Title: Debbuging a `-slim` image? · Issue #903 · docker-library/python · GitHub
Open Graph Title: Debbuging a `-slim` image? · Issue #903 · docker-library/python
X Title: Debbuging a `-slim` image? · Issue #903 · docker-library/python
Description: We are hitting a rare deadlock in production that can't be reproduced using debug images. Only way to debug it is to attach to the production image as the problem happens. Problem is that production are based on the -slim images. apt ins...
Open Graph Description: We are hitting a rare deadlock in production that can't be reproduced using debug images. Only way to debug it is to attach to the production image as the problem happens. Problem is that productio...
X Description: We are hitting a rare deadlock in production that can't be reproduced using debug images. Only way to debug it is to attach to the production image as the problem happens. Problem is that produ...
Opengraph URL: https://github.com/docker-library/python/issues/903
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Debbuging a `-slim` image?","articleBody":"We are hitting a rare deadlock in production that can't be reproduced using debug images.\r\nOnly way to debug it is to attach to the production image as the problem happens.\r\nProblem is that production are based on the `-slim` images.\r\n\r\n`apt install gdb` and `python3-dbg` is not enough because the python running is built from source and not aligned with what is available in apt.\r\n\r\nI've tried to start the corresponding non-slim image but their binaries don't seem to align enough to make gdb happy:\r\n\r\n### Start python inside `-slim` image\r\n:arrow_right: *My end goal is to run gdb `py-bt` on this process:* \r\n`docker run -ti python:3.11-slim-bookworm python3 -c \"import time; time.sleep(1000)\"`\r\n\r\nInside this image there is no chance to debug at all due to missing gdb and debug symbols. This is expected.\r\n\r\n### Build a debugger image from the corresponding non`-slim` image.\r\n```\r\nFROM python:3.11-bookworm\r\n\r\nRUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \\\r\n apt update -y && \\\r\n apt install -y gdb\r\n```\r\n`docker build -t mydebugpython .`\r\n\r\n### Use the newly built debug image to attach into the first running container\r\nFind the container id and use that to attach to the same pid-namespace.\r\n```\r\ndocker run \\\r\n --cap-add SYS_PTRACE \\\r\n --pid container:15aab7ea5f57 \\\r\n --privileged \\\r\n -ti \\\r\n --entrypoint bash docker.io/library/mydebugpython\r\n```\r\n```\r\nroot@bb90d04f8722:/# gdb -q python --pid 1 -ex \"py-bt\"\r\n\r\nReading symbols from python...\r\nAttaching to program: /usr/local/bin/python, process 1\r\n\r\nwarning: Build ID mismatch between current exec-file /usr/local/bin/python\r\nand automatically determined exec-file /usr/local/bin/python3.11\r\nexec-file-mismatch handling is currently \"ask\"\r\n\r\nLoad new symbol table from \"/usr/local/bin/python3.11\"? (y or n) y\r\nReading symbols from /usr/local/bin/python3.11...\r\nReading symbols from target:/usr/local/bin/../lib/libpython3.11.so.1.0...\r\n(No debugging symbols found in target:/usr/local/bin/../lib/libpython3.11.so.1.0)\r\nReading symbols from target:/lib/x86_64-linux-gnu/libc.so.6...\r\nReading symbols from /usr/lib/debug/.build-id/82/ce4e6e4ef08fa58a3535f7437bd3e592db5ac0.debug...\r\nReading symbols from target:/lib/x86_64-linux-gnu/libm.so.6...\r\nReading symbols from /usr/lib/debug/.build-id/ea/87e1b3daf095cd53f1f99ab34a88827eccce80.debug...\r\nReading symbols from target:/lib64/ld-linux-x86-64.so.2...\r\nReading symbols from /usr/lib/debug/.build-id/38/e7d4a67acf053c794b3b8094e6900b5163f37d.debug...\r\n[Thread debugging using libthread_db enabled]\r\nUsing host libthread_db library \"/lib/x86_64-linux-gnu/libthread_db.so.1\".\r\n__GI___clock_nanosleep (clock_id=1, flags=1, req=0x7ffd9d9ec458, rem=0x0) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:71\r\n71\t../sysdeps/unix/sysv/linux/clock_nanosleep.c: No such file or directory.\r\nTraceback (most recent call first):\r\n (unable to read python frame information) # \u003c-------------- :(\r\n```\r\n\r\n--------------\r\nSo it seems like the difference of `slim` and non`-slim` isn't only the _presence_ of debug symbols or not, but also the binary is built differently?\r\nIs this possible to solve somehow? My knowledge of how python is built and how to operate gdb are only moderate.","author":{"url":"https://github.com/hterik","@type":"Person","name":"hterik"},"datePublished":"2024-02-02T10:27:48Z","url":"https://github.com/docker-library/python/issues/903"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ec4fc7f0-bc14-76bd-edbc-f4376eb3dac5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 91C0:30C434:C30C38:10C07A4:6AFE8B8B |
| html-safe-nonce | 3416cafdfd939174ab2e5b9f7b02832e0872bf4c8f86f16673656e3e3113e45f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MUMwOjMwQzQzNDpDMzBDMzg6MTBDMDdBNDo2QUZFOEI4QiIsInZpc2l0b3JfaWQiOiI4MDc4NDM3OTI3NjczMDM5NzU1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 9d830500ea134dc61faa32ab0e166122ee163db82284ab2b25b54c949c0995ea |
| hovercard-subject-tag | issue:2114599831 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/docker-library/python/903/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ef6b1d31f18fed4f97f3f3c9032a3b10d0b91ff96fb49f2c33d027ffce3e083a/docker-library/python/issues/903 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ef6b1d31f18fed4f97f3f3c9032a3b10d0b91ff96fb49f2c33d027ffce3e083a/docker-library/python/issues/903 |
| og:image:alt | We are hitting a rare deadlock in production that can't be reproduced using debug images. Only way to debug it is to attach to the production image as the problem happens. Problem is that productio... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hterik |
| hostname | github.com |
| expected-hostname | github.com |
| None | b3c0f155eafc27e60db6e254d1ffff0e072e9ab3b4018a5ee518797c19d89f86 |
| turbo-cache-control | no-preview |
| go-import | github.com/docker-library/python git https://github.com/docker-library/python.git |
| octolytics-dimension-user_id | 7739233 |
| octolytics-dimension-user_login | docker-library |
| octolytics-dimension-repository_id | 21054928 |
| octolytics-dimension-repository_nwo | docker-library/python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 21054928 |
| octolytics-dimension-repository_network_root_nwo | docker-library/python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4a10310af51a1bfffbedc4fd81cb582acf0cb0ff |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width