Project

General

Profile

Bug #12406

Since r55002, Bus Error on 64-bit SPARC on Solaris 10

Added by ngoto (Naohisa Goto) about 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-dev:49631]

Description

r55002 以降、SPARC Solaris 10 の 64-bit コンパイル時に、以下の Bus Error が発生します。
コンパイラは、gcc, Oracle Solaris Studio 12.3, 12.4 いずれでも発生します。

(r55075の例)

gcc -g -O0 -m64 -L. -L/usr/local/64/lib -R/usr/local/64/lib -fstack-protector -f
stack-protector -pie  main.o dmydln.o miniinit.o dmyext.o miniprelude.o array.o 
bignum.o class.o compar.o complex.o dir.o dln_find.o encoding.o enum.o enumerato
r.o error.o eval.o load.o proc.o file.o gc.o hash.o inits.o io.o marshal.o math.
o node.o numeric.o object.o pack.o parse.o process.o random.o range.o rational.o
 re.o regcomp.o regenc.o regerror.o regexec.o regparse.o regsyntax.o ruby.o safe
.o signal.o sprintf.o st.o strftime.o string.o struct.o symbol.o time.o transcod
e.o util.o variable.o version.o compile.o debug.o iseq.o vm.o vm_dump.o vm_backt
race.o vm_trace.o thread.o cont.o probes.o enc/ascii.o enc/us_ascii.o enc/unicod
e.o enc/utf_8.o enc/trans/newline.o sparc.o explicit_bzero.o flock.o isinf.o set
proctitle.o addr2line.o   -lpthread -lrt -lgmp -lsocket -ldl -lcrypt -lm   -o mi
niruby
./miniruby -I./lib -I. -I.ext/common  ./tool/generic_erb.rb -c -o encdb.h ./temp
late/encdb.h.tmpl ./enc enc
./tool/generic_erb.rb:2: [BUG] Bus Error at 0x000001006969f4
ruby 2.4.0dev (2016-05-19) [sparc64-solaris2.10]

-- Control frame information -----------------------------------------------
c:0003 p:---- s:0025 e:000024 CFUNC  :require
c:0002 p:0008 s:0021 E:000bd8 EVAL   ./tool/generic_erb.rb:2 [FINISH]
c:0001 p:0000 s:0002 E:001320 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
./tool/generic_erb.rb:2:in `<main>'
./tool/generic_erb.rb:2:in `require'

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

* Loaded script: ./tool/generic_erb.rb

* Loaded features:

    0 enumerator.so
    1 thread.rb
    2 rational.so
    3 complex.so

[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

make: *** [encdb.h] Abort

gdb上で走らせると、以下のように、sizeof(VALUE)は8バイトなのに、8の倍数でない番地のポインタ (values == 0x100696a24) を使ってVALUE型にアクセスしようとして、Bus Errorになっていることがわかりました。

id_table.c が word alignment に無頓着なのが問題で、
capa を調整したり、パディングを導入したりする必要がありそうです。

$ gdb ./miniruby 
GNU gdb (GDB) 7.4
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 "sparc64-sun-solaris2.10".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /XXXXX-trunk-55075/miniruby...done.
(gdb) run -I./lib -I. -I.ext/common  ./tool/generic_erb.rb -c -o encdb.h ./template/encdb.h.tmpl ./enc enc
Starting program: /XXXXX-trunk-55075/miniruby -I./lib -I. -I.ext/common  ./tool/generic_erb.rb -c -o encdb.h ./template/encdb.h.tmpl ./enc enc
[Thread debugging using libthread_db enabled]
[New Thread 1 (LWP 1)]
[New LWP    2        ]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1 (LWP 1)]
0x0000000100205918 in list_id_table_insert (tbl=0x10069e920, id=26803, val=1)
    at id_table.c:663
663                 values[i] = val;
(gdb) print values
$1 = (VALUE *) 0x100696a24
(gdb) print i  
$2 = 0
(gdb) print tbl
$3 = (struct list_id_table *) 0x10069e920
(gdb) print *tbl
$4 = {capa = 1, num = 1, keys = 0x100696a20}
(gdb) print tbl->keys
$5 = (id_key_t *) 0x100696a20
(中略)
(gdb) print sizeof(id_key_t)
$8 = 4
(gdb) print sizeof(VALUE)
$9 = 8

Associated revisions

Revision 02cafdf4
Added by ngoto (Naohisa Goto) about 3 years ago

capa should be even number on 64-bit SPARC for 8-byte word alignment

  • id_table.c (list_id_table_init): When unaligned word access is prohibited and sizeof(VALUE) is 8 (64-bit machines), capa should always be even number for 8-byte word alignment of the values of a table. This code assumes that sizeof(ID) is 4, sizeof(VALUE) is 8, and xmalloc() returns 8-byte aligned memory. This fixes bus error on 64-bit SPARC Solaris 10. [Bug #12406][ruby-dev:49631]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 55086
Added by ngoto (Naohisa Goto) about 3 years ago

capa should be even number on 64-bit SPARC for 8-byte word alignment

  • id_table.c (list_id_table_init): When unaligned word access is prohibited and sizeof(VALUE) is 8 (64-bit machines), capa should always be even number for 8-byte word alignment of the values of a table. This code assumes that sizeof(ID) is 4, sizeof(VALUE) is 8, and xmalloc() returns 8-byte aligned memory. This fixes bus error on 64-bit SPARC Solaris 10. [Bug #12406][ruby-dev:49631]

Revision 55086
Added by ngoto (Naohisa Goto) about 3 years ago

capa should be even number on 64-bit SPARC for 8-byte word alignment

  • id_table.c (list_id_table_init): When unaligned word access is prohibited and sizeof(VALUE) is 8 (64-bit machines), capa should always be even number for 8-byte word alignment of the values of a table. This code assumes that sizeof(ID) is 4, sizeof(VALUE) is 8, and xmalloc() returns 8-byte aligned memory. This fixes bus error on 64-bit SPARC Solaris 10. [Bug #12406][ruby-dev:49631]

Revision 55086
Added by ngoto (Naohisa Goto) about 3 years ago

capa should be even number on 64-bit SPARC for 8-byte word alignment

  • id_table.c (list_id_table_init): When unaligned word access is prohibited and sizeof(VALUE) is 8 (64-bit machines), capa should always be even number for 8-byte word alignment of the values of a table. This code assumes that sizeof(ID) is 4, sizeof(VALUE) is 8, and xmalloc() returns 8-byte aligned memory. This fixes bus error on 64-bit SPARC Solaris 10. [Bug #12406][ruby-dev:49631]

Revision 55086
Added by ngoto (Naohisa Goto) about 3 years ago

capa should be even number on 64-bit SPARC for 8-byte word alignment

  • id_table.c (list_id_table_init): When unaligned word access is prohibited and sizeof(VALUE) is 8 (64-bit machines), capa should always be even number for 8-byte word alignment of the values of a table. This code assumes that sizeof(ID) is 4, sizeof(VALUE) is 8, and xmalloc() returns 8-byte aligned memory. This fixes bus error on 64-bit SPARC Solaris 10. [Bug #12406][ruby-dev:49631]

History

#1

Updated by ngoto (Naohisa Goto) about 3 years ago

  • Status changed from Open to Closed

Applied in changeset r55086.


capa should be even number on 64-bit SPARC for 8-byte word alignment

  • id_table.c (list_id_table_init): When unaligned word access is prohibited and sizeof(VALUE) is 8 (64-bit machines), capa should always be even number for 8-byte word alignment of the values of a table. This code assumes that sizeof(ID) is 4, sizeof(VALUE) is 8, and xmalloc() returns 8-byte aligned memory. This fixes bus error on 64-bit SPARC Solaris 10. [Bug #12406][ruby-dev:49631]

Updated by usa (Usaku NAKAMURA) about 3 years ago

  • Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: DONTNEED, 2.2: DONTNEED, 2.3: DONTNEED

Also available in: Atom PDF