About:

GNUGoS60 is a port of the FSF's GNU Go game engine to Nokia's S60 smartphone platform running on SymbianOS.

It is Free Software.

Saturday, November 18, 2006

Unresolved external symbol __chkstk

I have found that in some places I get random crashes of the application. After some investigation this seems to be caused by stack overflow. Generally I get it when gnugo is doing memset or something similar on a large array. Actually this is hard to debug in the emulator to begin with because it just kills the debugger without showing anything useful other than a "first chance exception" dialog box. The way around that is to replace the system memset with my own version that just is a for loop filling in the memory instead of whatever assember magic the system version does. This causes the debugger to terminate nicely showing the line of code where it overflows.

So why am I getting these. Well for starters because I ignored all the "Unresolved external symbol __chkstk" messages and went ahead and defined __chkstk just to get the thing running in the emulator. So much for shortcuts :)

After removing that definition, gnugo leaves 7 or 8 files which have obviously too large stacks. Unfortunately those files are each 100-200kB in size, so I spent a lot of time going through the files allocating all the arrays and large structures on the heap instead of the stack. It took a long time, but had to be done.

0 comments: