Latest version keeps crashing randomly

10 views
Skip to first unread message

Matthieu Hendriks

unread,
Mar 3, 2026, 3:23:37 PMMar 3
to PythonSCAD
I downloaded the latest version and did a fresh compile and build.

After a few times F5/F6 pythonscad crashes.

It has to do something with garbage collecting

When i put in my design:
import gc
gc.disable() 

The crashes are gone. Oke for debugging but not ok for production I think.
Hope someone can solve this.
mhlib.py
mecano.py

William Adams

unread,
Mar 3, 2026, 6:36:40 PMMar 3
to PythonSCAD
Also, the current Windows build didn't work on my Windows 11 machine:

>The application was unable to start correctly  (xc0000142).
>Click OK to close the application.

William

John David

unread,
Mar 3, 2026, 6:44:30 PMMar 3
to William Adams, PythonSCAD
Can you post a minimal example so others of us can give it a try?

--
You received this message because you are subscribed to the Google Groups "PythonSCAD" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pythonscad+...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/pythonscad/1ec9172b-bedc-4f43-a20e-2dcb17b21968n%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

William Adams

unread,
Mar 3, 2026, 6:50:35 PMMar 3
to PythonSCAD
That happens when first trying to launch --- no code executation.

Also, the dark mode setting is applied to menus in 15.0 (the first version back which worked):

Screenshot 2026-03-03 184827.png

William

John David

unread,
Mar 3, 2026, 10:19:29 PMMar 3
to William Adams, PythonSCAD
Sorry.  I cannot see your script with the black pop-up over the code.

Matthieu Hendriks

unread,
Mar 4, 2026, 12:23:44 AMMar 4
to John David, William Adams, PythonSCAD
That's one of the problems a minimal example doesn't crash.
 I included 2 files, one design and  one library file as an example. 
Without the:
import gc 
gc.disable() 

it crashes after a couple of F5/F6

Op wo 4 mrt 2026 om 00:44 schreef John David <ebo....@gmail.com>:

Matthieu Hendriks

unread,
Mar 4, 2026, 12:59:16 AMMar 4
to PythonSCAD
I uploaded the complete source code to NotebookLM and asked it to provide an analysis. This is what it came up with — and yes, this goes far beyond my level of knowledge:

The analysis of the source code and your findings regarding gc.disable() confirm that the spontaneous crashes in PythonSCAD are caused by a memory management conflict between the Python Garbage Collector and the C++ OpenSCAD engine.
Technical Analysis of the Crash
  • Hybrid Memory Management: PythonSCAD uses a dual system where 3D objects are core C++ objects (using std::shared_ptr) wrapped in Python objects called PyOpenSCADObject.
  • Metadata and Circular References: Each Python wrapper contains an internal dictionary (self->dict) to store metadata and matrix information. This structure can easily create circular references—where a Python object points to a dictionary that eventually points back to the object itself [1071, Conversation History].
  • Aggressive Garbage Collection: The Python Garbage Collector (GC) attempts to break these circular references at unpredictable times. If the GC destroys a Python wrapper while the C++ engine is still using the underlying geometry for a task like CGAL rendering or CSG evaluation, the program will suffer a Segmentation Fault (crash).
  • Threading Conflicts: PythonSCAD utilizes worker threads for heavy computations like CSGWorker and CGALWorker. While the code uses locks to protect the interpreter, the GC can still trigger on the main thread and deallocate memory that a worker thread is currently accessing.
Why gc.disable() Works
By calling gc.disable(), you force Python to rely strictly on direct reference counting. This prevents the GC from "spontaneously" breaking down complex object structures in the middle of a render process, ensuring that objects remain alive as long as they are still needed by the C++ engine [Conversation History]. While this may lead to slightly higher memory usage for scripts with many circular references, it provides the stability necessary for executing complex 3D models [Conversation History].

Op woensdag 4 maart 2026 om 06:23:44 UTC+1 schreef Matthieu Hendriks:

nomike (they/them)

unread,
Mar 4, 2026, 4:42:00 AMMar 4
to William Adams, PythonSCAD
That seems to be a separate issue.

It would be very helpful, if you could create a ticket at https://github.com/pythonscad/pythonscad/issues.

I need to be able to reproduce the issue in order to be able to have a look at what's wrong.

The new issue template asks a few questions about your system. It would be helpful, if you could provide those (e.g. OS Version, what system you have, etc.).

Thanks!

nomike

4 Mar 2026 00:36:46 William Adams <william.fra...@gmail.com>:

--

nomike (they/them)

unread,
Mar 4, 2026, 4:47:29 AMMar 4
to William Adams, PythonSCAD
Just to clarify:
My comment about this being a separate issue was a response to William about the crash on Windows 11. I just realized, that the interface of Google groups doesn't make that really obvious.

4 Mar 2026 10:42:05 nomike (they/them) <nom...@nomike.com>:

William Adams

unread,
Mar 5, 2026, 9:24:55 AMMar 5
to PythonSCAD
I put in an issue about the Dark/light theme menu visibility issue at Github.

William

nomike Postmann

unread,
Mar 5, 2026, 9:36:19 PMMar 5
to PythonSCAD
Thanks gsohler for opening #480.

As I just commented there, I was able to reproduce the crash with version 0.14.2. I was not able to reproduce it with the current version.
I recently fixed some memory safety related bugs, which also seems to have solved this crash (among a few others probably).

Let me know please if you still experience this specific crash with the latest release (or the current master version, in case you're building from source).

If you have other problems, it would be very helpful if you could open a new issue on github.

Matthieu Hendriks

unread,
Mar 6, 2026, 11:21:33 AMMar 6
to PythonSCAD
I downloaded the latest version, did a complete rebuild. And it looked oke, no direct crashing.
Rebooted my machine (ubuntu) started the same model and => crash.
Did a make clean
make install
=> crashing.

With :
import gc
gc.disable()

Crashes are gone.

Op vrijdag 6 maart 2026 om 03:36:19 UTC+1 schreef michael....@gmail.com:
Reply all
Reply to author
Forward
0 new messages