https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112017-05-01T01:06:35ZRuby Issue Tracking SystemRuby master - Bug #13524: miniruby: [BUG] Segmentation fault at 0x0055e487e00230 ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-lihttps://bugs.ruby-lang.org/issues/13524?journal_id=646072017-05-01T01:06:35Zshyouhei (Shyouhei Urabe)shyouhei@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li></ul><p>Is it possible for you to show us how to reproduce this?</p> Ruby master - Bug #13524: miniruby: [BUG] Segmentation fault at 0x0055e487e00230 ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-lihttps://bugs.ruby-lang.org/issues/13524?journal_id=646492017-05-03T10:24:07Zrtacconi (Riccardo Tacconi)
<ul></ul><p>shyouhei (Shyouhei Urabe) wrote:</p>
<blockquote>
<p>Is it possible for you to show us how to reproduce this?</p>
</blockquote>
<p>If you try to build it with this Dockerfile it works: <a href="https://github.com/docker-library/ruby/blob/master/2.4/alpine/Dockerfile" class="external">https://github.com/docker-library/ruby/blob/master/2.4/alpine/Dockerfile</a>. However I modified that to use jemalloc, so I guess it has something to do with jemalloc. Here is some steps I am doing to compile jemalloc and ruby:</p>
<p>wget <a href="https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.1.tar.gz" class="external">https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.1.tar.gz</a><br>
tar xzfv ruby-2.4.1.tar.gz<br>
apk update && apk add ca-certificates && update-ca-certificates && apk add openssl<br>
JEMALLOC_VERSION=4.5.0<br>
wget -O jemalloc.tar.gz <a href="https://github.com/jemalloc/jemalloc/archive/%24%7BJEMALLOC_VERSION%7D.tar.gz" class="external">https://github.com/jemalloc/jemalloc/archive/${JEMALLOC_VERSION}.tar.gz</a><br>
tar xzfv jemalloc.tar.gz && cd "jemalloc-${JEMALLOC_VERSION}"<br>
make && make install_bin install_include install_lib<br>
cd ruby-2.4.1<br>
./configure --with-jemalloc</p>
<p>So first you can create an Alpine image with that Dockerfile, than:</p>
<p>docker run image_id /bin/sh</p>
<p>and you run the commands above</p> Ruby master - Bug #13524: miniruby: [BUG] Segmentation fault at 0x0055e487e00230 ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-lihttps://bugs.ruby-lang.org/issues/13524?journal_id=646532017-05-03T13:33:19Zrtacconi (Riccardo Tacconi)
<ul></ul><p>shyouhei (Shyouhei Urabe) wrote:</p>
<blockquote>
<p>Is it possible for you to show us how to reproduce this?</p>
</blockquote>
<p>Please, build it with this [[https://github.com/docker-library/ruby/blob/master/2.4/alpine/Dockerfile]]</p> Ruby master - Bug #13524: miniruby: [BUG] Segmentation fault at 0x0055e487e00230 ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-lihttps://bugs.ruby-lang.org/issues/13524?journal_id=647272017-05-09T16:08:59Zrtacconi (Riccardo Tacconi)
<ul></ul><p>shyouhei (Shyouhei Urabe) wrote:</p>
<blockquote>
<p>Is it possible for you to show us how to reproduce this?</p>
</blockquote>
<p>Hi, any update?</p> Ruby master - Bug #13524: miniruby: [BUG] Segmentation fault at 0x0055e487e00230 ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-lihttps://bugs.ruby-lang.org/issues/13524?journal_id=647462017-05-10T15:21:40Zantoniobg (Antonio Borrero Granell)
<ul></ul><p>I'm also having a segmentation fault using the official ruby image. In my case, the error only happens when executing codeclimate-test-reporter.</p>
<p>Here's the log: <a href="https://gist.github.com/antoniobg/787521eec3d1e1019638a8cfe5b48fdd" class="external">https://gist.github.com/antoniobg/787521eec3d1e1019638a8cfe5b48fdd</a></p> Ruby master - Bug #13524: miniruby: [BUG] Segmentation fault at 0x0055e487e00230 ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-lihttps://bugs.ruby-lang.org/issues/13524?journal_id=647502017-05-11T00:42:23Zwanabe (_ wanabe)s.wanabe@gmail.com
<ul></ul><p>I think this is due to mixture of glibc and jemalloc.<br>
Here is a gdb output.</p>
<pre><code>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)
</code></pre>
<p>util.c:531 <a href="https://svn.ruby-lang.org/cgi-bin/viewvc.cgi/tags/v2_4_1/util.c?view=markup#l531" class="external">https://svn.ruby-lang.org/cgi-bin/viewvc.cgi/tags/v2_4_1/util.c?view=markup#l531</a><br>
is call free(cwd) of jemalloc.<br>
But cwd is a return value of getcwd(3) of glibc.</p> Ruby master - Bug #13524: miniruby: [BUG] Segmentation fault at 0x0055e487e00230 ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-lihttps://bugs.ruby-lang.org/issues/13524?journal_id=650232017-05-22T11:24:38Zshyouhei (Shyouhei Urabe)shyouhei@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Third Party's Issue</i></li></ul><p>Took me time for several reasons:</p>
<ol>
<li>Had temporarily ran out of my docker hosts and had to prepare new one. This is my fault.</li>
<li>The ruby:2.4-alpine's Dockerfile you linked kindly deletes compiler and other toolchains from the image. This prevents the procedure you told us to work. Please provide us a reproducible bug report. I ended up writing my own Dockerfile for this. <a href="https://github.com/shyouhei/docker-library/blob/master/%2313524/Dockerfile" class="external">https://github.com/shyouhei/docker-library/blob/master/%2313524/Dockerfile</a>
</li>
<li>I am able to reproduce the bug now, and agree with @wanbe. I think this is either Alpine's or jemalloc's fault (or both).</li>
</ol>
<p>The tiny C source code that comes with my Dockerfile is a file to generate SEGV without the needs of ruby. So at least I can say this has nothing to do with ruby. Please report this to alpine, to check if they support jemalloc or not. If they think it's ruby who's wrong, please tell us so. I'll take a deeper look at it.</p> Ruby master - Bug #13524: miniruby: [BUG] Segmentation fault at 0x0055e487e00230 ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-lihttps://bugs.ruby-lang.org/issues/13524?journal_id=714292018-04-09T09:59:06Zthomasfedb (Thomas Drake-Brockman)
<ul></ul><p>Alpine package jemalloc in their main repo, so it would seem that they support it to some extent: <a href="https://pkgs.alpinelinux.org/package/v3.7/main/x86/jemalloc" class="external">https://pkgs.alpinelinux.org/package/v3.7/main/x86/jemalloc</a></p> Ruby master - Bug #13524: miniruby: [BUG] Segmentation fault at 0x0055e487e00230 ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-lihttps://bugs.ruby-lang.org/issues/13524?journal_id=716272018-04-24T19:35:08Zmperham (Mike Perham)mperham@gmail.com
<ul></ul><p>All, I modified Shyouhei's Dockerfile to use alpine3.7 and jemalloc 5.0.1 and it no longer segfaults:</p>
<pre><code>FROM ruby:2.4.4-alpine3.7
</code></pre>
<pre><code>Step 8/10 : ADD segv.c /tmp/segv.c
---> be86245150aa
Step 9/10 : RUN gcc -ljemalloc segv.c && ./a.out; true
---> Running in 2454384e2cfc
Removing intermediate container 2454384e2cfc
---> ffb021513ffa
Step 10/10 : CMD gdb a.out core
---> Running in 039469e738f9
Removing intermediate container 039469e738f9
---> 01fdb4cf3190
Successfully built 01fdb4cf3190
</code></pre>
<p>I would suggest trying Alpine 3.7 and see if you still have problems.</p> Ruby master - Bug #13524: miniruby: [BUG] Segmentation fault at 0x0055e487e00230 ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-lihttps://bugs.ruby-lang.org/issues/13524?journal_id=744232018-10-12T08:49:07Zt_anjan (Anjan T)
<ul></ul><p>I used this Docker file (<a href="https://github.com/t-anjan/ruby/blob/jemalloc/2.4/alpine3.7/Dockerfile" class="external">https://github.com/t-anjan/ruby/blob/jemalloc/2.4/alpine3.7/Dockerfile</a>) which uses Alpine 3.7 and jemalloc 5.0.1 from the alpine repositories.</p>
<p>It still threw the same error.</p>
<pre><code>./miniruby: [BUG] Segmentation fault at 0x00000000001ec5b8
ruby 2.4.4p296 (2018-03-28 revision 63013) [x86_64-linux-musl]
-- Control frame information -----------------------------------------------
c:0001 p:0000 s:0003 E:000500 (none) [FINISH]
-- Machine register context ------------------------------------------------
RIP: 0x00007fdc27b30520 RBP: 0x0000557e3d8b7980 RSP: 0x00007ffe157203b0
RAX: 0x00000000001ec5b8 RBX: 0x0000557e3d8b6068 RCX: 0x0000000000000000
RDX: 0x0000000000000070 RDI: 0x0000557e3d8b6197 RSI: 0x0000000000000001
R8: 0x0000000000000000 R9: 0x0000557e00000000 R10: 0x0000557e3d8b6080
R11: 0x0000000000000008 R12: 0x0000557e3d8b60e8 R13: 0x0000557e3d8b6220
R14: 0x0000557e3d8b6088 R15: 0x0000557e00000000 EFL: 0x0000000000010206
-- Other runtime information -----------------------------------------------
* Loaded script: ./miniruby
* Loaded features:
0 enumerator.so
1 thread.rb
2 rational.so
3 complex.so
* Process memory map:
557e3bdb8000-557e3c0a0000 r-xp 00000000 08:01 5266190 /usr/src/ruby/miniruby
557e3c29f000-557e3c2a5000 r--p 002e7000 08:01 5266190 /usr/src/ruby/miniruby
557e3c2a5000-557e3c2a6000 rw-p 002ed000 08:01 5266190 /usr/src/ruby/miniruby
557e3c2a6000-557e3c2b4000 rw-p 00000000 00:00 0
557e3d8b6000-557e3d8b8000 rw-p 00000000 00:00 0 [heap]
7fdc26b43000-7fdc275c3000 rw-p 00000000 00:00 0
7fdc275c3000-7fdc277d3000 r-xp 00000000 08:01 5252956 /usr/lib/libgcc_s.so.1
7fdc277d3000-7fdc277d4000 r--p 00010000 08:01 5252956 /usr/lib/libgcc_s.so.1
7fdc277d4000-7fdc277d5000 rw-p 00011000 08:01 5252956 /usr/lib/libgcc_s.so.1
7fdc277d5000-7fdc27b15000 r-xp 00000000 08:01 5252961 /usr/lib/libstdc++.so.6.0.22
7fdc27b15000-7fdc27b23000 r--p 00140000 08:01 5252961 /usr/lib/libstdc++.so.6.0.22
7fdc27b23000-7fdc27b24000 rw-p 0014e000 08:01 5252961 /usr/lib/libstdc++.so.6.0.22
7fdc27b24000-7fdc27b27000 rw-p 00000000 00:00 0
7fdc27b27000-7fdc27d67000 r-xp 00000000 08:01 5259166 /usr/lib/libjemalloc.so.2
7fdc27d67000-7fdc27d6c000 r--p 00040000 08:01 5259166 /usr/lib/libjemalloc.so.2
7fdc27d6c000-7fdc27d6d000 rw-p 00045000 08:01 5259166 /usr/lib/libjemalloc.so.2
7fdc27d6d000-7fdc27f7c000 rw-p 00000000 00:00 0
7fdc27f7c000-7fdc28005000 r-xp 00000000 08:01 5776385 /lib/ld-musl-x86_64.so.1
7fdc281fc000-7fdc281fe000 ---p 00000000 00:00 0
7fdc281fe000-7fdc28204000 rw-p 00000000 00:00 0
7fdc28204000-7fdc28205000 r--p 00088000 08:01 5776385 /lib/ld-musl-x86_64.so.1
7fdc28205000-7fdc28206000 rw-p 00089000 08:01 5776385 /lib/ld-musl-x86_64.so.1
7fdc28206000-7fdc28209000 rw-p 00000000 00:00 0
7ffe14f23000-7ffe15722000 rw-p 00000000 00:00 0 [stack]
7ffe157ae000-7ffe157b1000 r--p 00000000 00:00 0 [vvar]
7ffe157b1000-7ffe157b3000 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
./miniruby: [BUG] Segmentation fault at 0x000000000005d9e8
ruby 2.4.4p296 (2018-03-28 revision 63013) [x86_64-linux-musl]
-- Control frame information -----------------------------------------------
c:0001 p:0000 s:0003 E:001df0 (none) [FINISH]
-- Machine register context ------------------------------------------------
RIP: 0x00007f2834591520 RBP: 0x000055fe0bb3d980 RSP: 0x00007ffe23b4cfd0
RAX: 0x000000000005d9e8 RBX: 0x000055fe0bb3c068 RCX: 0x0000000000000000
RDX: 0x0000000000000070 RDI: 0x000055fe0bb3c197 RSI: 0x0000000000000001
R8: 0x0000000000000000 R9: 0x000055fe00000000 R10: 0x000055fe0bb3c080
R11: 0x0000000000000008 R12: 0x000055fe0bb3c0e8 R13: 0x000055fe0bb3c220
R14: 0x000055fe0bb3c088 R15: 0x000055fe00000000 EFL: 0x0000000000010202
-- Other runtime information -----------------------------------------------
* Loaded script: ./miniruby
* Loaded features:
0 enumerator.so
1 thread.rb
2 rational.so
3 complex.so
* Process memory map:
55fe0a0da000-55fe0a3c2000 r-xp 00000000 08:01 5266190 /usr/src/ruby/miniruby
55fe0a5c1000-55fe0a5c7000 r--p 002e7000 08:01 5266190 /usr/src/ruby/miniruby
55fe0a5c7000-55fe0a5c8000 rw-p 002ed000 08:01 5266190 /usr/src/ruby/miniruby
55fe0a5c8000-55fe0a5d6000 rw-p 00000000 00:00 0
55fe0bb3c000-55fe0bb3e000 rw-p 00000000 00:00 0 [heap]
7f28335a4000-7f2834024000 rw-p 00000000 00:00 0
7f2834024000-7f2834234000 r-xp 00000000 08:01 5252956 /usr/lib/libgcc_s.so.1
7f2834234000-7f2834235000 r--p 00010000 08:01 5252956 /usr/lib/libgcc_s.so.1
7f2834235000-7f2834236000 rw-p 00011000 08:01 5252956 /usr/lib/libgcc_s.so.1
7f2834236000-7f2834576000 r-xp 00000000 08:01 5252961 /usr/lib/libstdc++.so.6.0.22
7f2834576000-7f2834584000 r--p 00140000 08:01 5252961 /usr/lib/libstdc++.so.6.0.22
7f2834584000-7f2834585000 rw-p 0014e000 08:01 5252961 /usr/lib/libstdc++.so.6.0.22
7f2834585000-7f2834588000 rw-p 00000000 00:00 0
7f2834588000-7f28347c8000 r-xp 00000000 08:01 5259166 /usr/lib/libjemalloc.so.2
7f28347c8000-7f28347cd000 r--p 00040000 08:01 5259166 /usr/lib/libjemalloc.so.2
7f28347cd000-7f28347ce000 rw-p 00045000 08:01 5259166 /usr/lib/libjemalloc.so.2
7f28347ce000-7f28349dd000 rw-p 00000000 00:00 0
7f28349dd000-7f2834a66000 r-xp 00000000 08:01 5776385 /lib/ld-musl-x86_64.so.1
7f2834c5d000-7f2834c5f000 ---p 00000000 00:00 0
7f2834c5f000-7f2834c65000 rw-p 00000000 00:00 0
7f2834c65000-7f2834c66000 r--p 00088000 08:01 5776385 /lib/ld-musl-x86_64.so.1
7f2834c66000-7f2834c67000 rw-p 00089000 08:01 5776385 /lib/ld-musl-x86_64.so.1
7f2834c67000-7f2834c6a000 rw-p 00000000 00:00 0
7ffe23350000-7ffe23b4f000 rw-p 00000000 00:00 0 [stack]
7ffe23b69000-7ffe23b6c000 r--p 00000000 00:00 0 [vvar]
7ffe23b6c000-7ffe23b6e000 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:643: .rbconfig.time] Aborted (core dumped)
make: *** Waiting for unfinished jobs....
make: *** [uncommon.mk:854: encdb.h] Aborted (core dumped)
</code></pre>
<p>Any suggestions?</p>