Bug #6391

Segment Fault while execute make_encmake.rb for Ruby 1.9.3 P194 ( MinGW64)

Added by ray linn over 3 years ago. Updated over 2 years ago.

[ruby-core:44795]
Status:Assigned
Priority:Normal
Assignee:Nobuyoshi Nakada
ruby -v:ruby 1.9.3p194 (2012-04-20) [x64-mingw32] Backport:

Description

The Ruby is compiled by MinGW64 (GCC 4.7.0 ), configure script is :

./configure --build=x86_64-w64-mingw32 CFLAGS="-O2 -mieee-fp -I/usr/local/include" LDFLAGS="-L/usr/local/include"

when miniruby executing, error occurs with the following message:

    CC = gcc
    LD = ld
    LDSHARED = gcc -shared
    CFLAGS = -O2 -mieee-fp -I/usr/local/include
    XCFLAGS = -include ruby/config.h -include ruby/missing.h -fvisibility=hi

dden -DRUBY_EXPORT
CPPFLAGS = -I. -I.ext/include/x64-mingw32 -I./include -I.
DLDFLAGS = -Wl,--enable-auto-image-base,--enable-auto-import -Wl,--out-i
mplib=libx64-msvcrt-ruby191.dll.a x64-msvcrt-ruby191.def
SOLIBS = x64-msvcrt-ruby191.res.o -lshell32 -lws2_32 -limagehlp
generating enc.mk
C:/msys/1.0/home/beta/ruby-1.9.3-p194/lib/mkmf.rb:5: [BUG] Segmentation fault
ruby 1.9.3p194 (2012-04-20) [x64-mingw32]

-- Control frame information -----------------------------------------------
c:td p:---- s:td b:td l:td d:td CFUNC :require
c:td p:td s:td b:td l:td d:td TOP C:/msys/1.0/home/beta/ruby-1.9.3-p194/lib/m
kmf.rb:5
c:td p:---- s:td b:td l:td d:td FINISH
c:td p:---- s:td b:td l:td d:td CFUNC :load
c:td p:td s:td b:td l:tx d:tx EVAL ./enc/make_encmake.rb:8
c:td p:---- s:td b:td l:td d:td FINISH
c:td p:td s:td b:td l:tx d:tx TOP

-- Ruby level backtrace information ----------------------------------------
./enc/make_encmake.rb:8:in <main>'
./enc/make_encmake.rb:8:in
load'
C:/msys/1.0/home/beta/ruby-1.9.3-p194/lib/mkmf.rb:5:in <top (required)>'
C:/msys/1.0/home/beta/ruby-1.9.3-p194/lib/mkmf.rb:5:in
require'

-- C level backtrace information -------------------------------------------
C:\windows\SYSTEM32\ntdll.dll(NtWaitForSingleObject+0xa) [0x0000000076EE135A]
C:\windows\system32\KERNELBASE.dll(WaitForSingleObjectEx+0x9c) [0x000007FEFD5710
DC]
[0x000000000051FA34]
[0x000000000042EBD7]
[0x000000000042F076]
[0x00000000004C3BD4]
[0x0000000000533F25]
C:\windows\SYSTEM32\ntdll.dll(_C_specific_handler+0x9c) [0x0000000076EA85A8]
C:\windows\SYSTEM32\ntdll.dll(RtlDecodePointer+0xbd) [0x0000000076EB9D0D]
C:\windows\SYSTEM32\ntdll.dll(RtlUnwindEx+0xbbf) [0x0000000076EA91AF]
C:\windows\SYSTEM32\ntdll.dll(KiUserExceptionDispatcher+0x2e) [0x0000000076EE127
8]
[0x0000000000441810]
[0x0000000000441713]
[0x0000000000507685]
[0x00000000004412FA]
[0x0000000000441713]
[0x0000000000507685]
[0x00000000004412FA]
[0x0000000000441713]
[0x0000000000507685]
[0x00000000004412FA]
[0x000000000050D095]
[0x00000000004412FA]
[0x000000000050BB59]
[0x00000000004CB35E]
[0x000000000050BC3A]
[0x00000000004412FA]
[0x000000000044305D]
[0x0000000000443AFF]
[0x00000000004CE7D1]
[0x00000000004D04AE]
[0x0000000000477792]
[0x0000000000486445]
[0x000000000048E5F5]
[0x0000000000521068]
[0x0000000000525890]
[0x000000000047BFB2]
[0x00000000004C218B]
[0x0000000000432D67]
[0x00000000004C294B]
[0x0000000000434556]
[0x000000000043574C]
[0x000000000051B50A]
[0x0000000000510F7F]
[0x0000000000515EA0]
[0x000000000051DABC]
[0x00000000004345C0]
[0x00000000004346D1]
[0x000000000051B50A]
[0x0000000000510F7F]
[0x0000000000515EA0]
[0x000000000051DB88]
[0x0000000000431AF7]
[0x00000000004325AD]
[0x0000000000433F50]
[0x0000000000538627]
[0x00000000004013C9]
[0x00000000004014E8]
C:\windows\system32\kernel32.dll(BaseThreadInitThunk+0xd) [0x0000000076C2652D]

