bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#11845: guile-1.8.8 segfaults at build-time with gcc-4.6.3 and -O3


From: Cyprien Nicolas
Subject: bug#11845: guile-1.8.8 segfaults at build-time with gcc-4.6.3 and -O3
Date: Mon, 02 Jul 2012 20:36:39 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/20120622 Firefox/13.0.1 SeaMonkey/2.10.1

Hello guilers,

Origin: https://bugs.gentoo.org/show_bug.cgi?id=424475

- CONFIGURATION -
-----------------

# emerge --info --ignore-default-opts
Portage 2.2.0_alpha113 (default/linux/x86/10.0/desktop, gcc-4.6.3,
glibc-2.15-r2, 3.2.1-gentoo-r2 x86_64)
=================================================================
System uname:
address@hidden
app-shells/bash:          4.2_p29
dev-util/pkgconfig:       0.26
sys-apps/baselayout:      2.1-r1
sys-apps/openrc:          0.10.3
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.11.5, 1.12.1
sys-devel/binutils:       2.22-r1
sys-devel/gcc:            4.5.3-r2, 4.6.3, 4.7.1
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4.2
sys-devel/make:           3.82-r3
sys-kernel/linux-headers: 3.4 (virtual/os-headers)
sys-libs/glibc:           2.15-r2


CFLAGS="-O2 -march=i686 -pipe -finline-functions -ggdb"



- BUILD FAILURE -
-----------------

(...)
cat alist.doc arbiters.doc async.doc backtrace.doc boolean.doc chars.doc
continuations.doc debug.doc deprecation.doc deprecated.doc
discouraged.doc dynl.doc dynwind.doc environments.doc eq.doc error.doc
eval.doc evalext.doc extensions.doc feature.doc fluids.doc fports.doc
futures.doc gc.doc goops.doc gsubr.doc gc-mark.doc gc-segment.doc
gc-malloc.doc gc-card.doc guardians.doc hash.doc hashtab.doc hooks.doc
i18n.doc init.doc ioext.doc keywords.doc lang.doc list.doc load.doc
macros.doc mallocs.doc modules.doc numbers.doc objects.doc objprop.doc
options.doc pairs.doc ports.doc print.doc procprop.doc procs.doc
properties.doc random.doc rdelim.doc read.doc root.doc rw.doc
scmsigs.doc script.doc simpos.doc smob.doc sort.doc srcprop.doc
stackchk.doc stacks.doc stime.doc strings.doc srfi-4.doc srfi-13.doc
srfi-14.doc strorder.doc strports.doc struct.doc symbols.doc threads.doc
throw.doc values.doc variable.doc vectors.doc version.doc vports.doc
weaks.doc ramap.doc unif.doc dynl.doc filesys.doc posix.doc
regex-posix.doc |
GUILE="/var/tmp/portage/dev-scheme/guile-1.8.8-r1/work/guile-1.8.8/pre-inst-guile"
../scripts/snarf-check-and-output-texi          > guile-procedures.texi
|| { rm guile-procedures.texi; false; }
/bin/sh: line 1:  8755 Broken pipe             cat alist.doc
arbiters.doc async.doc backtrace.doc boolean.doc chars.doc
continuations.doc debug.doc deprecation.doc deprecated.doc
discouraged.doc dynl.doc dynwind.doc environments.doc eq.doc error.doc
eval.doc evalext.doc extensions.doc feature.doc fluids.doc fports.doc
futures.doc gc.doc goops.doc gsubr.doc gc-mark.doc gc-segment.doc
gc-malloc.doc gc-card.doc guardians.doc hash.doc hashtab.doc hooks.doc
i18n.doc init.doc ioext.doc keywords.doc lang.doc list.doc load.doc
macros.doc mallocs.doc modules.doc numbers.doc objects.doc objprop.doc
options.doc pairs.doc ports.doc print.doc procprop.doc procs.doc
properties.doc random.doc rdelim.doc read.doc root.doc rw.doc
scmsigs.doc script.doc simpos.doc smob.doc sort.doc srcprop.doc
stackchk.doc stacks.doc stime.doc strings.doc srfi-4.doc srfi-13.doc
srfi-14.doc strorder.doc strports.doc struct.doc symbols.doc threads.doc
throw.doc values.doc variable.doc vectors.doc version.doc vports.doc
weaks.doc ramap.doc unif.doc dynl.doc filesys.doc posix.doc regex-posix.doc
      8756 Segmentation fault (core dumped)     |
