[Vm-dev] Getting stable Cog build on Ubuntu linux

Igor Stasenko siguctua at gmail.com
Sun Nov 7 07:00:17 UTC 2010

On 22 October 2010 04:40, Eliot Miranda <eliot.miranda at gmail.com> wrote:
> On Thu, Oct 21, 2010 at 6:35 PM, Igor Stasenko <siguctua at gmail.com> wrote:
>> Hello,
>> few weeks ago i reported that i experienced Cog VM crashes soon after
>> starting it.
>> I though that it could be related to pthread library, listed twice in
>> GCC options..
>> I was managed to build a stable VM but now i found that problem is not in that!
>> The VM, which i was built were using debugging-enabled, with all
>> bells&whistles config..
>> But once i tried a 'release' config, the VM is crashing:
>> ../../platforms/unix/config/configure --without-vm-display-fbdev
>> --without-npsqueak -prefix=/home/sig/cogvm/ CFLAGS="-g -O2 -msse2
>> Then i tried to gradually change various options and foudn that this
>> one produces stable VM:
>> ../../platforms/unix/config/configure --without-vm-display-fbdev
>> --without-npsqueak -prefix=/home/sig/cogvm/ CFLAGS="-g -O1 -msse2
>> (the difference is just an optimization option O2 vs O1 )
>> It seems like a compiler related issue..
>> Any ideas what wrong with O2?
>> gcc --version
>> gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
>> Copyright (C) 2009 Free Software Foundation, Inc.
>> This is free software; see the source for copying conditions.  There is NO
> I'm pretty sure I use gcc 4.2.  You might want to try compiling the files (especially cointerp.c cogit.c sqUnixThreads.c) with -O1 one by one to localise the problem.  I've seen problems with the cogit's use of alloca and if you look at the configure build system it forces compiling cogit.c with -O1.  If you're perhaps using CMake then you'll want to modify it to compile cogit.c with -O1 also.  The issue is the cogit's use of alloca which seems to confuse gcc.

I took your advice, by putting -O1 against each file in /vm dir and
found the culprit. Its sqUnixHeartbeat.c.
And it feels right, because
a) VM crashing at random point.
b) gdb reports that segfault is not in main thread (while still
refuses to show any traces/source)

Sometimes its crashing just after boot, sometimes it takes 10-20
seconds before crash,
and it completely doesn't matters what i doing. So, i suspect that
optimization somehow breaking the concurrent code.
But its just a wild guess, since i didn't examined source and have
only general understanding what it does (heartbeat, yeah :).

After putting -O1 against this file, VM is now stable.

Even more, i removed O1 and other flags from cogit.c compilation, and
still my VM is stable,
and even got a small increase in performance:

1 tinyBenchmarks
 '480300187 bytecodes/sec; 38529212 sends/sec'
 '473197781 bytecodes/sec; 34610052 sends/sec'
 '482563619 bytecodes/sec; 34486533 sends/sec'
  '468864468 bytecodes/sec; 34412844 sends/sec'

 '500978473 bytecodes/sec; 38284970 sends/sec'
 '500978473 bytecodes/sec; 40296608 sends/sec'
 '506930693 bytecodes/sec; 38103811 sends/sec'

so, cogit.c is now compiled with following:

cogit$o : $(srcdir)/vm/cogit.c
	$(COMPILE) cogit$o $(srcdir)/vm/cogit.c

I'm not sure maybe some other flags better be preserved (since i don't
know meaning of all of them):

> Eliot
>> --
>> Best regards,
>> Igor Stasenko AKA sig.

Best regards,
Igor Stasenko AKA sig.

More information about the Vm-dev mailing list