-- Other runtime information -----------------------------------------------

  • Loaded script: ./enc/make_encmake.rb

  • Loaded features:

    0 enumerator.so
    1 mkmf.rb

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
make: *** [enc.mk] Error 3


Once changed the "-O2" to "-Ofast -fno-finite-math-only" , issue disappeared.

History

#1 Updated by ray linn over 3 years ago

comfirmed with "-O1" has the same issued.

#2 Updated by ray linn over 3 years ago

and Bug #6333 has been patched.

#3 Updated by ray linn over 3 years ago

here is the GDB output:

Program received signal SIGSEGV, Segmentation fault.
gc_mark (objspace=objspace@entry=0x524580, ptr=8589934592, lev=lev@entry=1)
at gc.c:1632
1632 if (obj->as.basic.flags == 0) return; /* free cell /
(gdb) list
1627 {
1628 register RVALUE *obj;
1629
1630 obj = RANY(ptr);
1631 if (rb_special_const_p(ptr)) return; /
special const not marked /
1632 if (obj->as.basic.flags == 0) return; /
free cell /
1633 if (obj->as.basic.flags & FL_MARK) return; /
already marked */
1634 obj->as.basic.flags |= FL_MARK;
1635 objspace->heap.live_num++;
1636
(gdb) print obj
$1 = (RVALUE *) 0x200000000
(gdb) where
#0 gc_mark (objspace=objspace@entry=0x524580, ptr=8589934592,
lev=lev@entry=1) at gc.c:1632
#1 0x000000000043d18b in gc_mark_children (objspace=objspace@entry=0x524580,
ptr=, ptr@entry=48545120, lev=lev@entry=1) at gc.c:1836
#2 0x000000000043d573 in gc_mark (objspace=0x524580, ptr=48545120, lev=0)
at gc.c:1649
#3 0x000000000043ea12 in rb_gc_mark (ptr=8589934592) at gc.c:1655
#4 0x00000000004f5d0c in iseq_mark (ptr=0x2e63370) at iseq.c:102
#5 0x000000000043d200 in gc_mark_children (objspace=objspace@entry=0x524580,
ptr=ptr@entry=48545160, lev=lev@entry=2) at gc.c:1857
#6 0x000000000043d573 in gc_mark (objspace=objspace@entry=0x524580,
ptr=48545160, lev=lev@entry=1) at gc.c:1649
#7 0x000000000043d18b in gc_mark_children (objspace=objspace@entry=0x524580,
ptr=, ptr@entry=48447440, lev=lev@entry=1) at gc.c:1836
#8 0x000000000043d573 in gc_mark (objspace=0x524580, ptr=48447440, lev=0)
at gc.c:1649
#9 0x000000000043ea12 in rb_gc_mark (ptr=8589934592) at gc.c:1655
#10 0x00000000004f5d0c in iseq_mark (ptr=0x2e389f0) at iseq.c:102
#11 0x000000000043d200 in gc_mark_children (objspace=objspace@entry=0x524580,
ptr=ptr@entry=48447480, lev=lev@entry=1) at gc.c:1857
#12 0x000000000043d573 in gc_mark (objspace=0x524580, ptr=48447480, lev=0)
at gc.c:1649
#13 0x000000000043ea12 in rb_gc_mark (ptr=8589934592) at gc.c:1655
#14 0x00000000004f9d67 in rb_thread_mark (ptr=0xdbc930) at vm.c:1728
#15 0x000000000043d200 in gc_mark_children (objspace=objspace@entry=0x524580,
ptr=ptr@entry=42920360, lev=lev@entry=1) at gc.c:1857
#16 0x000000000043d573 in gc_mark (objspace=0x524580, ptr=42920360, lev=0)
at gc.c:1649
#17 0x000000000043ea12 in rb_gc_mark (ptr=8589934592) at gc.c:1655
#18 0x00000000004f9c12 in vm_mark_each_thread_func (key=,
value=, dummy=) at vm.c:1550
#19 0x00000000004bc784 in st_foreach (table=0x2d8e570,
func=func@entry=0x4f9c09 , arg=arg@entry=0)
at st.c:747
#20 0x00000000004f9f2c in rb_vm_mark (ptr=0xdbc6a0) at vm.c:1573
#21 0x000000000043d200 in gc_mark_children (objspace=objspace@entry=0x524580,
ptr=ptr@entry=42920400, lev=lev@entry=1) at gc.c:1857
#22 0x000000000043d573 in gc_mark (objspace=0x524580, ptr=42920400, lev=0)
at gc.c:1649
#23 0x000000000043ea12 in rb_gc_mark (ptr=8589934592) at gc.c:1655
#24 0x000000000043ea5e in gc_marks (objspace=objspace@entry=0x524580)
at gc.c:2446
#25 0x000000000043f422 in gc_lazy_sweep (objspace=0x524580) at gc.c:2194
#26 rb_newobj () at gc.c:1183
#27 0x00000000004c0479 in str_alloc (klass=42985080) at string.c:373
#28 str_new (klass=42985080, ptr=0x2ddf6e0 "INSTALL_SCRIPT", len=14)
at string.c:392
#29 0x00000000004c2079 in rb_str_new (ptr=,
len=) at string.c:412
#30 0x00000000004c20e5 in rb_enc_str_new (ptr=,
len=, enc=enc@entry=0xdbf520) at string.c:426
#31 0x000000000047153a in parser_str_new (p=,
n=, enc=0xdbf520, func=func@entry=2, enc0=0xdbf520)
at parse.y:5403
#32 0x0000000000478212 in parser_parse_string (quote=,
parser=0x2ef2e90) at parse.y:6043
#33 parser_yylex (parser=0x2ef2e90) at parse.y:6655
#34 yylex (p=0x2ef2e90, lval=0x22e7c0) at parse.y:7937
#35 ruby_yyparse (parser=parser@entry=0x2ef2e90) at parse.c:4952
#36 0x0000000000484884 in yycompile0 (arg=arg@entry=49229456,
tracing=tracing@entry=0) at parse.y:5215
#37 0x000000000050ec08 in thread_suppress_tracing (th=0xdbc930,
ev=ev@entry=1, func=func@entry=0x484476 ,
arg=arg@entry=49229456, always=always@entry=1) at thread.c:4565
#38 0x0000000000511967 in ruby_suppress_tracing (
func=func@entry=0x484476 , arg=arg@entry=49229456,
always=always@entry=1) at thread.c:4541
#39 0x0000000000471491 in yycompile (parser=parser@entry=0x2ef2e90,
f=f@entry=0x2eea160 "C:/msys/1.0/home/beta/ruby-1.9.3-p194/rbconfig.rb",
line=line@entry=1) at parse.y:5241
#40 0x00000000004745ca in rb_parser_compile_file (
vparser=vparser@entry=49131120,
f=f@entry=0x2eea160 "C:/msys/1.0/home/beta/ruby-1.9.3-p194/rbconfig.rb",
file=file@entry=49131080, start=start@entry=1) at parse.y:5373
#41 0x00000000004b3d8b in load_file_internal (arg=arg@entry=2288944)
at ruby.c:1630
#42 0x000000000042f68a in rb_ensure (
b_proc=b_proc@entry=0x4b38ef ,
data1=data1@entry=2288944, e_proc=e_proc@entry=0x4b244f ,
data2=1) at eval.c:744
#43 0x00000000004b244a in load_file (parser=,
fname=fname@entry=0x2eea160 "C:/msys/1.0/home/beta/ruby-1.9.3-p194/rbconfig.
rb", script=script@entry=0, opt=opt@entry=0x22ed80) at ruby.c:1667
#44 0x00000000004b4053 in rb_load_file (
fname=0x2eea160 "C:/msys/1.0/home/beta/ruby-1.9.3-p194/rbconfig.rb")
at ruby.c:1675
#45 0x0000000000430d96 in rb_load_internal (fname=49131280, wrap=wrap@entry=0)
at load.c:306
#46 0x0000000000432021 in rb_require_safe (fname=49131520,
fname@entry=49131560, safe=0) at load.c:619
#47 0x00000000004321cc in rb_f_require (obj=, fname=49131560)
at load.c:465
#48 0x00000000004fa08d in call_cfunc (func=0x4321b5 ,
recv=recv@entry=42988160, len=, argc=argc@entry=1,
argv=0x26f0138) at vm_insnhelper.c:323
#49 0x0000000000506c51 in vm_call_cfunc (me=0x2d747b0,
blockptr=, recv=, num=1, reg_cfp=0x27efe30,
th=0xdbc930) at vm_insnhelper.c:404
#50 vm_call_method (th=th@entry=0xdbc930, cfp=cfp@entry=0x27efe30,
num=num@entry=1, blockptr=, flag=flag@entry=8,
id=id@entry=8832, me=0x2d747b0, recv=recv@entry=42988160)
at vm_insnhelper.c:534
#51 0x00000000004ff240 in vm_exec_core (th=th@entry=0xdbc930,
initial=initial@entry=0) at insns.def:1015
#52 0x0000000000502abd in vm_exec (th=0xdbc930) at vm.c:1220
#53 0x0000000000508be1 in rb_iseq_eval (iseqval=48447480) at vm.c:1447
#54 0x0000000000430e03 in rb_load_internal (fname=42889480,
wrap=) at load.c:310
#55 0x0000000000430f67 in rb_f_load (argc=,
argv=) at load.c:383
#56 0x00000000004fa074 in call_cfunc (func=0x430ee5 ,
recv=recv@entry=42988160, len=, argc=argc@entry=1,
argv=0x26f00a8) at vm_insnhelper.c:317
#57 0x0000000000506c51 in vm_call_cfunc (me=0x2d744d0,
blockptr=, recv=, num=1, reg_cfp=0x27eff38,
th=0xdbc930) at vm_insnhelper.c:404
#58 vm_call_method (th=th@entry=0xdbc930, cfp=cfp@entry=0x27eff38,
num=num@entry=1, blockptr=, flag=flag@entry=8,
id=id@entry=6040, me=0x2d744d0, recv=recv@entry=42988160)
at vm_insnhelper.c:534
#59 0x00000000004ff240 in vm_exec_core (th=th@entry=0xdbc930,
initial=initial@entry=0) at insns.def:1015
#60 0x0000000000502abd in vm_exec (th=th@entry=0xdbc930) at vm.c:1220
#61 0x0000000000508c9b in rb_iseq_eval_main (iseqval=iseqval@entry=42892120)
at vm.c:1461
#62 0x000000000042eb66 in ruby_exec_internal (n=0x28e7b58) at eval.c:204
#63 0x000000000042ef49 in ruby_exec_node (n=n@entry=0x28e7b58) at eval.c:251
#64 0x0000000000430781 in ruby_run_node (n=0x28e7b58) at eval.c:244
#65 0x0000000000401547 in main (argc=2, argv=0xdb5ca0) at main.c:38
(gdb)

