Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opening and Empty .slvs File Causes a Crash (Was: "Crash after autosave-restore dialog wth file from v2.3") #918

Closed
someSven opened this issue Jan 31, 2021 · 4 comments · Fixed by #919
Milestone

Comments

@someSven
Copy link

System information

  • **SolveSpace version:3.0~3e3ccdca
  • **Operating system:Raspian wth OpenGL active

Expected behavior

Autosave file from v2.3 should open on v3 when I click to load it in the startup dialog.

Actual behavior

Crash.

Additional information

  • I have OpenGL activated.
  • The file was created in Solvespace 2.3, it works if I choose not to restore the autosave.
  • It's not important to me, just thought you should know.

Shell:
(solvespace:18054): Gtk-CRITICAL **: 10:57:23.745: gtk_file_chooser_widget_set_current_name: assertion 'priv->action == GTK_FILE_CHOOSER_ACTION_SAVE || priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER' failed
File ./src/graphicswin.cpp, line 394, function Init:
Assertion failed: !SK.groupOrder.IsEmpty().
Message: Group order can't be empty since we will activate the last group..
Aborted

Chuwi-Guard.slvs.zip

@phkahler
Copy link
Member

Not sure what the issue is, but it looks like a problem in 2.3 or even current version with auto-save. There are 2 files in the zip archive. One of them is zero length so I opened the other one and it works fine. Is the problem actually the empty file? Does it actually work on 2.3?
issue918

@someSven
Copy link
Author

someSven commented Feb 1, 2021

I tried again. The problem is the empty autosave file, which v2.3 created at some point. After putting it back into the same dir than the file I want to open, it crashes after trying to load the real file, if I click on "Load autosave". Same with both versions of Solvespace. If I click not to load it, then it works with both versions, the same if I delete the autosave-file.

@ruevs
Copy link
Member

ruevs commented Feb 1, 2021

There is a problem when opening empty (0 bytes long) .SLVS files.
I'll fix it.

OpenEmptyFileProblem

The problem is that here:

ClearExisting();

we clear all groups. Then we try to read an empty file and therefore this while exists immediately:
while(fgets(line, (int)sizeof(line), fh)) {

and we come to here:
if(fileLoadError) {

where there is no fileLoadError and thus we are left with no groups, and so this assert fails:
"Group order can't be empty since we will activate the last group.");

since is is not allowed to have no groups :-)

@ruevs ruevs changed the title Crash after autosave-restore dialog wth file from v2.3 Opening and Empty .slvs File Causes a Crash (Was: "Crash after autosave-restore dialog wth file from v2.3") Feb 1, 2021
ruevs added a commit to ruevs/solvespace that referenced this issue Feb 1, 2021
@ruevs
Copy link
Member

ruevs commented Feb 1, 2021

Fixed.

@someSven someSven closed this as completed Feb 1, 2021
@ruevs ruevs added this to the 3.0 milestone Feb 3, 2021
phkahler pushed a commit that referenced this issue Feb 3, 2021
Fixes: #918

The problem was that here:
https://github.com/solvespace/solvespace/blob/11a8a0abd5e21a0da6c818674f8b4b657a401a6c/src/file.cpp#L480
we cleared all groups. Then we tried to read an empty file and therefore this `while` exited immediately:
https://github.com/solvespace/solvespace/blob/11a8a0abd5e21a0da6c818674f8b4b657a401a6c/src/file.cpp#L487
and we came to here:
https://github.com/solvespace/solvespace/blob/11a8a0abd5e21a0da6c818674f8b4b657a401a6c/src/file.cpp#L548
where there was no `fileLoadError` and thus we were left with no groups, and so this assert failed:
https://github.com/solvespace/solvespace/blob/11a8a0abd5e21a0da6c818674f8b4b657a401a6c/src/graphicswin.cpp#L394
since is is not allowed to have no groups :-)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants