-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Some DraftCreation unit tests fail randomly #18679
Comments
cc @Roy-043 |
The issue is indeed that documents can get closed before delayed code that should act on them has had a chance to execute. I suppose this is an example of a 'race condition'. What is interesting is that the referenced code in gui_trackers.py actually checks if there is a valid 3D view. So it appears documents get closed at the exact moment that code runs. FreeCAD/src/Mod/Draft/draftguitools/gui_trackers.py Lines 93 to 100 in e977eb4
WorkingPlane.py is responsible for (some of) the delayed code. That code triggers the grid (among other things) based on view changes. FreeCAD/src/Mod/Draft/WorkingPlane.py Lines 1791 to 1804 in e977eb4
The tests that close documents too soon are actually dummy tests ( In a way that solution avoids the problem rather than solving it. To really solve it I suppose we should add @kpemartin Can please you test with the attached file? Thanks.
|
I ran the file and it succeeded but the only way I could ever get the failure was to run the complete test suite (-r 0) so I'm not surprised this subset did not fail.
There is perhaps a larger time window between the Come to think of it, it is possible that the window being closed by the test that did the delay call has actually closed, popping back to some unrelated previous active window, which may also be closing asynchronously. Asking for the Active window in (arbitrarily) delayed code and expecting to get any particular window just sounds like a Bad Idea because who knows what window will be active at that time. One way to avoid this is to have the code that does the delay call query the view at that time, and pass it as an argument to the delayed code. But then, perhaps the whole reason for the delay is that this is too early to find the view. |
Some Draft test files contain only dummy tests (`aux.fake_function`). Running them will just open a new file and then immediately close it. This can result in issues with code that is called with a delay. See FreeCAD#18679. Disabling these tests by commenting them out avoids this.
Is there an existing issue for this?
Problem description
When running the full suite of unit tests in the Gui app, some of the
DraftCreation
tests fail non-deterministically.Several of these tests, such as the one calling itself "Draft Dimension Angular" can sometimes produce a Windows exception 0xC0000005 (memory access violation). Furthermore, when handling this exception another error occurs in the form of a
std::exception
with the message "invalid format specifier" which causes a popup message window with the same text and ends the test run.The actual original exception occurs in
View3DInventorPy::getSceneGraph
on the linescene->ref()
becausescene
is null.This only seems to occur if the entire test suite (TestApp.All) is run. It does not matter if this is done from the command line using
-r 0
or by using the test workbench.This particular test even admits
Occasionally crashes
with no further explanation. Looking at the code history provides no details as to whether this is the "occasional crash" the comment refers to.It would appear that the crash occurs because code delayed using
ToDo.delay
is delayed long enough that the document window is already closed (I'm guessing here) so there is noscene
any more. The call toToDo.delay
is inTracker.__init__
ingui_tracker.py
.The full Console Log is attached, but here is a summarized extract:
Full log: Null scene exception.zip
This log seems to imply that there are two access violations, which would imply that there are two
ToDo
entries, each of which causes an exception once the message loop runs the delayed code. This double exception might ultimately be the cause of the "invalid format specifier"Full version info
Subproject(s) affected?
None
Anything else?
The immediate fix is to change
View3DInventorPy::getSceneGraph
to return a pythonNone
is scene is null.This does not explain the second "invalid format specifier" error, so perhaps that should be analyzed before fixing
View3DInventorPy::getSceneGraph
.Code of Conduct
The text was updated successfully, but these errors were encountered: