-
Notifications
You must be signed in to change notification settings - Fork 76
docker ruby:alpine SEGFAULT error #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The big problem with running in Docker is that a lot of normally expected dependencies aren't guaranteed to exist. In this case it looks like the actual segfault is from timeout.rb, not our own code. It seems possible that you're missing some internal dependency for Ruby that's causing this. |
To be clear, I don't think this is Skylight crashing. I think Skylight is attempting an HTTP request with If you want to test more, can you try making your own |
Please, pay attention that |
OK, I can confirm that this is Alpine image-only issue |
That image ruby:2.4-alpine does not use Alpine’s ruby package, but compiles it itself. So the first thing I’d suggest is to try skylight on clean Alpine v3.5 and Ruby installed from the official package main/ruby (2.3.3). If you need Ruby 2.4.0, then you can install it from edge (unstable). If it will work here, then it’s not a bug in skylight nor Alpine, but that docker image (I’d not be surprised…). Otherwise I’d look at it more closely, because it might be a bug in our Ruby package, or skylight is doing something very nasty in its native extension. Please note that Alpine uses musl libc, not GNU libc. However, I’d not expect problem in libc compatibility here, if it compiles without any error (I assume that you compile this extension directly on Alpine…). |
@jirutka
Thanks! |
@ababich so far, the problem you're seeing looks likely to be caused by a problematic Docker container. I believe this is what @jirutka is trying to say. This is also backed up by the fact that Skylight runs with this Dockerfile: https://gist.github.com/wagenet/5ae561a4105c7b32483b2a08aebe8f34 I understand that you're saying the issue only happens when you have the Skylight gem installed. However, I'm suggesting that the SEGFAULT you're seeing may still be from Ruby internals, not Skylight. If Skylight is using a Ruby feature that isn't used elsewhere in your app then removing the Skylight gem would solve this problem. From what I can see of the logs you shared, the error is from Ruby's Timeout code as utilized by Net::HTTP. If this is indeed the case, then there still isn't much we can do in Skylight to directly to solve the issue. Docker setups attempt to strip out everything that is non-essential, but as a result, it's easy to accidentally strip out something that is actually important. If something essential to Ruby's internals is missing from the Docker container, that could definitely cause the problem. There are a couple of ways to proceed from here:
|
To be honest, I do not see much sense in further experiments for next reasons:
This means that dockerizing cannot strip anything - both images are fully official with no changes, and I've never seen issues switching between them
|
@ababich if you're happy with Debian then it sounds like a good solution. In my experience Docker containers commonly run into issues like this, though YMMV. |
Right now getting things to work on Alpine is a low priority. However, if someone is able to provide a simple reproduction (i.e. a repo we can clone that causes the issue) I'd be happy to reopen this and investigate further. |
Turns out it was an issue with when Ruby is compiled. This should fix it 138bb9a |
Hi @wagenet, We use Ruby on Rails with Docker, we would like to use Skylight but I still get the segmentation fault exception at the starting of the container. According the issues about Alpine, a patch should be provided since at least March but even we the latest versions (Skylight: The problem blocks us to test Skylight and I don't have a lot of time for that. How can I help you to identify the cause? In the IRB of the container (ruby:2.4-alpine): RbConfig::CONFIG['arch'] #=> "x86_64-linux-musl" In the shell of the container: $ ldd --version
musl libc (x86_64)
Version 1.1.14
Dynamic Program Loader
Usage: ldd [options] [--] pathname In the shell of the container: $ cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.4.6
PRETTY_NAME="Alpine Linux v3.4"
HOME_URL="http://alpinelinux.org"
BUG_REPORT_URL="http://bugs.alpinelinux.org" Let me know if you need something else. Thank you. |
@GRoguelon sorry for the delayed reply, and sorry for the trouble! I've found that getting stuff to work with musl is a pretty annoying process. However, I'll see if I can investigate this sometime in the near future. |
Then you’re probably doing something nasty. Musl is quite good litmus paper… |
@jirutka that's possible, but I've found that error messages are quite opaque and not even all "standard" libraries appear to play well with musl. So while you may be technically correct, it doesn't make things any less painful. |
You can try to ask in Freenode’s channel #musl, there are clever people who can help. |
What do you consider as “standard” libraries? We have a complete Linux distribution based on musl libc, Alpine Linux. Sure, some libraries and programs needs to be patched, b/c they rely on non-standard GNU libc extensions and bugs, but it’s almost always solvable. |
@jirutka to be clear, I'm not saying it's unsolvable, but that it can be non-trivial, especially for someone who is not an expert in the intricacies of the system. I'll definitely give the Freenode channel a go when I'm able to allocate more time to this. |
Aha, It seems that there’s no source-code available, so I cannot check it and try to compile. Users cannot review it and I’d bet that most of them even don’t know that this Ruby gem downloads some proprietary binary from somewhere. I’m done here. (As I said, musl is quite good litmus paper… for bad code and even suspicious software.) |
@jirutka That's a bit premature. The binary is a rust library they can share among the different language specific agents. It's one of the things that makes skylight work so well. We're using skylight on musl in production with no issues. |
@jirutka I'm really not understanding your antagonism here. Skylight is a proprietary product and we're pretty clear about downloading pre-compiled code. |
There’s no source-code in skylightio/skylight-rust repository, only binaries. @wagenet How do you build it? On Alpine system with rust installed from Alpine package, or other Linux system with musl toolchain? |
@jirutka currently we're building it with the musl toolchain on a CentOS system. I'm completely ready to admit that this may not be the ideal way to do things. I'd really like to rewrite our internal build system (it was cobbled together before Rust was 1.0 and things were not nearly so good then) which would probably help with some of our issues. |
Where? There’s no single note in the gem’s description on Rubygems and no warning when installing it:
Also license field is completely missing in your gemspec. |
@jirutka If you're a current customer and you want to contact our support to discuss these sorts of issues, please do so. This isn't the appropriate thread for discussing these issues. But to give you a quick answer, we talk about it extensively in our marketing. The gem isn't any use if you don't sign up for our product so I expect people to be generally aware. We've yet to have any customer complain about the existence of a precompiled native agent. |
No, I’m not and not willing to be. I’m one of the Alpine Linux’s developers, that’s why I started watching this issue. But I cannot help much with something that does not have source code available. |
That’s interesting, because rustc (still) don’t support building dynamically linked binaries with musl. How you did it? We needed to patch rust to allow this and fix many bad assumptions and bugs in Rust’s build system. Unfortunately these patches are not merged into upstream yet. Anyway, you may try to build skylight-rust on Alpine Linux with Rust installed from our package (community/rust). The default triplet is You can use script alpine-chroot-install to easily install Alpine Linux into chroot on your CentOS builders. I use it on Travis CI that runs Ubuntu (example .travis.yml). |
@jirutka here's our Makefile. I'll be the first to tell you that it's not pretty: https://gist.github.com/wagenet/094517642304615fbb9295f5744dd78c. |
Do I understand it right that you build How do you build |
Our Rust code has two portions: a completely standalone daemon and a library that is loaded by Ruby that then interfaces with the daemon. Where things get a bit complicated is in making that library that Ruby can load. I've updated the gist to include the deps Makefile: https://gist.github.com/wagenet/094517642304615fbb9295f5744dd78c |
I was able to resolve some of the recent build issues. I can't guarantee that it will work for @ababich, but at least the build toolchain is working correctly again! |
@ababich if this is still an issue for you, would you be able to provide a sample Dockerfile? |
Closing due to inability to reproduce. Will happily reopen if anyone can help with a reproduction. |
I cannot write more "proper" subject because I do not know exact issue:
Precondition: we have
ruby 2.4
project usingrails 5.0.1
This project is running inside
docker 1.13+
When running in dev mode w/o docker
skylight
works in development modeWorks means
rspec
test coverage hereWhen running in
docker
we haveSEGFAULT
, ruby 2.3 and 2.4 verified - same issuesExample logs:
the test above tries to reach external endpoint via
restclient 2.0
this is integration test
Exactly the same test is perfectly working w/o skylight
Docker image is based on
ruby:2.4-alpine
Please let me know if this is known issues or you need more details to reproduce
The text was updated successfully, but these errors were encountered: