Awesome news!
Actually, yes, reading this from : Technical Q&A QA1419: Customizing Process Stack Size
Q: My application maintains a large number of concurrent threads and needs to use a large amount of stack allocated data. How can I protect against overflowing my allocated stack space?
A: My application maintains a large number of concurrent threads and needs to use a large amount of stack allocated data. How can I protect against overflowing my allocated stack space?
Each Mac OS X process is launched with a default stack size of 8 Megabytes. This allocation is used exclusively for the main thread’s stack needs. Each subsequent thread created is allocated its own default stack, the size of which differs depending on the threading API used. For example, the Mac OS X implementation of Pthreads defines a default stack size of 512 Kilobytes, while Carbon MPTasks are created with a 4 Kilobyte stack.
Then I see that 512Kb is indeed too small.
Holy crap! That was just this ? What a waste of time! I had the same issue on Windows, but at least, the error message was "Stack overflow"
which was clear enough to understand what was going on…
I’ve actually already worked hard these last years to decrease the stack usage in the G’MIC code (to fix the issue on Windows). The fact that the stack size for the main thread and the secondary threads are not the same didn’t help finding the issue. That’s really awesome to know, thanks a lot Andrea!
So, now, it would be great to determine the “optimal” stack size for each thread. I think 8Mb is maybe too much. On Windows, I’ve used a #pragma
to set it to approx. 6.5Mb (line 147, file gmic.h). Maybe you could try with 6.5Mb too. Trying this ultimate recursive test to determine the best size could help: While the following code crashes, you need to add some stack size.
gmic _l=0 -m "foo : _l={\$_l+1} -foo" -parallel \"-skip\",-foo
which gives this (on Linux, so with a correct stack size and no crash) :
[gmic]-0./ Start G’MIC interpreter.
[gmic]-0./ Set global variable _l=‘0’.
[gmic]-0./ Import custom commands from expression ‘foo : _l={$_l+1} -foo’ (added 1 command, total 6197).
[gmic]-0./ Execute 2 commands ‘-skip,-foo’ in parallel and wait thread termination immediately.
[gmic]-0./*thread1/foo/ Set global variable _l=‘1’.
[gmic]-0./*thread1/foo/foo/ Set global variable _l=‘2’.
[gmic]-0./*thread1/foo/foo/foo/ Set global variable _l=‘3’.
[gmic]-0./*thread1/foo/foo/foo/foo/ Set global variable _l=‘4’.
[gmic]-0./*thread1/foo/foo/foo/foo/foo/ Set global variable _l=‘5’.
[gmic]-0./*thread1/foo/foo/foo/foo/foo/foo/ Set global variable _l=‘6’.
[gmic]-0./*thread1/foo/foo/foo/foo/foo/foo/foo/ Set global variable _l=‘7’.
…
[gmic]-0./*thread1/foo/foo/(…)/foo/foo/foo/foo/ Set global variable _l=‘61’.
[gmic]-0./*thread1/foo/foo/(…)/foo/foo/foo/foo/ Set global variable _l=‘62’.
[gmic]./*thread1/foo/foo/(…)/foo/foo/foo/foo/ *** Error *** Call stack overflow (infinite recursion ?).
Please, tell us. I’m so excited by the news. I think this could deserve a new stable release (currently planed is 1.6.6.0).
Having in the same week the GEGL stuff included in the plug-in for GIMP 2.9, and the bug fix for MacOSX… wow!