Hi, My variant of Cog still keeps crashing in GC, but now it seems I made those crashes more "consistent". Now I am posting my code to better illustrate the problem, maybe this helps. Fileout of the class which implements my variant of VM. http://pastebin.com/WJKtXVk5 It overrides few methods of its parent classes to implement the event-driven VM. Most important changes are in methods interpret, wakeHighestPriority, and transferTo. The crash log (output of printOop inserted at each entry of markAndTrace) http://pastebin.com/sHSyHqHE It shows the debug output from the last entry in the interpreter after which GC happens which crashes. The host program runs the interpreter like this: ------------------------------------------------------ if (runInterpreter) { interpret(); while(1) { int rc; if(!aioPoll(1000)) continue; heartbeat(); printf("enter interpreter\n"); rc = interpret(); printf("exit interpreter: %d\n", rc); if(rc == 1) break; } } ------------------------------------------------------ and heartbeat() is reduced to ------------------------------------------------------ void heartbeat() { int saved_errno = errno; printf("heartbeat\n"); updateMicrosecondClock(); if (get64(frequencyMeasureStart) == 0) { set64(frequencyMeasureStart,utcMicrosecondClock); heartbeats = 0; } else heartbeats += 1; forceInterruptCheckFromHeartbeat(); errno = saved_errno; } ------------------------------------------------------ In order to put the VM into event-driven mode, the following is executed in a workspace: (ProcessorScheduler classPool at: #BackgroundProcess) terminate. VM continues working, interpreter is entered on any mouse move or click, I could open World menu for example. First GC crashes. It is my understanding that longjmp I use to exit the interpreter somehow does not unwind the native stack properly thus corrupting the heap which crashes GC. What could it be? Thanks for any ideas. -- Dimitry Golubovsky Anywhere on the Web |
On 18 July 2011 05:55, Dimitry Golubovsky <[hidden email]> wrote: > > Hi, > > My variant of Cog still keeps crashing in GC, but now it seems I made > those crashes more "consistent". Now I am posting my code to better > illustrate the problem, maybe this helps. > > Fileout of the class which implements my variant of VM. > > http://pastebin.com/WJKtXVk5 > > It overrides few methods of its parent classes to implement the > event-driven VM. Most important changes are in methods interpret, > wakeHighestPriority, and transferTo. > > The crash log (output of printOop inserted at each entry of markAndTrace) > > http://pastebin.com/sHSyHqHE > > It shows the debug output from the last entry in the interpreter after > which GC happens which crashes. > > The host program runs the interpreter like this: > > ------------------------------------------------------ > if (runInterpreter) { > interpret(); > while(1) { > int rc; > if(!aioPoll(1000)) continue; > heartbeat(); > printf("enter interpreter\n"); > rc = interpret(); > printf("exit interpreter: %d\n", rc); > if(rc == 1) break; > } > } > ------------------------------------------------------ > > and heartbeat() is reduced to > > ------------------------------------------------------ > void > heartbeat() > { > int saved_errno = errno; > printf("heartbeat\n"); > updateMicrosecondClock(); > if (get64(frequencyMeasureStart) == 0) { > set64(frequencyMeasureStart,utcMicrosecondClock); > heartbeats = 0; > } > else > heartbeats += 1; > forceInterruptCheckFromHeartbeat(); > > errno = saved_errno; > } > ------------------------------------------------------ > > In order to put the VM into event-driven mode, the following is > executed in a workspace: > > (ProcessorScheduler classPool at: #BackgroundProcess) terminate. > > VM continues working, interpreter is entered on any mouse move or > click, I could open World menu for example. First GC crashes. > > It is my understanding that longjmp I use to exit the interpreter > somehow does not unwind the native stack properly thus corrupting the > heap which crashes GC. What could it be? > > Thanks for any ideas. > The only thing what i can say that crash in CG usually indicates that heap is corrupted. Because it is hard to believe that your changes trigger some bug in GC. :) > -- > Dimitry Golubovsky > > Anywhere on the Web > -- Best regards, Igor Stasenko AKA sig. |
In reply to this post by Dimitry Golubovsky
Hi Dimitry. I will probably be completely useless, but one of the things I would do is to compile the VM in debug mode (in fact, only the asserts is needed). If you are compiling Cog with CMakeVMMaker just use a debug config. The important flags are DNDEBUG and DDEBUGVM. For more details read: http://forum.world.st/DNDEBUG-0-and-DDEBUGVM-1-td3447587.html My guess is that the VM is crashing as you said because of a corrupted stack, so when it crash you don't have any useful information. So...once you build a VM with debug you will also have the asserts. So run the VM from command line, and all those assert that fails will be shown in the console and they will show the value of the variables involved in the assert. With this, you can see as soon as a assert fails (which may be much before the crash) and could point you to something interesting :) Good luck. On Mon, Jul 18, 2011 at 5:55 AM, Dimitry Golubovsky <[hidden email]> wrote:
-- Mariano http://marianopeck.wordpress.com |
In reply to this post by Dimitry Golubovsky
On Sun, Jul 17, 2011 at 11:55:33PM -0400, Dimitry Golubovsky wrote: > > VM continues working, interpreter is entered on any mouse move or > click, I could open World menu for example. First GC crashes. > > It is my understanding that longjmp I use to exit the interpreter > somehow does not unwind the native stack properly thus corrupting the > heap which crashes GC. What could it be? > > Thanks for any ideas. Dimitry, I certainly do not know what the problem is, but here are some ideas: - I would be inclined to suspect interations between pthreads and longjmp. I know that you have taken the heartbeat out its separate thread, but check if there is any other use of pthreads anywhere in your VM or plugins. My hunch is that longjmp and pthreads are unlikely to work well together. - Check if anyone other than you is calling setjmp, either somewhere in the Cog support code, or perhaps in a support library (pthreads again? I do not know). - The man page for longjmp warns about effects on the signal context and advises to use siglongjmp if this is an issue. I doubt that this is your problem, but it's worth mentioning. HTH, Dave |
Free forum by Nabble | Edit this page |