[racket-dev] SGC as default

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Aug 12 03:46:52 EDT 2014

The gcc 4.9 release notes warn about this optimization:

 https://gcc.gnu.org/gcc-4.9/porting_to.html

I'm surprised that this change hasn't caused more trouble for us.

At Tue, 12 Aug 2014 08:39:01 +0100, Matthew Flatt wrote:
> Apparently, when gcc 4.9.1 sees
> 
>  memcpy(x, y, n);
>  if (y)
>    ....
> 
> then it believes `y` can be assumed to be NULL --- even if `n` turns
> out to be zero --- and so the conditional can be optimized away.
> 
> I'm surprised by that rule, but it's easy enough to move the test
> before the memcpy().
> 
> At Tue, 12 Aug 2014 02:00:04 -0400, Asumu Takikawa wrote:
> > On 2014-08-12 06:06:51 +0100, Matthew Flatt wrote:
> > > What platform are you using?
> > > 
> > > I imagine that running `./racketcgc` within the "racket" subdirectory
> > > of your build directory will similarly crash. Can you get any
> > > information from running `gdb racketcgc`?
> > 
> > This is on Linux. Running the built executable immediately produces a 
> segfault.
> > 
> > Here's a backtrace from gdb:
> >   (gdb) bt
> >   #0  0x00000000005e78db in free_managed (s=s at entry=0x0) at 
> > ../../../racket/sgc/sgc.c:1535
> >   #1  0x00000000005e7f63 in GC_add_roots (start=start at entry=0x881b70 
> > <collects_path>, end=end at entry=0x881b79 <run_cmd+1>) at 
> > ../../../racket/sgc/sgc.c:1657
> >   #2  0x0000000000576f9a in scheme_register_static (ptr=ptr at entry=0x881b70 
> > <collects_path>, size=size at entry=8) at ../../../racket/src/salloc.c:720
> >   #3  0x000000000045b87f in scheme_set_collects_path 
> (p=p at entry=0x7ffff7f701a0) 
> > at ../../../racket/src/file.c:6841
> >   #4  0x0000000000436673 in run_from_cmd_line (mk_basic_env=<optimized out>, 
> > cont_run=0x435a10 <cont_run>, _argv=<optimized out>, argc=0) at 
> > ../../racket/cmdline.inc:1444
> >   #5  main_after_stack (data=data at entry=0x7fffffffdc30) at 
> > ../../racket/main.c:450
> >   #6  0x000000000057694d in do_main_stack_setup (data=0x7fffffffdc30, 
> > _main=0x435a80 <main_after_stack>, no_auto_statics=1) at 
> > ../../../racket/src/salloc.c:198
> >   #7  scheme_main_stack_setup (no_auto_statics=no_auto_statics at entry=1, 
> > _main=_main at entry=0x435a80 <main_after_stack>, data=data at entry=0x7fffffffdc30)
> >       at ../../../racket/src/salloc.c:310
> >   #8  0x00000000004346ee in main_after_dlls (argv=<optimized out>, 
> > argc=<optimized out>) at ../../racket/main.c:381
> >   #9  main (argc=<optimized out>, argv=<optimized out>) at 
> > ../../racket/main.c:341
> > 
> > Cheers,
> > Asumu
> _________________________
>   Racket Developers list:
>   http://lists.racket-lang.org/dev

Posted on the dev mailing list.