GUILE="/var/tmp/portage/dev-scheme/guile-1.8.8-r1/work/guile-1.8.8/pre-inst-guile"
../scripts/snarf-check-and-output-texi > guile-procedures.texi
make[3]: *** [guile-procedures.texi] Error 1
make[3]: Leaving directory
`/var/tmp/portage/dev-scheme/guile-1.8.8-r1/work/guile-1.8.8/libguile'
make[2]: *** [all] Error 2
make[2]: Leaving directory
`/var/tmp/portage/dev-scheme/guile-1.8.8-r1/work/guile-1.8.8/libguile'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory
`/var/tmp/portage/dev-scheme/guile-1.8.8-r1/work/guile-1.8.8'
make: *** [all] Error 2

- PATHS -
---------

# pwd
/var/tmp/portage/dev-scheme/guile-1.8.8-r2/work/guile-1.8.8/libguile

# ldd .libs/guile
        linux-gate.so.1 (0xffffe000)
        libguile.so.17 =>
/var/tmp/portage/dev-scheme/guile-1.8.8-r2/work/guile-1.8.8/libguile/.libs/libguile.so.17
(0xf76c9000)
        libpthread.so.0 => /lib/libpthread.so.0 (0xf7696000)
        libc.so.6 => /lib/libc.so.6 (0xf7511000)
        libgmp.so.10 => /usr/lib/libgmp.so.10 (0xf74b2000)
        libcrypt.so.1 => /lib/libcrypt.so.1 (0xf7480000)
        libm.so.6 => /lib/libm.so.6 (0xf745a000)
        libltdl.so.7 => /usr/lib/libltdl.so.7 (0xf7451000)
        libdl.so.2 => /lib/libdl.so.2 (0xf744d000)
        /lib/ld-linux.so.2 (0xf77c4000)


- GDB SESSION -
---------------


# gdb .libs/guile core
GNU gdb (Gentoo 7.4.1 p1) 7.4.1
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.gentoo.org/>...
Reading symbols from
/var/tmp/portage/dev-scheme/guile-1.8.8-r2/work/guile-1.8.8/libguile/.libs/guile...done.
[New LWP 14880]

warning: Could not load shared library symbols for linux-gate.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
Core was generated by
`/var/tmp/portage/dev-scheme/guile-1.8.8-r2/work/guile-1.8.8/libguile/.libs/guil'.
Program terminated with signal 11, Segmentation fault.
#0  0xf76b4154 in scm_mark_locations (x=0xff908cac, n=4294967132) at
gc-mark.c:435
435           SCM obj = * (SCM *) &x[m];
(gdb) bt
#0  0xf76b4154 in scm_mark_locations (x=0xff908cac, n=4294967132) at
gc-mark.c:435
#1  0xf770eb22 in scm_threads_mark_stacks () at threads.c:1408
#2  0xf76b4076 in scm_mark_all () at gc-mark.c:82
#3  0xf76b38de in scm_i_gc (what=0xf772ae69 "cells") at gc.c:596
#4  0xf76b3a78 in scm_gc_for_newcell (freelist=0xf7760720,
free_cells=0x952e080) at gc.c:507
#5  0xf76efb32 in scm_double_cell (cdr=0, ccr=0, cbr=0, car=<optimized
out>) at ../libguile/inline.h:201
#6  make_stringbuf (len=10) at strings.c:116
#7  scm_i_c_make_symbol (name=0xf773276a "string-pad", len=10, flags=0,
hash=1161852829, props=0xf73b85e8) at strings.c:433
#8  0xf770d362 in scm_i_c_mem2symbol (len=<optimized out>,
name=0xf773276a "string-pad") at symbols.c:150
#9  scm_from_locale_symbol (sym=0xf773276a "string-pad") at symbols.c:388
#10 0xf76df3fa in scm_c_make_subr (name=0xf773276a "string-pad",
type=85, fcn=0xf7702740 <scm_string_pad>) at procs.c:69
#11 0xf76c08f2 in create_gsubr (define=1, name=<optimized out>, req=2,
opt=3, rst=0, fcn=0xf7702740 <scm_string_pad>) at gsubr.c:81
#12 0xf7703f5f in scm_init_srfi_13 () at ../libguile/srfi-13.x:20
#13 0xf76c509a in scm_i_init_guile (base=0xff908cac) at init.c:514
#14 0xf770e7fe in scm_i_init_thread_for_guile (parent=0x0,
base=0xff908cac) at threads.c:590
#15 scm_i_with_guile_and_parent (func=0xf76c4d60 <invoke_main_func>,
data=0xff908d00, parent=0x0) at threads.c:732
#16 0xf770e8fd in scm_with_guile (func=0xf76c4d60 <invoke_main_func>,
data=0xff908d00) at threads.c:721
#17 0xf76c4ea5 in scm_boot_guile (argc=5, argv=0xff908de4,
main_func=0x8048550 <inner_main>, closure=0x0) at init.c:350
#18 0x0804846b in main (argc=5, argv=0xff908de4) at guile.c:63
(gdb) up
#1  0xf770eb22 in scm_threads_mark_stacks () at threads.c:1408
1408          scm_mark_locations (t->base, t->top - t->base);
(gdb) print (t->top - t->base)
$1 = -164
(gdb) l
1403          assert (t->top);
1404    
1405          scm_gc_mark (t->handle);
1406    
1407    #if SCM_STACK_GROWS_UP
1408          scm_mark_locations (t->base, t->top - t->base);
1409    #else
1410          scm_mark_locations (t->top, t->base - t->top);
1411    #endif
1412          scm_mark_locations ((void *) &t->regs,


- COMMENTS -
------------

The GDB session show clearly that something is going wrong when
scm_mark_locations is called. Passing a negative value (interpreted as
an unsigned int) makes scm_mark_locations scanning almost the whole
memory, thus resulting in a segmentation fault.

The upper frame shows that the #if choice was wrong, leaving the
possibility of the SCM_STACK_GROWS_UP define to be wrong, here 1 instead
of 0 on standard x86 boxes.

That define value is computed using the find_stack_direction function
defined in configure.in:

int
find_stack_direction ()
{
  static char *addr = 0;
  auto char dummy;
  if (addr == 0)
    {
      addr = &dummy;
      return find_stack_direction ();
    }
  else
    return (&dummy > addr) ? 1 : -1;
}

int
main ()
{
  return find_stack_direction () < 0;
}

This small program gives different results on the same machine with
different gcc versions and CFLAGS combinations:

# gcc-4.5.3 find_stack_direction.c && ./a.out ; echo $?
1
# gcc-4.5.3 -O3 find_stack_direction.c && ./a.out ; echo $?
1
# gcc-4.6.3 find_stack_direction.c && ./a.out ; echo $?
1
# gcc-4.6.3 -O3 find_stack_direction.c && ./a.out ; echo $?
0
# gcc-4.7.1 find_stack_direction.c && ./a.out ; echo $?
1
# gcc-4.7.1 -O3 find_stack_direction.c && ./a.out ; echo $?
1

So we can find out the incriminating CFLAGS:

# gcc-4.6.3 -O3 -fno-inline-functions find_stack_direction.c && ./a.out
; echo $?
1


I'm not a GCC expert, so I cannot go further. My C programming skills
aren't enough to know if this procedure is correct or not :-)


guile-2.0.5 use a different find_stack_direction() procedure, that gives
the same result with gcc-4.6.3 with and without -O3:

# gcc-4.6.3 find_stack_direction2.c && ./a.out ; echo $?
1
# gcc-4.6.3 -O3 find_stack_direction2.c && ./a.out ; echo $?
1


I'll test with a vanilla gcc-4.6.3 (i.e. not patched by Gentoo) and keep
you informed if I cannot reproduce that issue with the vanilla.

Regards

-- 
,Cyprien





reply via email to

[Prev in Thread] Current Thread [Next in Thread]