Issue #11831 has been reported by octoploid octoploid.

----------------------------------------
Bug #11831: Undefined behavior issues
https://bugs.ruby-lang.org/issues/11831

* Author: octoploid octoploid
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Building ruby-2.2.4 with gcc's -fsanitize=undefined shows:

...
./miniruby -I./lib -I. -I.ext/common  ./tool/mkconfig.rb -timestamp=.rbconfig.time \
        -install_name=ruby22 \
        -so_name=ruby22 rbconfig.rb
siphash.c:417:8: runtime error: load of misaligned address 0x000000835093 for type 'uint64_t', which requires 8 byte alignment
0x000000835093: note: pointer points here
 61  6d 65 00 5f 5f 61 75 74  6f 6c 6f 61 64 5f 5f 00  63 61 6e 27 74 20 61 6c  69 61 73 20 69 6e 20
              ^ 
siphash.c:452:43: runtime error: load of misaligned address 0x00000083509b for type 'uint32_t', which requires 4 byte alignment
0x00000083509b: note: pointer points here
 74  6f 6c 6f 61 64 5f 5f 00  63 61 6e 27 74 20 61 6c  69 61 73 20 69 6e 20 74  72 61 63 65 72 00 23
              ^ 
./miniruby -I./lib -I. -I.ext/common  ./tool/generic_erb.rb -c -o encdb.h ./template/encdb.h.tmpl ./enc enc
st.c:1583:7: runtime error: load of misaligned address 0x00000083756c for type 'st_index_t', which requires 8 byte alignment
0x00000083756c: note: pointer points here
  65 2e 63 00 65 6e 63 2f  65 6e 63 64 62 2e 73 6f  00 65 6e 63 2f 74 72 61  6e 73 2f 74 72 61 6e 73
              ^ 
siphash.c:417:8: runtime error: load of misaligned address 0x000000835093 for type 'uint64_t', which requires 8 byte alignment
0x000000835093: note: pointer points here
 61  6d 65 00 5f 5f 61 75 74  6f 6c 6f 61 64 5f 5f 00  63 61 6e 27 74 20 61 6c  69 61 73 20 69 6e 20
              ^ 
siphash.c:452:43: runtime error: load of misaligned address 0x00000083509b for type 'uint32_t', which requires 4 byte alignment
0x00000083509b: note: pointer points here
 74  6f 6c 6f 61 64 5f 5f 00  63 61 6e 27 74 20 61 6c  69 61 73 20 69 6e 20 74  72 61 63 65 72 00 23
              ^ 
st.c:1583:7: runtime error: load of misaligned address 0x00000083756c for type 'st_index_t', which requires 8 byte alignment
0x00000083756c: note: pointer points here
  65 2e 63 00 65 6e 63 2f  65 6e 63 64 62 2e 73 6f  00 65 6e 63 2f 74 72 61  6e 73 2f 74 72 61 6e 73
              ^ 
regexec.c:2632:7: runtime error: load of misaligned address 0x0000026ec3b2 for type 'RelAddrType', which requires 4 byte alignment
0x0000026ec3b2: note: pointer points here
 00 00  2b 40 0e 00 00 00 07 09  00 00 00 61 63 5f 67 69  76 65 6e 5f 07 08 00 00  00 49 4e 53 54 41
              ^ 
regexec.c:1632:7: runtime error: load of misaligned address 0x0000026ec3b7 for type 'LengthType', which requires 4 byte alignment
0x0000026ec3b7: note: pointer points here
 00 00 00 07 09  00 00 00 61 63 5f 67 69  76 65 6e 5f 07 08 00 00  00 49 4e 53 54 41 4c 4c  3d 37 01
             ^ 
regexec.c:2624:7: runtime error: load of misaligned address 0x0000027ccc41 for type 'RelAddrType', which requires 4 byte alignment
0x0000027ccc41: note: pointer points here
 00 23 41  3f f4 ff ff ff 3b 01 00  03 22 5d 40 27 00 00 00  10 00 3e 00 00 01 00 00  00 00 00 00 00
              ^ 
regexec.c:1759:11: runtime error: load of misaligned address 0x0000027ccc55 for type 'Bits', which requires 4 byte alignment
0x0000027ccc55: note: pointer points here
 00 3e 00 00 01 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00
             ^ 
regexec.c:2296:7: runtime error: load of misaligned address 0x0000027cccad for type 'MemNumType', which requires 2 byte alignment
0x0000027cccad: note: pointer points here
 00 1b 22 3b 02 00 02  22 40 26 00 00 00 10 00  3e 00 00 01 00 00 00 00  00 00 00 00 00 00 00 00  00
             ^ 
