List Info

Thread: Segfault on x86_64 when built with -O0 in CFLAGS




Segfault on x86_64 when built with -O0 in CFLAGS
user name
2006-05-16 16:46:57
Bugs item #4491, was opened at 2006-05-16 12:46
You can respond by visiting: 
http://rubyforge.org/tracke
r/?func=detail&atid=1698&aid=4491&group_id=426

Category: Core
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Jeff Abbott (fdiv_bug)
Assigned to: Nobody (None)
Summary: Segfault on x86_64 when built with -O0 in CFLAGS

Initial Comment:
Due to a bug in the spec file for the package I was building
(which I will be filing separately with the package author),
Ruby 1.8.4 was getting built with -O0 in its CFLAGS.  This
worked fine on i386, but on x86_64 it caused a segfault
which I was easily able to reproduce with the following in
either ruby or irb:

  Dir['/bin/bash/foo']

The problem appears to stem from '/bin/bash' being a file,
not a directory -- Rails was doing a similar Dir.glob,
referencing a subdirectory of a plain file object, which was
where I was seeing the segfault in production.  On i386 it
returns an empty array.  Building with -O2 in the CFLAGS
resolves the problem.  I understand if this might be a case
of "so don't build with -O0" but I believe
behavior should be identical on both platforms, or at the
very least not exhibit a segfault on x86_64.

Thanks,
Jeff

------------------------------------------------------------
----------

You can respond by visiting: 
http://rubyforge.org/tracke
r/?func=detail&atid=1698&aid=4491&group_id=426

Segfault on x86_64 when built with -O0 in CFLAGS
user name
2006-05-17 08:27:48
>>>>> "n" == noreply 
<noreplyrubyforge.org> writes:

n> The problem appears to stem from '/bin/bash' being a
file, not a
n> directory -- Rails was doing a similar Dir.glob,
referencing a
n> subdirectory of a plain file object, which was where I
was seeing the
n> segfault in production.  On i386 it returns an empty
array.  Building
n> with -O2 in the CFLAGS resolves the problem.  I
understand if this
n> might be a case of "so don't build with
-O0" but I believe behavior
n> should be identical on both platforms, or at the very
least not exhibit
n> a segfault on x86_64. 

 Well not really a problem with -O0 (i.e. it can possible to
have a version
 which crash with -O2), but rather an alignment problem.

 This is the call rb_protect(rb_sys_warning()) which give
the crash because
 rb_sys_warning() is a variadic function.




Guy Decoux

Segfault on x86_64 when built with -O0 in CFLAGS
user name
2006-05-17 08:57:47
Hi,

In message "Re: [ ruby-Bugs-4491 ] Segfault on x86_64
when built with -O0 in CFLAGS"
    on Wed, 17 May 2006 17:27:48 +0900, ts <decouxmoulon.inra.fr> writes:

| This is the call rb_protect(rb_sys_warning()) which give
the crash because
| rb_sys_warning() is a variadic function.

Thank you, Guy.  Does this patch could solve the problem?

							matz.

Segfault on x86_64 when built with -O0 in CFLAGS
user name
2006-05-17 09:03:48
Hi,

In message "Re: [ ruby-Bugs-4491 ] Segfault on x86_64
when built with -O0 in CFLAGS"
    on Wed, 17 May 2006 17:57:47 +0900, Yukihiro Matsumoto
<matzruby-lang.org> writes:

|Thank you, Guy.  Does this patch could solve the problem?

Oops, here's the patch.

 -801,5
+801,11  dir_s_rmdir(obj, dir)
 
+static void
+sys_warning_1(const char* mesg)
+{
+    rb_sys_warning("%s", mesg);
+}
+
 #define GLOB_VERBOSE	(1 << (sizeof(int) * CHAR_BIT -
1))
 #define sys_warning(val) \
-    ((flags & GLOB_VERBOSE) &&
rb_protect((VALUE (*)_((VALUE)))rb_sys_warning,
(VALUE)(val), 0))
+    ((flags & GLOB_VERBOSE) &&
rb_protect((VALUE (*)_((VALUE)))sys_warning_1, (VALUE)(val),
0))
 

Segfault on x86_64 when built with -O0 in CFLAGS
user name
2006-05-17 09:08:49
>>>>> "Y" == Yukihiro Matsumoto
<matzruby-lang.org> writes:

Y> |Thank you, Guy.  Does this patch could solve the
problem?

 yes, I think.


Guy Decoux

 



[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )