Bug 689877

Summary: running valgrind on a gc-using application causes segfault
Product: [Fedora] Fedora Reporter: Jim Meyering <meyering>
Component: gcAssignee: Rex Dieter <rdieter>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: rawhideCC: rdieter, sochotni
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-01-31 20:41:49 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jim Meyering 2011-03-22 17:41:25 UTC
Description of problem: running valgrind on any gc-using program results in a segmentation fault

Version-Release number of selected component (if applicable):
gc-7.2-0.1.alpha4.fc13.x86_64

How reproducible: always

Steps to Reproduce:
1. printf '%s\n' \
  '#define GC_THREADS' \
  '#include "gc.h"' \
  'int main () { GC_INIT (); return 0; }' > k.c

2. gcc -Wall k.c -lgc && valgrind --log-file=x ./a.out
  
Actual results:
zsh: segmentation fault (core dumped)  valgrind --log-file=x ./a.out

Expected results:
it exits with status == 0

Additional info:
Currently, I work around this by building my own version of libgc, which is compiled with CPPFLAGS=-DUSE_GET_STACKBASE_FOR_MAIN.  If I link an application with *that* libgc.a, then I can use valgrind on it, as usual: no segfault.

I've mentioned F14 above, but this also affects F15 and rawhide.

Comment 1 Jim Meyering 2011-03-22 17:50:07 UTC
FYI, guile developers would find this useful, too:

http://lists.gnu.org/archive/html/guile-devel/2010-11/msg00037.html

Comment 2 Rex Dieter 2011-03-22 17:56:13 UTC
If valgrind is segfaulting, what makes you suspect gc is to blame here?

Comment 3 Jim Meyering 2011-03-22 18:07:48 UTC
The link above gives some justification.
In particular, follow it's link to this thread:

http://comments.gmane.org/gmane.comp.programming.garbage-collection.boehmgc/3788

Comment 4 Rex Dieter 2011-03-22 18:10:16 UTC
Thanks, found it just now. :)

So, do you have any concrete suggestions yet on how to address this?

Consider building gc with -DUSE_GET_STACKBASE_FOR_MAIN or other?

Comment 5 Jim Meyering 2011-03-22 18:30:30 UTC
Yes, that seems like the way to go.  As mentioned in "additional info" above, I've been doing that, and so far it's worked great.

Comment 6 Rex Dieter 2011-04-01 12:18:44 UTC
I'm wondering if I should also try to grab a fresh snapshot too... hmm...

Comment 7 Jim Meyering 2011-04-01 12:23:38 UTC
maybe not too fresh.
I've just tried the latest from cvs with iwhd, and am now encountering a new memory-exhausted error when running valgrind-wrapped iwhd through "make check".  Haven't tracked it down yet.

Comment 8 Rex Dieter 2011-04-01 14:40:42 UTC
Oh fun.  will wait on that then.

Comment 9 Rex Dieter 2011-06-20 17:05:29 UTC
I'm going to go ahead and import the newish 7.2alpha6 into rawhide and build with the aforementioned -DUSE_GET_STACKBASE_FOR_MAIN option.

Comment 10 Jim Meyering 2011-06-20 20:21:23 UTC
Thanks.  I'll be happy to try it out, if I can get past problems with other iwhd 
prerequisites.

Comment 11 Rex Dieter 2012-01-31 14:58:09 UTC
ping, the  -DUSE_GET_STACKBASE_FOR_MAIN enabled build made it into f16, is there still any interest in pursuing this further with a newer snapshot or otherwise?

Comment 12 Jim Meyering 2012-01-31 20:17:39 UTC
Hi Rex,

Thanks for the follow-up.
I've just confirmed that valgrind on gc-using iwhd now works fine in rawhide,
so you're welcome to close this.

I saw a hint on the gc mailing list that it's time for a new alpha release, or even a beta.  Who knows.

Comment 13 Rex Dieter 2012-01-31 20:41:49 UTC
Cool, thanks.