public
anonymous / fix_segv.patch
Created

Build x86 ruby with -mfpmath=sse -msse2 on Windows 7 MinGW causes 2 Segmentation faults

  • Download Gist
fix_segv.patch
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
diff --git a/re.c b/re.c
index fe7e390..5c96276 100644
--- a/re.c
+++ b/re.c
@@ -154,7 +154,8 @@ rb_memsearch_qs(const unsigned char *xs, long m, const unsigned char *ys, long n
{
const unsigned char *x = xs, *xe = xs + m;
const unsigned char *y = ys;
- VALUE i, qstable[256];
+ volatile VALUE i;
+ VALUE qstable[256];
/* Preprocessing */
for (i = 0; i < 256; ++i)
diff --git a/regcomp.c b/regcomp.c
index 1373ff2..8c0e2b5 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -5306,7 +5306,7 @@ set_optimize_exact_info(regex_t* reg, OptExactInfo* e)
static void
set_optimize_map_info(regex_t* reg, OptMapInfo* m)
{
- int i;
+ volatile int i;
for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++)
reg->map[i] = m->map[i];
output.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
sh-3.1$ ./ruby --disable-gems -I. -rRbConfig -e 'p RbConfig::CONFIG["optflags"]'
"-O3 -mfpmath=sse -msse2 -fno-omit-frame-pointer -fno-fast-math"
 
sh-3.1$ gcc -v 2>&1 | tail -n1
gcc version 4.7.2 (rubenvb-4.7.2-release)
 
sh-3.1$ ./ruby -v
ruby 2.1.0dev (2013-04-30 trunk 40528) [i386-mingw32]
 
sh-3.1$ gdb -args ./ruby -I. -I../../../ruby/lib -I.ext/i386-mingw32 -I.ext/common ../../../ruby/test/csv/test_interface.rb
GNU gdb (rubenvb-4.7.2-release) 7.5.50.20120920-cvs
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-w64-mingw32".
For bug reporting instructions, please see:
<mingw-w64-public@lists.sourceforge.net>...
Reading symbols from c:\Users\h.shirosaki\work\rubyinstaller\sandbox\ruby19_build\ruby.exe...done.
(gdb) r
Starting program: c:\Users\h.shirosaki\work\rubyinstaller\sandbox\ruby19_build\ruby.exe -I. -I../../../ruby/lib -I.ext/i
386-mingw32 -I.ext/common ../../../ruby/test/csv/test_interface.rb
[New Thread 4384.0x23b4]
[New Thread 4384.0x2234]
[New Thread 4384.0x2634]
[New Thread 4384.0x2350]
Run options:
 
# Running tests:
 
[ 2/42] TestCSV::Interface#test_enumerators_are_supported
Program received signal SIGSEGV, Segmentation fault.
set_optimize_info_from_tree (scan_env=0x217e80c, reg=0x2d3cb60, node=<optimized out>) at ../../../ruby/regcomp.c:5312
5312 reg->map[i] = m->map[i];
(gdb)
 
 
sh-3.1$ gdb -args ./ruby -ropenssl -I. -I../../../ruby/lib -I.ext/i386-mingw32 -I.ext/common ../../../ruby/test/rubygems/test_gem_commands_cert_command.rb
GNU gdb (rubenvb-4.7.2-release) 7.5.50.20120920-cvs
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-w64-mingw32".
For bug reporting instructions, please see:
<mingw-w64-public@lists.sourceforge.net>...
Reading symbols from c:\Users\h.shirosaki\work\rubyinstaller\sandbox\ruby19_build\ruby.exe...done.
(gdb) r
Starting program: c:\Users\h.shirosaki\work\rubyinstaller\sandbox\ruby19_build\ruby.exe -ropenssl -I. -I../../../ruby/li
b -I.ext/i386-mingw32 -I.ext/common ../../../ruby/test/rubygems/test_gem_commands_cert_command.rb
[New Thread 864.0x2774]
[New Thread 864.0x2700]
[New Thread 864.0x1ec0]
[New Thread 864.0x1fd8]
DL is deprecated, please use Fiddle
Run options: --seed 45168
 
# Running tests:
 
[New Thread 864.0x2188]
[New Thread 864.0x191c]
.........
Program received signal SIGSEGV, Segmentation fault.
rb_memsearch_qs (xs=0x31a5988 "alternate", xs@entry=0x15 <Address 0x15 out of bounds>, m=m@entry=9,
ys=ys@entry=0x3cc30a0 "/cn=nobody/dc=example", n=21) at ../../../ruby/re.c:161
161 qstable[i] = m + 1;
(gdb)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.