GNU bug report logs -
#21587
Mac: Segfault when unloading shared object linked to libguile
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 21587 in the body.
You can then email your comments to 21587 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-guile <at> gnu.org
:
bug#21587
; Package
guile
.
(Tue, 29 Sep 2015 19:41:04 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Wilhelm Schuster <wilhelm <at> wilhelm.re>
:
New bug report received and forwarded. Copy sent to
bug-guile <at> gnu.org
.
(Tue, 29 Sep 2015 19:41:04 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi,
I have a rather weird issue with guile on OSX Yosemite (10.10.5). The
problem originally stems from weechat [1] which provides guile scripting
through a dynamically loaded "plugin" (shared object). However, I was
able to extract the problem into a smaller test program.
The basic run down: When I try to unload (using dlclose() ) a shared
object that is linked to libguile after calling scm_init_guile() OR
scm_with_guile(), a Segfault is triggered.
Here is my test case:
$ cat test.c
#include <stdio.h>
#include <dlfcn.h>
typedef int (*guile_func)(void);
int main (void) {
void *guile = NULL;
guile_func init_func = NULL;
printf("Loading Guile... ");
guile = dlopen("guile.so", RTLD_GLOBAL | RTLD_NOW);
if (!guile) printf("Error!\n");
else printf("Done!\n");
printf("Trying to load \"init_guile\" ");
init_func = dlsym(guile, "init_guile");
if (!init_func) printf("Error!\n");
else {
printf("Done!\n");
printf("Trying to run \"init_guile\"\n");
init_func();
}
printf("Unloading Guile... ");
fflush(stdout);
dlclose(guile);
printf("Done!\n");
}
$ cat guile.c
#include <libguile.h>
extern void init_guile(void);
void init_guile(void) {
scm_init_guile();
}
When I compile and run the program I get the following output:
$ clang -g -shared -o guile.so guile.c $(pkg-config --cflags --libs
guile-2.0)
$ clang -g test.c -o test
$ ./test
Loading Guile... Done!
Trying to load "init_guile" Done!
Trying to run "init_guile"
Unloading Guile... [1] 41550 segmentation fault ./test
The expected output:
Loading Guile... Done!
Trying to load "init_guile" Done!
Trying to run "init_guile"
Unloading Guile... Done!
Here's an excerpt from the output when enabling dyld (dynamic linker)
debugging information:
$ DYLD_PRINT_APIS=1 ./test
[...]
dlopen(guile.so) ==> 0x7fbcc8e00000
Loading Guile... Done!
dlsym(0x7fbcc8e00000, init_guile)
Trying to load "init_guile" Done!
Trying to run "init_guile"
[...]
Unloading Guile... dlclose(0x7fbcc8e00000)
dlclose(), found unused image 0x7fbcc8e00000 guile.so
dlclose(), found unused image 0x7fbcc8c00170 libguile-2.0.22.dylib
dlclose(), found unused image 0x7fbcc8d04930 libgc.1.dylib
dlclose(), found unused image 0x7fbcc8e00140 libffi.6.dylib
dlclose(), found unused image 0x7fbcc8f00000 libunistring.2.dylib
dlclose(), found unused image 0x7fbcc8f00130 libgmp.10.dylib
dlclose(), found unused image 0x7fbcc8e001d0 libltdl.7.dylib
dlclose(), deleting 0x7fbcc8e00000 guile.so
dlclose(), deleting 0x7fbcc8c00170 libguile-2.0.22.dylib
dlclose(), deleting 0x7fbcc8d04930 libgc.1.dylib
dlclose(), deleting 0x7fbcc8e00140 libffi.6.dylib
[1] 41585 segmentation fault DYLD_PRINT_APIS=1 ./test
I have attached a lldb debugging session with backtrace.
Cheers, Wilhelm Schuster.
[lldb.log (text/plain, attachment)]
Information forwarded
to
bug-guile <at> gnu.org
:
bug#21587
; Package
guile
.
(Tue, 29 Sep 2015 20:49:02 GMT)
Full text and
rfc822 format available.
Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):
I forgot to include the link to the original issue:
[1]: https://github.com/weechat/weechat/issues/527
Information forwarded
to
bug-guile <at> gnu.org
:
bug#21587
; Package
guile
.
(Fri, 24 Jun 2016 12:34:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 21587 <at> debbugs.gnu.org (full text, mbox):
On Tue 29 Sep 2015 20:21, Wilhelm Schuster <wilhelm <at> wilhelm.re> writes:
> The basic run down: When I try to unload (using dlclose() ) a shared
> object that is linked to libguile after calling scm_init_guile() OR
> scm_with_guile(), a Segfault is triggered.
Hummmmmmmmmmmm! Well, so this is quite tricky. Loading Guile loads
Guile which might start threads (some helper threads behind the scenes
for finalization (see section on scm_set_automatic_finalization_enabled
in tha manual), perhaps a thread to listen for signals, and then the
garbage collector that we use (libgc) might start parallel marking
threads (though you can control that parameter too).
Guile doesn't really provide an interface to allow it to shut down
cleanly and I don't know if it can. (I guess it could.) However it
would take quite some amount of work and I don't see us doing it any
time soon. In any case simply trying to dlclose() is never likely to
work, as you aren't synchronizing with Guile itself.
Sorry for the bad news!
Andy
Reply sent
to
Andy Wingo <wingo <at> pobox.com>
:
You have taken responsibility.
(Tue, 28 Feb 2017 14:30:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Wilhelm Schuster <wilhelm <at> wilhelm.re>
:
bug acknowledged by developer.
(Tue, 28 Feb 2017 14:30:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 21587-done <at> debbugs.gnu.org (full text, mbox):
Closing as not-a-bug given discussion below. Please reply if you have
additional comments/etc. Thanks.
Andy
On Fri 24 Jun 2016 14:32, Andy Wingo <wingo <at> pobox.com> writes:
> On Tue 29 Sep 2015 20:21, Wilhelm Schuster <wilhelm <at> wilhelm.re> writes:
>
>> The basic run down: When I try to unload (using dlclose() ) a shared
>> object that is linked to libguile after calling scm_init_guile() OR
>> scm_with_guile(), a Segfault is triggered.
>
> Hummmmmmmmmmmm! Well, so this is quite tricky. Loading Guile loads
> Guile which might start threads (some helper threads behind the scenes
> for finalization (see section on scm_set_automatic_finalization_enabled
> in tha manual), perhaps a thread to listen for signals, and then the
> garbage collector that we use (libgc) might start parallel marking
> threads (though you can control that parameter too).
>
> Guile doesn't really provide an interface to allow it to shut down
> cleanly and I don't know if it can. (I guess it could.) However it
> would take quite some amount of work and I don't see us doing it any
> time soon. In any case simply trying to dlclose() is never likely to
> work, as you aren't synchronizing with Guile itself.
>
> Sorry for the bad news!
>
> Andy
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 29 Mar 2017 11:24:08 GMT)
Full text and
rfc822 format available.
This bug report was last modified 8 years and 87 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.