Project

General

Profile

Bug #13524

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

Added by rtacconi (Riccardo Tacconi) over 2 years ago. Updated about 1 year ago.

Status:
Third Party's Issue
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:80925]

Description

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

History

Updated by shyouhei (Shyouhei Urabe) over 2 years ago

  • Status changed from Open to Feedback

Is it possible for you to show us how to reproduce this?

Updated by rtacconi (Riccardo Tacconi) over 2 years ago

shyouhei (Shyouhei Urabe) wrote:

Is it possible for you to show us how to reproduce this?

If you try to build it with this Dockerfile it works: https://github.com/docker-library/ruby/blob/master/2.4/alpine/Dockerfile. 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:

wget https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.1.tar.gz
tar xzfv ruby-2.4.1.tar.gz
apk update && apk add ca-certificates && update-ca-certificates && apk add openssl
JEMALLOC_VERSION=4.5.0
wget -O jemalloc.tar.gz https://github.com/jemalloc/jemalloc/archive/${JEMALLOC_VERSION}.tar.gz
tar xzfv jemalloc.tar.gz && cd "jemalloc-${JEMALLOC_VERSION}"
make && make install_bin install_include install_lib
cd ruby-2.4.1
./configure --with-jemalloc

So first you can create an Alpine image with that Dockerfile, than:

docker run image_id /bin/sh

and you run the commands above

Updated by rtacconi (Riccardo Tacconi) over 2 years ago

shyouhei (Shyouhei Urabe) wrote:

Is it possible for you to show us how to reproduce this?

Please, build it with this [[[https://github.com/docker-library/ruby/blob/master/2.4/alpine/Dockerfile]]]

Updated by rtacconi (Riccardo Tacconi) over 2 years ago

shyouhei (Shyouhei Urabe) wrote:

Is it possible for you to show us how to reproduce this?

Hi, any update?

Updated by antoniobg (Antonio Borrero Granell) over 2 years ago

I'm also having a segmentation fault using the official ruby image. In my case, the error only happens when executing codeclimate-test-reporter.

Here's the log: https://gist.github.com/antoniobg/787521eec3d1e1019638a8cfe5b48fdd

Updated by wanabe (_ wanabe) over 2 years ago

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.

Updated by shyouhei (Shyouhei Urabe) over 2 years ago

  • Status changed from Feedback to Third Party's Issue

Took me time for several reasons:

  1. Had temporarily ran out of my docker hosts and had to prepare new one. This is my fault.
  2. 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. https://github.com/shyouhei/docker-library/blob/master/%2313524/Dockerfile
  3. 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).

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.

Updated by thomasfedb (Thomas Drake-Brockman) over 1 year ago

Alpine package jemalloc in their main repo, so it would seem that they support it to some extent: https://pkgs.alpinelinux.org/package/v3.7/main/x86/jemalloc

Updated by mperham (Mike Perham) over 1 year ago

All, I modified Shyouhei's Dockerfile to use alpine3.7 and jemalloc 5.0.1 and it no longer segfaults:

FROM ruby:2.4.4-alpine3.7
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

I would suggest trying Alpine 3.7 and see if you still have problems.

Updated by t_anjan (Anjan T) about 1 year ago

I used this Docker file (https://github.com/t-anjan/ruby/blob/jemalloc/2.4/alpine3.7/Dockerfile) which uses Alpine 3.7 and jemalloc 5.0.1 from the alpine repositories.

It still threw the same error.

./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)

Any suggestions?

Also available in: Atom PDF