#4 Updated by ray linn over 3 years ago

(gdb) print obj
$1 = (RVALUE ) 0x200000000
(gdb) print ptr
$2 = 8589934592
(gdb) print RANY(ptr)
No symbol "RANY" in current context.
(gdb) print (RVALUE
) ptr
$4 = (RVALUE *) 0x200000000

#5 Updated by Luis Lavena over 3 years ago

  • Status changed from Open to Feedback
  • Category set to build
  • Assignee set to Luis Lavena

Hello,

Are you trying to build trunk? GCC 4.7.0 changes hasn't been backported yet to ruby_1_9_3 branch

There is no mention of revision against you tested it.

Please confirm.

#6 Updated by ray linn over 3 years ago

Here is the update:

  1. I renamed my folder local to local.old, so that any 3rd partt lib will not be linked.
  2. Rolled back GCC from 4.7.0 to 4.6.2.
  3. just use the following command to configure : ./configure --build=x86_64-w64-mingw32 CFLAGS="-Ox" x will be replaced as 2 or 3.

after took all these actions, I got the following result:

  1. Ruby 1.9.3P0 x=3 passed; x=2 failed
  2. Ruby 1.9.3P194 x=3 passed; x=2 failed
  3. Snapshot {ruby 2.0.0) x=3 passed; x=2 failed.

