Subject: Re: bug#10235: guile 2.0.3 segfaults on FreeBSD 9

From: Andy Wingo <[email-masked]>
Date: Thu, 22 Dec 2011 10:35:33 -0500

Hi Jim,

There are some packaging-specific things in your mail, one bug, and a
few FreeBSD-related things that we should probably fold into Guile.
I'll try to reply only to those things that we need to do in Guile.

On Tue 06 Dec 2011 10:53, "Jim Pryor" <[email-masked]> writes:

>         REINPLACE_FILES=        libguile/smob.c libguile/gc.c \
>                                 libguile/mallocs.c libguile/gc-malloc.c
>
>         post-patch:
>                 @cd ${WRKSRC} ; sed -e 's|<malloc\.h>|<stdlib.h>|g'

I have fixed these files to use stdlib.h instead of malloc.h.

>           GEN    guile-procedures.texi
>         Segmentation fault (core dumped)

That's a problem :)

> And indeed if you just go to the libguile directory and execute the
> build `guile` file manually, you get a segfault. Here is the backtrace:
>
>     #0  0x000000080091f8a5 in scm_c_vm_run () from
>     /usr/obj/usr/ports/lang/guile/work/guile-2.0.3/libguile/.libs/libguile-2.0.so.25
>     [New Thread 802807400 (LWP 104574/guile)]
>     (gdb) bt
>     #0  0x000000080091f8a5 in scm_c_vm_run () from
>     /usr/obj/usr/ports/lang/guile/work/guile-2.0.3/libguile/.libs/libguile-2.0.so.25
>     #1  0x0000000800895e17 in scm_async_click () from
>     /usr/obj/usr/ports/lang/guile/work/guile-2.0.3/libguile/.libs/libguile-2.0.so.25
>     #2  0x00000008008f952f in scm_make_smob_type () from
>     /usr/obj/usr/ports/lang/guile/work/guile-2.0.3/libguile/.libs/libguile-2.0.so.25

Can you get a backtrace with symbols?

Also, once you have built a version with symbols, I would like to see
what is triggering this async, and what the error is.  So if you could
run:

  GUILE_AUTO_COMPILE=0 libtool --mode=execute gdb libguile/guile

and see what happens, that would be great.  You will likely be able to
reproduce this error that way.

> --- ./configure.ac.orig 2011-10-07 19:49:48.000000000 -0400
> +++ ./configure.ac      2011-12-06 09:35:02.484201526 -0500
> @@ -657,7 +657,7 @@
>  #
>  AC_CHECK_HEADERS([complex.h fenv.h io.h libc.h limits.h malloc.h
>  memory.h process.h string.h \
>  regex.h rxposix.h rx/rxposix.h sys/dir.h sys/ioctl.h sys/select.h \
> -sys/time.h sys/timeb.h sys/times.h sys/stdtypes.h sys/types.h \
> +sys/time.h sys/times.h sys/stdtypes.h sys/types.h \
>  sys/utime.h time.h unistd.h utime.h pwd.h grp.h sys/utsname.h \
>  direct.h langinfo.h nl_types.h machine/fpu.h poll.h sched.h])

Why did you need to do this?

> +#   pthread_np.h - available on FreeBSD

I applied this and the supporting code, with some small changes.
Thanks.  I also applied the itanium patch.

> -#if defined (sparc) || defined (__sparc__) || defined (__sparc)
> +#if (defined (sparc) || defined (__sparc__) || defined (__sparc)) && \
> +    (!defined(__FreeBSD__))
>  # define SCM_FLUSH_REGISTER_WINDOWS asm("ta 3")
>  #else
>  # define SCM_FLUSH_REGISTER_WINDOWS /* empty */

Why is this?

> ----- files/patch-libguile_gen-scmconfig.c -----
> --- libguile/gen-scmconfig.c    2008-02-23 21:38:39.310330888 -0600
> +++ libguile/gen-scmconfig.c    2008-02-23 21:39:32.909873567 -0600
> @@ -123,6 +123,7 @@
>  
>  #include "gen-scmconfig.h"
>  
> +#define _ANSI_SOURCE
>  #include <stdio.h>
>  #include <string.h>
>  

Why is this?

> ----- files/patch-libguile_numbers.c -----
> --- ./libguile/numbers.c.orig   2011-10-10 16:24:38.000000000 -0400
> +++ ./libguile/numbers.c        2011-12-06 05:26:45.391199972 -0500
> @@ -148,7 +148,7 @@
>  
>  
>  #if defined (GUILE_I)
> -#if defined HAVE_COMPLEX_DOUBLE
> +#if defined HAVE_COMPLEX_DOUBLE && (defined HAVE_CLOG || defined
> HAVE_CLOG10 || defined HAVE_CEXP || defined HAVE_USABLE_CSQRT) &&
> defined (SCM_COMPLEX_VALUE) 
>  
>  /* For an SCM object Z which is a complex number (ie. satisfies
>     SCM_COMPLEXP), return its value as a C level "complex double". */

Why is this?

OK, I think that's all that we need to do in Guile.  If you can get back
to me with some explanations on these patches and a transcript of your
debugging session, that would be great.  Also, if you are able to build
from git, you will find some of your changes incorporated there.

Thanks!

Andy
-- 
http://wingolog.org/