sakya/corechess

Load/Save Game as PGN crashes the app

Closed this issue ยท 9 comments

Hello,

There's a filetype option for PGN games in file choosing dialogs, but when I try to load or save a game as a PGN, the app crashes.

Using flatpak version on Ubuntu 22.04.

sakya commented

Can you please share the content of ~/.var/app/com.github.sakya.corechess/data/CoreChess/crash.log?

Sure. Here it is:

[20220710_171405] Failed to load file
[20220710_171405] at ChessLib.PGN.LoadGamePrimitive(Stream stream, Int64 filePosition)
at ChessLib.PGN.LoadFromStream(Stream stream)
at ChessLib.PGN.LoadFile(String file)
at CoreChess.Views.MainWindow.OnLoadGameClick(Object sender, RoutedEventArgs e) in /run/build/CoreChess/CoreChess/Views/MainWindow.axaml.cs:line 601
at System.Threading.Tasks.Task.<>c.b__128_0(Object state)
at Avalonia.Threading.JobRunner.RunJobs(Nullable`1 priority) in //src/Avalonia.Base/Threading/JobRunner.cs:line 37
at Avalonia.X11.X11PlatformThreading.CheckSignaled() in /
/src/Avalonia.X11/X11PlatformThreading.cs:line 164
at Avalonia.X11.X11PlatformThreading.RunLoop(CancellationToken cancellationToken) in //src/Avalonia.X11/X11PlatformThreading.cs:line 244
at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken) in /
/src/Avalonia.Base/Threading/Dispatcher.cs:line 65
at CoreChess.App.Run(CancellationToken ct) in /run/build/CoreChess/CoreChess/App.axaml.cs:line 127

sakya commented

Thanks for the feedback. It seems a problem with the saved file. Can you also share the PGN?

Here it is, (a bit lengthy, sorry):

[Event "Hastings"]
[Site "Hastings ENG"]
[Date "1895.08.17"]
[Round "10"]
[White "Wilhelm Steinitz"]
[Black "Curt von Bardeleben"]
[Result "1-0"]
[ECO "C54"]
[PlyCount "69"]
[EventDate "1895.08.05"]

  1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. c3 Nf6 5. d4 exd4 6. cxd4 Bb4+ 7. Nc3 {
    [pgndiagram] Sharp gambits such as this one were quite popular in the 19th
    century.} d5 {Not a critical reply} (7... Nxe4 {"The best way of refuting a
    gambit is to accept it"} 8. O-O Bxc3 {And now White has a choice} (8... Nxc3 9.
    bxc3 Bxc3 10. Qb3 {Is very dangerous for Black}) 9. bxc3 {[pgndiagram] And the
    tabiya of the variation is reached} (9. d5 $5 {Is probably playable,
    especially if Black doesn't know what he is doing}) 9... d5 (9... Nxc3 10. Qe1+
    ) 10. Bd3) 8. exd5 {Now White has the initiative} Nxd5 9. O-O Be6 (9... Bxc3 {
    Here Black can't go for the pawn} 10. bxc3 Nxc3 {loses to} 11. Qe1+) (9... Nxc3
    {Again loses to} 10. bxc3 Bxc3 11. Qb3) 10. Bg5 Be7 (10... Qd7 {Was arguably
    better} 11. Nxd5 Bxd5 12. Qb3 Bxf3 {[pgndiagram]} (12... Bxc4 13. Qxc4 O-O 14.
    d5) 13. Qxf3 O-O {And Black will have to suffer, but his position is
    definitely defensible}) 11. Bxd5 $1 {[pgndiagram] A very counterintuitive
    exchange. You can feel the understanding Steinitz had for the game from moves
    like these. His games are full of deep strategic ideas.} Bxd5 {The right
    recapture} (11... Bxg5 {Is horrible for Black} 12. Bxe6 fxe6 13. d5 {And Black
    is close to being lose} exd5 14. Re1+ Kf7 15. Nxd5 {[pgndiagram] With such a
    king and undeveloped rooks, Black is doomed}) 12. Nxd5 Qxd5 $1 {Once again the
    right choice} (12... Bxg5 {Is bad due to} 13. Re1+ {The most clear cut} (13.
    Nxg5 {But not} Qxd5) (13. Nxc7+ {Wins a pawn} Qxc7 14. Nxg5) 13... Be7 14. Qb3
    {[pgndiagram] And White has a winning position. Here it pays not to go for an
    endgame, but to continue building up some pressure}) 13. Bxe7 Nxe7 14. Re1 {
    [pgndiagram] If only Black could castle, he would have no problems whatsoever.
    As it is, White has the initiative} f6 (14... Qd7 {Would allow the extra tempo
    on the knight} 15. Ne5 Qd8 16. Qf3 {And White is winning}) (14... Qd6 {Would
    likely transpose, although the queen on d6 is subjecto to knight attack from
    e4 or c4} 15. Qe2 f6) 15. Qe2 Qd7 16. Rac1 $2 {[pgndiagram] So far the game
    has been of a rather high quality. This move releases the tension} (16. d5 Kf7
  2. Rad1 {With the idea of d6 push would maintain White's initiative}) 16... c6
    $2 {And immediately Bardeleben returns the favour} (16... Kf7 {Was correct.
    Black shouldn't have feared the potential sacrifice of the knight} 17. Ne5+
    fxe5 18. dxe5 Qe6 19. Qf3+ Kg8 20. Rxc7 {[pgndiagram] Although this is highly
    unpleasant, he should be able to unravel his forces and fight for the draw})
  3. d5 $1 {[pgndiagram] A thematic clearance move.Now White is winning. The
    way Steinitz concludes the game is highly spectacular} cxd5 18. Nd4 {The
    knight is coming to e6 with great effect} Kf7 19. Ne6 Rhc8 (19... Nc6 {Was no
    better, due to the weakness of d5 pawn} 20. Nc5 Qd6 (20... Qc7 21. Qh5+ {Wins
    immediately}) 21. Nxb7 Qd7 22. Nc5 {And White retains the dominating position})
  4. Qg4 {Now the g7 also is weak} g6 21. Ng5+ $1 {[pgndiagram] A highly
    attractive finish and one of the most remarkable combinations in the history
    of chess.} Ke8 22. Rxe7+ $3 {A fantastic blow. At first sight it seems that
    White will overextend himself, because his back rank is weak. But Steinitz has
    calculted everything precisely} Kf8 $1 {[pgndiagram] The best chance} (22...
    Kxe7 23. Qb4+ {Wins} Ke8 24. Re1+ {[pgndiagram]} Kd8 25. Ne6+ {And Black has
    to give up his queen due to mate on f8. And luckily for him, White has Re1 to
    prevent back rank mate after he takes on e6} Qxe6 26. Rxe6 Rc1+ 27. Re1) 23.
    Rf7+ $1 {The combination continues} Kg8 24. Rg7+ {Naturally, now Black can't
    take the rook on g7 due to capture on d7 with check} Kh8 25. Rxh7+ {
    [pgndiagram] Here Bardeleben left the game. Steinitz willingly demonstrated
    the spectators what awaited his opponent had he continued the game} Kg8 26.
    Rg7+ Kh8 (26... Kf8 27. Nh7+) 27. Qh4+ Kxg7 28. Qh7+ Kf8 29. Qh8+ Ke7 30. Qg7+
    Ke8 31. Qg8+ Ke7 32. Qf7+ Kd8 33. Qf8+ Qe8 34. Nf7+ Kd7 35. Qd6# {[pgndiagram]
    And at the end of the story, everything concludes with an epaulette mate.
    Fantastic} 1-0

Edit: Github screwed the format, but it is a valid pgn as far as I can tell. The editor created a numbered list, and I don't know how to correct it.

The game is the first one of the pgn on this link: https://chessentials.com/storage/2020/03/Steinitz-Best-Games.zip

BTW, saving any game as a pgn crashes the app too.

sakya commented

That's strange, I tried to save a couple of games in PGN on my system (arch) and it works. Can you please share the content of ~/.var/app/com.github.sakya.corechess/data/CoreChess/crash.log after a crash occurred when saving a game?
Thanks for your time

Thank you, I will. In the meantime, I stripped the file of comments and variations in scid, and CoreChess could open it nicely. You were right, it was the pgn file. But the file was a valid pgn, since scid could import it without errors or warnings.

Thank you for your time too, and for a nice app.

sakya commented

Probably it's due to the comments/variations, I'll try to fix it.

I just compiled 0.11.3 and tried. PGN loading works great. Thank you.

Edit: I just don't know how to install it, lol. I'll wait for the release.