Issue #13524 has been updated by wanabe (_ wanabe).


I think this is due to mixture of glibc and jemalloc.
Here is a gdb output.

```
Thread 1 "miniruby" received signal SIGSEGV, Segmentation fault.
0x00007ffff7b03ca6 in je_arena_mapbitsp_read (mapbitsp=<optimized out>) at include/jemalloc/internal/arena.h:802
802	include/jemalloc/internal/arena.h: No such file or directory.
(gdb) bt
#0  0x00007ffff7b03ca6 in je_arena_mapbitsp_read (mapbitsp=<optimized out>) at include/jemalloc/internal/arena.h:802
#1  je_arena_mapbits_get (pageind=77, chunk=0x555555a00000) at include/jemalloc/internal/arena.h:809
#2  je_arena_mapbits_binind_get (pageind=77, chunk=0x555555a00000) at include/jemalloc/internal/arena.h:866
#3  je_arena_salloc (demote=false, ptr=0x555555a4dd00, tsdn=<optimized out>) at include/jemalloc/internal/arena.h:1387
#4  je_isalloc (demote=false, ptr=0x555555a4dd00, tsdn=<optimized out>)
    at include/jemalloc/internal/jemalloc_internal.h:1054
#5  ifree (tsd=<optimized out>, slow_path=false, tcache=0x7ffff760d000, ptr=0x555555a4dd00) at src/jemalloc.c:1891
#6  free (ptr=0x555555a4dd00) at src/jemalloc.c:2016
#7  0x000055555573426a in ruby_getcwd () at util.c:531
(snip)
```

util.c:531 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi/tags/v2_4_1/util.c?view=markup#l531
is call free(cwd) of jemalloc.
But cwd is a return value of getcwd(3) of glibc.

----------------------------------------
Bug #13524: miniruby: [BUG] Segmentation fault at 0x0055e487e00230 ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-li
https://bugs.ruby-lang.org/issues/13524#change-64750

* Author: rtacconi (Riccardo Tacconi)
* Status: Feedback
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.4.1p111
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
Linux: Alpine Linux 3.5

./miniruby: [BUG] Segmentation fault at 0x0055e487e00230
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0001 p:0000 s:0003 E:001c20 (none) [FINISH]


-- Machine register context ------------------------------------------------
 RIP: 0x00007f3c79126046 RBP: 0x000055e487e44d00 RSP: 0x00007ffd62f251e0
 RAX: 0x00007f3c79608ae0 RBX: 0x000055e487e00000 RCX: 0x0000000000000000
 RDX: 0x0000000000000001 RDI: 0x000055e487e44d00 RSI: 0x0000000000000037
  R8: 0x00007f3c7916d680  R9: 0x0000000000000001 R10: 0x0000000000802005
 R11: 0x000000000000007a R12: 0x00007f3c78c0d000 R13: 0x00007f3c79608ae0
 R14: 0x00007f3c7937c090 R15: 0x00007f3c7937c0a0 EFL: 0x0000000000010212

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

* Loaded script: ./miniruby

* Loaded features:

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

* Process memory map:

55e487930000-55e487c31000 r-xp 00000000 00:2e 18687                      /root/ruby-2.4.1/miniruby
55e487e30000-55e487e36000 r--p 00300000 00:2e 18687                      /root/ruby-2.4.1/miniruby
55e487e36000-55e487e37000 rw-p 00306000 00:2e 18687                      /root/ruby-2.4.1/miniruby
55e487e37000-55e487e45000 rw-p 00000000 00:00 0
7f3c78a00000-7f3c79000000 rw-p 00000000 00:00 0
7f3c7911c000-7f3c79378000 r-xp 00000000 00:2e 12926                      /usr/local/lib/libjemalloc.so.2
7f3c79378000-7f3c7937b000 r--p 0005c000 00:2e 12926                      /usr/local/lib/libjemalloc.so.2
7f3c7937b000-7f3c7937c000 rw-p 0005f000 00:2e 12926                      /usr/local/lib/libjemalloc.so.2
7f3c7937c000-7f3c7937d000 rw-p 00000000 00:00 0
7f3c7937d000-7f3c79405000 r-xp 00000000 00:2e 24                         /lib/ld-musl-x86_64.so.1
7f3c795ff000-7f3c79600000 ---p 00000000 00:00 0
7f3c79600000-7f3c79605000 rw-p 00000000 00:00 0
7f3c79605000-7f3c79606000 r--p 00088000 00:2e 24                         /lib/ld-musl-x86_64.so.1
7f3c79606000-7f3c79607000 rw-p 00089000 00:2e 24                         /lib/ld-musl-x86_64.so.1
7f3c79607000-7f3c7960a000 rw-p 00000000 00:00 0
7ffd62f07000-7ffd62f28000 rw-p 00000000 00:00 0                          [stack]
7ffd62f2f000-7ffd62f31000 r--p 00000000 00:00 0                          [vvar]
7ffd62f31000-7ffd62f33000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]


[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: *** [uncommon.mk:854: encdb.h] Aborted



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

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>