You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Memcached -o modern segfaults when using Musl/Alpine Linux #286
any way of someone getting a backtrace (or at least the segfault line out of dmesg + addr2line?) If I have to set that all up to get it to crash it might take a while to figure out :(
Also: I know there're a bunch of options, but if you look at -h it'll list everything that goes into -o modern. it would be super if someone knew which specific option was causing it!
Awesome, thanks, will get you all of those. Will try figure out which one.
It did look like 1.37 which is when it first broke, might have touched some
stuff that overlapped with `-o modern`.
/ $ memcached -h
memcached 1.4.39
...
-o Comma separated list of extended or experimental options
...
- modern: Enables 'modern' defaults. Options that will be default in future.
enables: slab_chunk_max:512k,slab_reassign,slab_automove=1,maxconns_fast,
hash_algorithm=murmur3,lru_crawler,lru_maintainer,no_inline_ascii_resp
can you addr2line -e ./memcached 00007f1e9bc0c162 ?
also, if you're building from source, starting with memcached-debug might do something more useful now that I think about it.
if you can start it so easily, the best thing to do is just: gdb memcached-debug (if using source, else just memcached), then r -o modern and bt
/usr/src/memcached # gdb memcached-debug
This GDB was configured as "x86_64-alpine-linux-musl".
Type "apropos word" to search for commands related to "word"...
Reading symbols from memcached-debug...done.
(gdb) r -u root -o lru_maintainer
Starting program: /usr/src/memcached/memcached-debug -u root -o lru_maintainer
warning: Error disabling address space randomization: Operation not permitted
During startup program terminated with signal SIGSEGV, Segmentation fault.
(gdb) bt
No stack.
sorry it took so long, I finally had some time to figure out wtf musl libc was.
a quick bisect showed me I was creating something large on the stack, and musl must have a much smaller thread stack by default or something. It didn't need to be there so I switched it to a calloc.
Good news and bad news. The good news is that as expected, the tests pass 100% in our Debian variant (whew). The bad news is that Alpine has four tests failures:
Test Summary Report
-------------------
t/dyn-maxbytes.t (Wstat: 28416 Tests: 0 Failed: 0)
Non-zero exit status: 111
Parse errors: Bad plan. You planned 309 tests but ran 0.
t/lru-maintainer.t (Wstat: 28416 Tests: 0 Failed: 0)
Non-zero exit status: 111
Parse errors: Bad plan. You planned 226 tests but ran 0.
t/slabs-reassign-chunked.t (Wstat: 28416 Tests: 0 Failed: 0)
Non-zero exit status: 111
Parse errors: Bad plan. You planned 8 tests but ran 0.
t/slabs-reassign2.t (Wstat: 28416 Tests: 0 Failed: 0)
Non-zero exit status: 111
Parse errors: Bad plan. You planned 12 tests but ran 0.
Files=59, Tests=25154, 171 wallclock secs ( 7.77 usr 0.53 sys + 15.84 cusr 6.51 csys = 30.65 CPU)
Result: FAIL
Still the same 4 failures failing with 1831634 -- anything more I can do to help debug? Would a Dockerfile for reproducing within Docker be helpful? Can I upload binaries somewhere? 😄
Edit: I messed up applying the patch, in my excitement. 🤦♂️ New post incoming with the test results following a proper patching.
I have a bunch of them. some are debian, some are ubuntu, from a few different versions.
on my local machine I just quickly installed the latest musl into /usr/local/musl, compiled latest libevent into it, then built memcached against musl-gcc. that was enough to run the bisect so I stopped there. make would fail at linking memcached-debug together though.
I can either clone one of the debian/ubuntu builders and do something similar with fetching latest musl/building/etc or etc.
I initially tried with the self-compile because the included version of debian/ubuntu of musl was much older than what alpine had packaged. I haven't tried with the built-ins to see if that fixes the memcached-debug compile issue.
Activity
dormando commentedon Jul 11, 2017
any way of someone getting a backtrace (or at least the segfault line out of dmesg + addr2line?) If I have to set that all up to get it to crash it might take a while to figure out :(
dormando commentedon Jul 11, 2017
Also: I know there're a bunch of options, but if you look at -h it'll list everything that goes into -o modern. it would be super if someone knew which specific option was causing it!
zoidyzoidzoid commentedon Jul 11, 2017
dormando commentedon Jul 12, 2017
https://github.com/memcached/memcached/wiki/ReleaseNotes1437 largeish number of small changes in .37. would still save a lot of time to narrow it down, but good to know .36 is fine. If you have an easy repro you can even do a git bisect :) but a hint from a backtrace is probably good enough.
zoidyzoidzoid commentedon Jul 12, 2017
So it seems like
memcached -o lru_maintaineris the problem:slab_chunk_maxalso raises a different strange error, though maybe that's me setting it in the wrong place.Option by option:
Details
I'm not sure if this helps.
dmesgoutput frommemcached -o modern:Details
dormando commentedon Jul 12, 2017
can you
addr2line -e ./memcached 00007f1e9bc0c162?also, if you're building from source, starting with memcached-debug might do something more useful now that I think about it.
if you can start it so easily, the best thing to do is just:
gdb memcached-debug(if using source, else just memcached), thenr -o modernandbtzoidyzoidzoid commentedon Jul 13, 2017
zoidyzoidzoid commentedon Jul 13, 2017
Trying to get
addr2lineandgdbto give me info, but I don't have too much experience with them.dormando commentedon Jul 16, 2017
sorry it took so long, I finally had some time to figure out wtf musl libc was.
a quick bisect showed me I was creating something large on the stack, and musl must have a much smaller thread stack by default or something. It didn't need to be there so I switched it to a calloc.
could you give the next branch a try? https://github.com/memcached/memcached/tree/next - just threw a commit on top that makes it not segfault for me. However can't build the debug binary without surgery I don't really have time for right now, so the tests don't run. It's impressive/scary that someone's been packging memcached without working tests.
tianon commentedon Jul 17, 2017
😅 that's my fault -- I'll go see what I can do to get
make testrunning during our build right away. 😇 ❤️(Edit: hopefully there's a test that will exhibit this failure so I can try applying that patch! 👍)
tianon commentedon Jul 17, 2017
Good news and bad news. The good news is that as expected, the tests pass 100% in our Debian variant (whew). The bad news is that Alpine has four tests failures:
(Edit: full output of
make test: https://gist.github.com/anonymous/5cf98b4f58a0add4f8de34ddfc5ac303)Going to try applying 1831634 now to see if that gets us any further. 👍
tianon commentedon Jul 17, 2017
Still the same 4 failures failing with 1831634 -- anything more I can do to help debug? Would aDockerfilefor reproducing within Docker be helpful? Can I upload binaries somewhere? 😄Edit: I messed up applying the patch, in my excitement. 🤦♂️ New post incoming with the test results following a proper patching.
tianon commentedon Jul 17, 2017
(Should I file a new issue to discuss the test failures instead?)
tianon commentedon Jul 17, 2017
Ok, scratch all that -- I messed up applying the patch. 😇
After applying the patch, all tests pass!!!
dormando commentedon Jul 17, 2017
excellent! If I knew how to make the -debug binary build (fails looking for gcov stuff) I could add musl to the buildbots.
tianon commentedon Jul 17, 2017
Oooh, intriguing. Do they run on some version of Debian/Ubuntu? I'm happy to take a look at what it'll take to make that work!
dormando commentedon Jul 17, 2017
I have a bunch of them. some are debian, some are ubuntu, from a few different versions.
on my local machine I just quickly installed the latest musl into /usr/local/musl, compiled latest libevent into it, then built memcached against musl-gcc. that was enough to run the bisect so I stopped there. make would fail at linking memcached-debug together though.
I can either clone one of the debian/ubuntu builders and do something similar with fetching latest musl/building/etc or etc.
tianon commentedon Jul 18, 2017
Ah nice, I think we could get clever with the
musl-toolspackage (https://packages.debian.org/stretch/musl-tools, https://packages.ubuntu.com/xenial/musl-tools; which includesmusl-gcc). Then you've only got to compilelibeventandmemcacheditself (rather than also buildingmusl). I'll play around a little bit and see what I can come up with.tianon commentedon Jul 18, 2017
Alright, good news -- with the following, I've successfully reproduced the four musl-related test failures from Debian Stretch amd64:
Once I apply the following patch, the image builds (and runs!) successfully and all the tests pass: 👍 🤘
dormando commentedon Jul 18, 2017
I initially tried with the self-compile because the included version of debian/ubuntu of musl was much older than what alpine had packaged. I haven't tried with the built-ins to see if that fixes the memcached-debug compile issue.
edit: swapped some words around..