regexec.c:2695:7: runtime error: load of misaligned address 0x0000027d75df for type 'RelAddrType', which requires 4 byte alignment
0x0000027d75df: note: pointer points here
 00 00 23 43 06  00 00 00 4f 23 3f f4 ff  ff ff 05 4f 42 4a 53 2c  01 00 00 00 00 00 00 00  01 0a 00
             ^ 
regexec.c:2275:7: runtime error: load of misaligned address 0x00000281f723 for type 'MemNumType', which requires 2 byte alignment
0x00000281f723: note: pointer points here
 03  24 7b 38 02 00 13 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 28 00 00  00 00 00 00 00 00 00
              ^ 
regexec.c:1814:11: runtime error: load of misaligned address 0x00000281f732 for type 'Bits', which requires 4 byte alignment
0x00000281f732: note: pointer points here
 00 00  00 00 00 00 00 28 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 40 27  00 00 00 13 00 00
              ^ 
regexec.c:2282:7: runtime error: load of misaligned address 0x0000027caedb for type 'MemNumType', which requires 2 byte alignment
0x0000027caedb: note: pointer points here
 ff  ff ff 37 02 00 40 02 00  00 00 02 2d 10 00 00 00  00 00 00 ff 03 00 00 00  00 00 00 00 00 00 00
              ^ 
regexec.c:2823:7: runtime error: load of misaligned address 0x0000027cbbbe for type 'RelAddrType', which requires 4 byte alignment
0x0000027cbbbe: note: pointer points here
 37 01 00 50 14 00  00 00 40 0a 00 00 00 05  61 62 73 5f 3f 04 00 00  00 04 6f 6c 64 51 10 00  00 00
             ^ 
rbconfig.rb updated
./miniruby -I./lib -I. -I.ext/common  "./tool/generic_erb.rb" -o verconf.h ./template/verconf.h.tmpl
./miniruby -I./lib -I. -I.ext/common  ./enc/make_encmake.rb --builtin-encs="ascii.o us_ascii.o unicode.o utf_8.o" --builtin-transes="newline.o" --module enc.mk 
regexec.c:2632:7: runtime error: load of misaligned address 0x00000169763b for type 'RelAddrType', which requires 4 byte alignment
0x00000169763b: note: pointer points here
 3b  01 00 40 08 00 00 00 38  02 00 17 19 3b 02 00 01  2a 76 61 6c 29 0a 00 00  00 00 00 00 00 00 00
              ^ 
regexec.c:2282:7: runtime error: load of misaligned address 0x0000016978d5 for type 'MemNumType', which requires 2 byte alignment
0x0000016978d5: note: pointer points here
 03 2d 2d 37 01 00 40  26 00 00 00 13 00 3e 00  00 01 00 00 20 00 00 00  28 00 00 00 00 00 00 00  00
             ^ 
regexec.c:1814:11: runtime error: load of misaligned address 0x0000016978e9 for type 'Bits', which requires 4 byte alignment
0x0000016978e9: note: pointer points here
 00 00 00  28 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 3f d5 ff  ff ff 3b 01 00
              ^ 
regexec.c:2624:7: runtime error: load of misaligned address 0x0000016978fe for type 'RelAddrType', which requires 4 byte alignment
0x0000016978fe: note: pointer points here
 00 00 00 3f d5 ff  ff ff 3b 01 00 40 08 00  00 00 38 02 00 17 19 3b  02 00 01 65 64 20 77 69  74 68
             ^ 
regexec.c:2296:7: runtime error: load of misaligned address 0x000001697903 for type 'MemNumType', which requires 2 byte alignment
0x000001697903: note: pointer points here
 ff  ff ff 3b 01 00 40 08 00  00 00 38 02 00 17 19 3b  02 00 01 65 64 20 77 69  74 68 69 6e 0a 00 00
              ^ 
regexec.c:2275:7: runtime error: load of misaligned address 0x00000169790b for type 'MemNumType', which requires 2 byte alignment
0x00000169790b: note: pointer points here
 00  00 00 38 02 00 17 19 3b  02 00 01 65 64 20 77 69  74 68 69 6e 0a 00 00 00  00 00 00 00 00 00 00
              ^ 
...

The upcoming gcc-6 actually "miscompiles" ./miniruby due to these issues.



-- 
https://bugs.ruby-lang.org/