chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Strange segfaults when linking with pthreads


From: Felix
Subject: Re: [Chicken-users] Strange segfaults when linking with pthreads
Date: Fri, 04 Mar 2011 10:40:49 +0100 (CET)

From: Peter Bex <address@hidden>
Subject: [Chicken-users] Strange segfaults when linking with pthreads
Date: Thu, 3 Mar 2011 21:01:04 +0100

> Hello there,
> 
> I've been observing something really strange for a while and decided to
> finally dig a little deeper.  It appears that when I link to libpthread,
> even if I don't use it, Chicken segfaults.
> 
> To reproduce this, put the following in a file called "foo.scm":
> (module foo *
>   (import chicken scheme)
>   ;; Just a lot of semi-random libraries here:
>   (use srfi-1 srfi-13 srfi-4 data-structures spiffy test)
>   (print "yo"))
> 
> Then when I run
> $ csc -s -lpthread foo.scm
> $ csi
> CHICKEN
> (c)2008-2010 The Chicken Team
> (c)2000-2007 Felix L. Winkelmann
> Version 4.6.0 
> netbsd-unix-gnu-x86-64 [ 64bit manyargs dload ptables ]
> compiled 2011-01-21 on langly (NetBSD)
> 
> #;1> (load "foo")
> ; loading foo.so ...
> ; loading /usr/pkg/lib/chicken/5/chicken.import.so ...
> ; loading /usr/pkg/lib/chicken/5/scheme.import.so ...
> ; loading /usr/pkg/lib/chicken/5/srfi-1.import.so ...
> ; loading /usr/pkg/lib/chicken/5/srfi-13.import.so ...
> ; loading /usr/pkg/lib/chicken/5/srfi-4.import.so ...
> [ETCETERA]
> ; loading /usr/pkg/lib/chicken/5/test.so ...
> yo
> #;2> zsh: segmentation fault  csi
> 
> 
> This appears to happen *only* on 64-bit platforms, I don't see it on
> my 32-bit powerpc mac.  The segfault is a bit elusive because it happens
> only after I load lots of libraries.  When csi is invoked with -e or
> with -q, I generally don't get the segfault as easily, so it probably
> has something to do with the garbage collector; when it generates many
> strings it needs to clean up it fails.  Or something :)
> 
> You might wonder why I'm trying to link against libpthread, but that's
> not really what I'm trying to do.  For example, svn-client links against
> libsvn_client, which itself links to libpthread (through apr, I think).
> 
> If this segfault happens, I simply can't work on svn-client.
> 
> I am currently very uncertain whether this is a bug in Chicken,
> libpthread on NetBSD, the combination of the two, or something else.
> 

This seems to work. It looks like Aleksej pointed into the right
direction, as insane as this may be. 

diff --git a/Makefile.bsd b/Makefile.bsd
index b818eac..5eab203 100644
--- a/Makefile.bsd
+++ b/Makefile.bsd
@@ -57,7 +57,7 @@ LINKER_LINK_SHARED_LIBRARY_OPTIONS = -shared
 LINKER_LINK_SHARED_DLOADABLE_OPTIONS = -shared -Wl,-R"$(RUNTIME_LINKER_PATH)" 
-Wl,-L.
 LINKER_LINK_SHARED_PROGRAM_OPTIONS = -Wl,-R"$(RUNTIME_LINKER_PATH)"
 LIBCHICKEN_SO_LINKER_OPTIONS = 
-Wl,-soname,lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX).so$(SONAME_VERSION)
-LIBRARIES = -lm
+LIBRARIES = -lm -lpthread
 NEEDS_RELINKING = yes
 USES_SONAME = yes
 

cheers,
felix



reply via email to

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