Add core dump support to Docker Compose services#35
Add core dump support to Docker Compose services#35RiteshKtiet wants to merge 4 commits intoosdldbt:mainfrom
Conversation
- Enable unlimited core dumps via ulimits in broker, market, and driver services - Add volume mount for ./cores directory to persist core dumps on host - Add ulimit -c unlimited in service startup scripts - Update .gitignore to exclude cores/ directory - Update .dockerignore to exclude cores/ directory from build context - Add ulimit configuration to base image bashrc This allows automatic core dump generation when services crash. Host configuration may be required on systems with systemd-coredump or other crash handlers. Will add it in the docs later on.
Two things items to work on. You should add documentation, don't need to ask if it's acceptable. I don't think this takes into account my comment about in #34 about the the host and guest OS matching. |
|
Hey @markwkm, firstly sorry for the delay. I have made a few changes which I feel will address all the issues. When a binary crashes inside a container, core dumps are automatically captured and persisted to Here are the changes that I have made in the docker file:- Key Changes
The How the Host/Guest OS Mismatch Is SolvedA core dump is just a memory snapshot. To read it, GDB needs the exact binary and exact shared libraries that were loaded when the crash happened. If the host runs a diff os say, Ubuntu 24.04 and since the container runs Debian Bookworm, the library versions differ ( So we solve it by :-
Thus, a clean backtrace regardless of host distro: Usage1. Host prerequisite (one-time)sudo sysctl -w kernel.core_pattern=core.%e.%p
# Ubuntu only — disable Apport if it intercepts core dumps:
sudo systemctl disable apport && sudo systemctl stop apport2. Start servicesdocker compose up -d
docker compose run load # first time only
docker compose run driver -d 120 # run workload3. After a crashls ./cores/
# BrokerageHouseMain core.BrokerageHouseM.483 sysroot/4a. Debug inside the container (easier)docker compose exec broker \
gdb /opt/egen/bin/BrokerageHouseMain /cores/core.BrokerageHou.<pid>4b. Debug locally on the hostsudo chmod 644 ./cores/core.BrokerageHou.<pid>
cd cores/
gdb -ex "set sysroot ./sysroot" \
./BrokerageHouseMain ./core.BrokerageHou.<pid>5. Inside GDBI hope this meets all your expectations (Although I have a feeling that this a little complex solution). Let me know if I should make any change, I'll do it asap! |
|
Yeah, the complexity bothers me a little, because it doesn't look natural. i.e. Docker really isn't meant to be used like that. Yet I say that as someone not particularly Docker savvy. Although I still wonder if there is a way to fall through coredumpctl to output or save any cores. While I like the sound of that thought, I don't know if that's any more possible to expect to be doable. |
|
Thanks for the feedback! I have tried to simplify the approach a little. On the coredumpctl question: tested it and here is how it works. Debugging workflowWhen a container crashes,
To get the full backtrace, extract the core with
docker compose run --no-deps --rm \
-v /tmp/core.file:/tmp/core.file \
broker \
gdb /opt/egen/bin/BrokerageHouseMain /tmp/core.filebasically: “spin up a fresh broker container, bring the core file into it, and launch GDB where everything matches.” This still uses Docker in a slightly “creative” way. Let me know if this bothers you I’ll refactor the PR in that case. |
|
It would be additionally helpful if you commented on your experiences about using the various methods you are proposing. |
|
Hey @markwkm, here's what I experienced testing the different approaches: Sysroot copy (earlier iteration) This worked when host and container distros didn't match, copied the binary + shared libs via coredumpctl + docker compose run (current approach) This was a better experience, On my Ubuntu 22.04 setup, crashes inside containers just showed up in One thing to note, for Ubuntu desktop, Apport likes to hijack On WSL This was the messiest of the three. WSL2 doesn't run systemd by default so Overall method 2 was better, it piggybacks on what the host already does. |
Hey @markwkm, with reference to issue #34, I have implemented a minimal solution for core dump support:
Changes:
ulimits: core: -1to broker, market, and driver services./cores:/coresvolume mount to persist core dumps on hostulimit -c unlimitedin startup scripts.gitignoreand.dockerignoreto excludecores/If you are using WSL, you'll need to configure the host:
sudo sysctl -w kernel.core_pattern="$(pwd)/cores/core.%e.%p.%t"Another option is using
privileged: true, but i guess that would be less secure.Test:
I hope this solves the purpose. Should I add documentation if this approach is acceptable?