Bug #12118
closedruby2.3: Segfaults on m68k due to improper stack allocation
Added by glaubitz (John Paul Adrian Glaubitz) over 8 years ago. Updated over 8 years ago.
Description
Hello!
On Motorola 680x0, ruby2.2 and ruby2.3 segfault when running the Ruby interpretor:
./miniruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems -r./m68k-linux-gnu-fake ./tool/rbinstall.rb --make="/usr/bin/make" --dest-dir="/<>/debian/tmp" --extout=".ext" --mflags="-w" --make-flags="w -- DESTDIR=/<>/debian/tmp" --data-mode=0644 --prog-mode=0755 --installed-list .installed.list --mantype="doc"
installing binary commands: /usr/bin
/<>/lib/fileutils.rb:250: [BUG] Segmentation fault at 0x5f583332
ruby 2.3.0p0 (2015-12-25) [m68k-linux-gnu]
This happens while building ruby2.3 on Debian, for example [1].
Andreas Schwab has already investigated into this issue and he came up with the following patch for ruby2.2 [2]:
Index: ruby-2.2.3/thread_pthread.c
===================================================================
--- ruby-2.2.3.orig/thread_pthread.c
+++ ruby-2.2.3/thread_pthread.c
@@ -678,15 +678,14 @@ reserve_stack(volatile char *limit, size
limit += size;
if (limit > end) {
size = limit - end;
- limit = alloca(size);
+ limit = alloca(stack_check_margin+size);
limit[stack_check_margin+size-1] = 0;
}
}
else {
limit -= size;
if (buf > limit) {
- limit = alloca(buf - limit);
- limit -= stack_check_margin;
+ limit = alloca(buf - limit + stack_check_margin);
limit[0] = 0;
}
}
The same patch works fine on ruby2.3, I although I had to modify it so it still applies the same way in ruby2.3.
The bug can be reproduced in a qemu-m68k chroot environment which can be set up quite easily [3].
It would be very important for Debian's Motorola 680x0 port to get this issue fixed.
Thanks,
Adrian
[1] https://buildd.debian.org/status/fetch.php?pkg=ruby2.3&arch=m68k&ver=2.3.0-2&stamp=1455092994
[2] https://lists.debian.org/debian-68k/2015/11/msg00057.html
[3] https://wiki.debian.org/M68k/sbuildQEMU
Updated by glaubitz (John Paul Adrian Glaubitz) over 8 years ago
Update: It seems the suggested patch by Andreas Schwab does not help on ruby2.3 anymore. So, for ruby2.3, something different needs to be done.
Updated by Anonymous over 8 years ago
- File 111.jpg added
- Subject changed from ruby2.3: Segfaults on m68k due to improper stack allocation to http://www.proessaywriting.com/
Updated by hsbt (Hiroshi SHIBATA) over 8 years ago
- Subject changed from http://www.proessaywriting.com/ to ruby2.3: Segfaults on m68k due to improper stack allocation
Updated by glaubitz (John Paul Adrian Glaubitz) over 8 years ago
Hi!
Since my first post was a bit confusing, here is for clarification:
The above patch helped with ruby2.2, but it does not help with ruby2.3, so this seems to be a different problem.
Trying to debug the issue now.
Adrian
Updated by glaubitz (John Paul Adrian Glaubitz) over 8 years ago
Here's the complete backtrace:
(sid-m68k-sbuild)root@z6:/build/ruby2.3-dCWwvL/ruby2.3-2.3.0# ./miniruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems -r./m68k-linux-gnu-fake ./tool/rbinstall.rb --make="/usr/bin/make" --dest-dir="/<<PKGBUILDDIR>>/debian/tmp" --extout=".ext" --mflags="-w" --make-flags="w -- DESTDIR=/<<PKGBUILDDIR>>/debian/tmp" --data-mode=0644 --prog-mode=0755 --installed-list .installed.list --mantype="doc"
qemu: Unsupported syscall: 352
qemu: Unsupported syscall: 352
installing binary commands: /usr/bin
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/fileutils.rb:250: [BUG] Segmentation fault at 0x38000000
ruby 2.3.0p0 (2015-12-25) [m68k-linux-gnu]
-- Control frame information -----------------------------------------------
c:0013 p:---- s:0076 e:000075 CFUNC :initialize
c:0012 p:---- s:0074 e:000073 CFUNC :mkdir
c:0011 p:0034 s:0069 e:000068 METHOD /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/fileutils.rb:250
c:0010 p:0019 s:0064 e:000063 BLOCK /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/fileutils.rb:214 [FINISH]
c:0009 p:---- s:0060 e:000059 CFUNC :each
c:0008 p:0122 s:0057 e:000056 METHOD /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/fileutils.rb:211
c:0007 p:0046 s:0052 e:000051 METHOD ./tool/rbinstall.rb:191
c:0006 p:0158 s:0048 e:000047 METHOD ./tool/rbinstall.rb:304
c:0005 p:0012 s:0041 e:000040 BLOCK ./tool/rbinstall.rb:342 [FINISH]
c:0004 p:0025 s:0039 e:000038 BLOCK ./tool/rbinstall.rb:801 [FINISH]
c:0003 p:---- s:0035 e:000034 CFUNC :each
c:0002 p:1387 s:0032 E:ffffe4f8 EVAL ./tool/rbinstall.rb:798 [FINISH]
c:0001 p:0000 s:0002 E:ffffdee8 (none) [FINISH]
-- Ruby level backtrace information ----------------------------------------
./tool/rbinstall.rb:798:in `<main>'
./tool/rbinstall.rb:798:in `each'
./tool/rbinstall.rb:801:in `block in <main>'
./tool/rbinstall.rb:342:in `block in <main>'
./tool/rbinstall.rb:304:in `prepare'
./tool/rbinstall.rb:191:in `makedirs'
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/fileutils.rb:211:in `mkdir_p'
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/fileutils.rb:211:in `each'
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/fileutils.rb:214:in `block in mkdir_p'
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/fileutils.rb:250:in `fu_mkdir'
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/fileutils.rb:250:in `mkdir'
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/fileutils.rb:250:in `initialize'
-- C level backtrace information -------------------------------------------
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(rb_print_backtrace+0x24) [0xf67380b4] vm_dump.c:987
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(rb_vm_bugreport+0x7e) [0xf673814c] /usr/include/m68k-linux-gnu/bits/stdio2.h:97
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(rb_bug_context+0x58) [0xf66094a6] error.c:435
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(sigsegv+0x46) [0xf66c4334] signal.c:890
[0x800414d8]
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(iv_index_tbl_make+0x10) [0xf66fed4a] variable.c:1308
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(rb_ivar_set+0x86) [0xf6702428] variable.c:1340
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(syserr_initialize+0x152) [0xf660abb6] error.c:1525
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(vm_call0_body.constprop.112+0x1e6) [0xf673091e] vm_eval.c:119
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(rb_call0+0xd4) [0xf67313ee] vm_eval.c:609
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(rb_funcallv+0x3a) [0xf6731c14] /usr/include/m68k-linux-gnu/bits/string3.h:53
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(rb_obj_call_init+0x48) [0xf661008a] eval.c:1310
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(rb_class_new_instance+0x22) [0xf6660b3c] object.c:1856
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(rb_syserr_fail_path_in+0x7a) [0xf660b1e4] error.c:2208
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(rb_sys_fail_path_in+0x1e) [0xf660b23a] error.c:2191
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(dir_s_mkdir+0xb0) [0xf65f8028] dir.c:1132
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(vm_call_cfunc+0xf8) [0xf6726f18] vm_args.c:761
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(vm_call_method_each_type+0xd6) [0xf6733926] vm_insnhelper.c:2048
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(vm_call_general+0xba) [0xf673493e] vm.c:952
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(vm_exec_core+0xf8a) [0xf672b168] vm_insnhelper.c:210
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(vm_exec+0x68) [0xf672ec74] vm_insnhelper.c:1280
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(rb_yield+0x2b8) [0xf67350ce] vm_method.c:1905
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(rb_ary_each+0x40) [0xf65ca4a6] array.c:1815
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(vm_call_cfunc+0xf8) [0xf6726f18] vm_args.c:761
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(vm_call_method_each_type+0xd6) [0xf6733926] vm_insnhelper.c:2048
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(vm_call_general+0xba) [0xf673493e] vm.c:952
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(vm_exec_core+0xeee) [0xf672b0cc] insns.def:1032
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(vm_exec+0x68) [0xf672ec74] vm_insnhelper.c:1280
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(invoke_block_from_c_0+0x1d2) [0xf672f682] vm_args.c:762
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(vm_invoke_proc+0x84) [0xf672f71e] vm_eval.c:1584
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(rb_vm_invoke_proc+0x2a) [0xf672f7aa] vm_eval.c:1596
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(vm_call_opt_call+0x8c) [0xf672f864] vm.c:983
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(vm_call_method_each_type+0x390) [0xf6733be0] vm_insnhelper.c:2161
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(vm_call_general+0xba) [0xf673493e] vm.c:952
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(vm_exec_core+0xf8a) [0xf672b168] vm_insnhelper.c:210
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(vm_exec+0x68) [0xf672ec74] vm_insnhelper.c:1280
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(rb_yield+0x2b8) [0xf67350ce] vm_method.c:1905
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(rb_ary_each+0x60) [0xf65ca4c6] array.c:1815
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(vm_call_cfunc+0xf8) [0xf6726f18] vm_args.c:761
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(vm_call_method_each_type+0xd6) [0xf6733926] vm_insnhelper.c:2048
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(vm_call_general+0xba) [0xf673493e] vm.c:952
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(vm_exec_core+0xeee) [0xf672b0cc] insns.def:1032
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(vm_exec+0x68) [0xf672ec74] vm_insnhelper.c:1280
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(ruby_exec_internal+0x8c) [0xf660c3d2] eval.c:244
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(ruby_exec_node+0x18) [0xf660dc8a] eval.c:309
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/libruby-2.3.so.2.3.0(ruby_run_node+0x24) [0xf660fb8c] eval.c:977
/build/ruby2.3-dCWwvL/ruby2.3-2.3.0/ruby2.3(main+0x52) [0x80000736] main.c:36
-- Other runtime information -----------------------------------------------
* Loaded script: ./tool/rbinstall.rb
* Loaded features:
0 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/rbconfig.rb
1 enumerator.so
2 thread.rb
3 rational.so
4 complex.so
5 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/.ext/m68k-linux-gnu/enc/encdb.so
6 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/.ext/m68k-linux-gnu/enc/trans/transdb.so
7 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/unicode_normalize.rb
8 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/m68k-linux-gnu-fake.rb
9 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/.ext/m68k-linux-gnu/etc.so
10 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/fileutils.rb
11 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/shellwords.rb
12 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/optparse.rb
13 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/optparse/shellwords.rb
14 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/ostruct.rb
15 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/compatibility.rb
16 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/defaults.rb
17 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/deprecate.rb
18 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/errors.rb
19 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/version.rb
20 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/requirement.rb
21 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/platform.rb
22 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/basic_specification.rb
23 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/stub_specification.rb
24 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/util/list.rb
25 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/.ext/m68k-linux-gnu/stringio.so
26 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/specification.rb
27 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/exceptions.rb
28 /usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb
29 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/core_ext/kernel_gem.rb
30 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/monitor.rb
31 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/core_ext/kernel_require.rb
32 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems.rb
33 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/.ext/m68k-linux-gnu/zlib.so
34 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/.ext/m68k-linux-gnu/io/console.so
35 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/user_interaction.rb
36 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/command.rb
37 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/.ext/m68k-linux-gnu/digest.so
38 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/.ext/common/digest.rb
39 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/.ext/m68k-linux-gnu/openssl.so
40 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/.ext/common/openssl/bn.rb
41 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/.ext/common/openssl/pkey.rb
42 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/.ext/common/openssl/cipher.rb
43 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/.ext/common/openssl/config.rb
44 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/.ext/common/openssl/digest.rb
45 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/.ext/common/openssl/x509.rb
46 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/.ext/common/openssl/buffering.rb
47 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/.ext/m68k-linux-gnu/io/nonblock.so
48 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/.ext/common/openssl/ssl.rb
49 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/.ext/common/openssl.rb
50 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/security/policy.rb
51 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/security/policies.rb
52 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/security/trust_dir.rb
53 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/security/signer.rb
54 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/security.rb
55 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/package/digest_io.rb
56 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/package/source.rb
57 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/package/file_source.rb
58 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/package/io_source.rb
59 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/package/old.rb
60 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/package/tar_header.rb
61 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/package/tar_reader/entry.rb
62 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/package/tar_reader.rb
63 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/package/tar_writer.rb
64 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/package.rb
65 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/ext/build_error.rb
66 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/ext/builder.rb
67 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/ext/configure_builder.rb
68 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/delegate.rb
69 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/tmpdir.rb
70 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/tempfile.rb
71 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/ext/ext_conf_builder.rb
72 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/ext/rake_builder.rb
73 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/ext/cmake_builder.rb
74 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/ext.rb
75 /build/ruby2.3-dCWwvL/ruby2.3-2.3.0/lib/rubygems/installer.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
qemu: uncaught target signal 6 (Aborted) - core dumped
Aborted
(sid-m68k-sbuild)root@z6:/build/ruby2.3-dCWwvL/ruby2.3-2.3.0#
Updated by naruse (Yui NARUSE) over 8 years ago
- Description updated (diff)
Updated by naruse (Yui NARUSE) over 8 years ago
- Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: REQUIRED, 2.2: REQUIRED, 2.3: REQUIRED
As far as I understand, the fix should be following:
diff --git a/thread_pthread.c b/thread_pthread.c
index ef43b36..1fdf3f5 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -693,17 +693,31 @@ reserve_stack(volatile char *limit, size_t size)
const volatile char *end = buf + sizeof(buf);
limit += size;
if (limit > end) {
- size = limit - end;
- limit = alloca(size);
- limit[stack_check_margin+size-1] = 0;
+ /* |<-bottom (=limit(a)) top->|
+ * | .. |<-buf 256B |<-end | stack check |
+ * | 256B | =size= | margin (4KB)|
+ * | =size= limit(b)->| 256B | |
+ * | | alloca(sz) | | |
+ * | .. |<-buf |<-limit(c) [sz-1]->0> | |
+ */
+ size_t sz = limit - end;
+ limit = alloca(sz);
+ limit[sz-1] = 0;
}
}
else {
limit -= size;
if (buf > limit) {
- limit = alloca(buf - limit);
- limit[0] = 0; /* ensure alloca is called */
- limit -= stack_check_margin;
+ /* |<-top (=limit(a)) bottom->|
+ * | .. | 256B buf->| | stack check |
+ * | 256B | =size= | margin (4KB)|
+ * | =size= limit(b)->| 256B | |
+ * | | alloca(sz) | | |
+ * | .. | buf->| limit(c)-><0> | |
+ */
+ size_t sz = buf - limit;
+ limit = alloca(sz);
+ limit[0] = 0;
}
}
}
Updated by naruse (Yui NARUSE) over 8 years ago
- Status changed from Open to Closed
Applied in changeset r54256.
- thread_pthread.c (reserve_stack): fix reserving position where
the stack growing bottom to top. [Bug #12118]
Updated by glaubitz (John Paul Adrian Glaubitz) over 8 years ago
Hi!
Thank you very much for your input.
Andreas Schwab just provided a second patch which actually fixed the problem for me. After applying the patch, ruby-2.3 builds fine on m68k.
Here's the patch:
Index: ruby-2.3.0/localeinit.c
===================================================================
--- ruby-2.3.0.orig/localeinit.c
+++ ruby-2.3.0/localeinit.c
@@ -89,7 +89,7 @@ enc_find_index(const char *name)
}
int
-rb_locale_charmap_index(VALUE klass)
+rb_locale_charmap_index(void)
{
return (int)locale_charmap(enc_find_index);
}
Index: ruby-2.3.0/thread_pthread.c
===================================================================
--- ruby-2.3.0.orig/thread_pthread.c
+++ ruby-2.3.0/thread_pthread.c
@@ -691,16 +691,15 @@ reserve_stack(volatile char *limit, size
limit += size;
if (limit > end) {
size = limit - end;
- limit = alloca(size);
+ limit = alloca(stack_check_margin+size);
limit[stack_check_margin+size-1] = 0;
}
}
else {
limit -= size;
if (buf > limit) {
- limit = alloca(buf - limit);
+ limit = alloca(buf - limit + stack_check_margin);
limit[0] = 0; /* ensure alloca is called */
- limit -= stack_check_margin;
}
}
}
As you can see, the patch corresponds almost the original patch, but includes an update to the function prototype for "rb_locale_charmap_index" in localeinit.c.
Adrian
Updated by naruse (Yui NARUSE) over 8 years ago
Thanks, I also merged the patch for rb_locale_charmap_index.
Updated by naruse (Yui NARUSE) over 8 years ago
- Related to Bug #12218: Undefined behaviour added
Updated by glaubitz (John Paul Adrian Glaubitz) over 8 years ago
I just verified that ruby2.3 works fine on m68k with both the changes from ruby-core:74537 and in rb_locale_charmap_index applied!
Thanks for fixing this issue. And please make sure to backport the fixes to ruby2.3 so that the next updated Debian upload for ruby2.3 will be automatically fixed!
Again, thanks a lot!
Adrian
Updated by usa (Usaku NAKAMURA) over 8 years ago
- Backport changed from 2.1: REQUIRED, 2.2: REQUIRED, 2.3: REQUIRED to 2.1: DONE, 2.2: REQUIRED, 2.3: REQUIRED
ruby_2_1 r54394 merged revision(s) 54256.
Updated by naruse (Yui NARUSE) over 8 years ago
- Backport changed from 2.1: DONE, 2.2: REQUIRED, 2.3: REQUIRED to 2.1: DONE, 2.2: REQUIRED, 2.3: DONE
ruby_2_3 r54425 merged revision(s) 54256,54291,54292,54293.
Updated by nagachika (Tomoyuki Chikanaga) over 8 years ago
- Backport changed from 2.1: DONE, 2.2: REQUIRED, 2.3: DONE to 2.1: DONE, 2.2: DONE, 2.3: DONE
Backported into ruby_2_2
branch at r54430.