#7 Updated by ray linn over 3 years ago

Sorry for duplicate items since bugs system has some problem last night.

#8 Updated by ray linn over 3 years ago

Here is the update:

  1. I renamed my folder local to local.old, so that any 3rd partt lib will not be linked.
  2. Rolled back GCC from 4.7.0 to 4.6.2.
  3. just use the following command to configure : ./configure --build=x86_64-w64-mingw32 CFLAGS="-Ox" x will be replaced as 2 or 3.

after took all these actions, I got the following result:

  1. Ruby 1.9.3P0 x=3 passed; x=2 failed
  2. Ruby 1.9.3P194 x=3 passed; x=2 failed
  3. Snapshot {ruby 2.0.0) x=3 passed; x=2 failed.

#9 Updated by Heesob Park over 3 years ago

I can reproduce this issue for trunk with MinGW64 4.7.0 on Windows 7.

I found it is related with inline function optimization.

Here is a workaround:
./configure --build=x86_64-w64-mingw32 CFLAGS="-O2 -finline-functions"

#10 Updated by ray linn over 3 years ago

that means even choose -O0, still could see this issue. could it be duplicated on Linux?

#11 Updated by Luis Lavena over 3 years ago

  • Assignee changed from Luis Lavena to Nobuyoshi Nakada

#12 Updated by Eric Hodel over 2 years ago

  • Status changed from Feedback to Assigned

There is feedback on this issue that has not been addressed. Luis, Nobu can you comment?

Also available in: Atom PDF