René's URL Explorer Experiment


Title: SIGSEGV using `journal.Reader`, thread safety issue? · Issue #143 · systemd/python-systemd · GitHub

Open Graph Title: SIGSEGV using `journal.Reader`, thread safety issue? · Issue #143 · systemd/python-systemd

X Title: SIGSEGV using `journal.Reader`, thread safety issue? · Issue #143 · systemd/python-systemd

Description: Env: $ python3 --version Python 3.11.2 $ systemctl --version systemd 252 (252.36-1~deb12u1) +PAM +AUDIT +SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTS...

Open Graph Description: Env: $ python3 --version Python 3.11.2 $ systemctl --version systemd 252 (252.36-1~deb12u1) +PAM +AUDIT +SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS ...

X Description: Env: $ python3 --version Python 3.11.2 $ systemctl --version systemd 252 (252.36-1~deb12u1) +PAM +AUDIT +SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS ...

Opengraph URL: https://github.com/systemd/python-systemd/issues/143

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"SIGSEGV using `journal.Reader`, thread safety issue?","articleBody":"### Env:\n```\n$ python3 --version\nPython 3.11.2\n$ systemctl --version\nsystemd 252 (252.36-1~deb12u1)\n+PAM +AUDIT +SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY +P11KIT +QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD -BPF_FRAMEWORK -XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified\n$ python3 -c \"from systemd import journal; print(journal.__version__)\"\n235\n```\n### Issue:\nI got sporadically a segfault using journal.Reader from python-systemd module.\nThereby it seemed to happen by stop of thread, monitoring journal with Reader.\n\nI could reproduce it also under dgb, here is the callstack:\n\u003cdetails\u003e\n\n```\n[New Thread 0x7ffff5f876c0 (LWP 89339)]\n\nThread 2 \"f2b/f.DummyJail\" received signal SIGSEGV, Segmentation fault.\n[Switching to Thread 0x7ffff5f876c0 (LWP 89339)]\n0x00007ffff6f86d63 in ?? () from /lib/x86_64-linux-gnu/libsystemd.so.0\n(gdb) where\n#0  0x00007ffff6f86d63 in ?? () from /lib/x86_64-linux-gnu/libsystemd.so.0\n#1  0x00007ffff6f877f5 in ?? () from /lib/x86_64-linux-gnu/libsystemd.so.0\n#2  0x00007ffff6f6a848 in ?? () from /lib/x86_64-linux-gnu/libsystemd.so.0\n#3  0x00007ffff6f99502 in ?? () from /lib/x86_64-linux-gnu/libsystemd.so.0\n#4  0x00007ffff6f69403 in ?? () from /lib/x86_64-linux-gnu/libsystemd.so.0\n#5  0x00007ffff6f6961e in ?? () from /lib/x86_64-linux-gnu/libsystemd.so.0\n#6  0x00007ffff6f6d11a in sd_journal_get_fd () from /lib/x86_64-linux-gnu/libsystemd.so.0\n#7  0x00007ffff6f6f3c9 in sd_journal_wait () from /lib/x86_64-linux-gnu/libsystemd.so.0\n#8  0x00007ffff6cadf2c in ?? () from /usr/lib/python3/dist-packages/systemd/_reader.cpython-311-x86_64-linux-gnu.so\n#9  0x0000000000548ac8 in ?? ()\n#10 0x00000000005188b3 in _PyObject_MakeTpCall ()\n#11 0x000000000052c2f0 in _PyEval_EvalFrameDefault ()\n#12 0x0000000000585e54 in ?? ()\n#13 0x0000000000584e98 in ?? ()\n#14 0x000000000053034e in _PyEval_EvalFrameDefault ()\n#15 0x0000000000585e54 in ?? ()\n#16 0x0000000000584e98 in ?? ()\n#17 0x000000000067b32c in ?? ()\n#18 0x0000000000656384 in ?? ()\n#19 0x00007ffff7d381f5 in start_thread (arg=\u003coptimized out\u003e) at ./nptl/pthread_create.c:442\n#20 0x00007ffff7db889c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81\n```\n\u003c/details\u003e\n\nIt can be either some missing lock or atomic handling somewhere in journal.Reader, because if I rewrote the code to avoid too earlier clean-up, closing the journal with `Reader.close()` before join of thread (now it ensures that the thread working with Reader is really stopped, before clean-up happens), it doesn't happen anymore.\nSo my assumption is if TH2 is somewhere within `reader.wait()` and TH1 would invoke `reader.close()`, it could segfault.\nSure, it can be avoided on the user side, just SF is SF and shall not happen normally.\n\nNaive attempts to reproduce it with simple wait/close in different threads did not work, but I could find a bit complex scenario (with a busy-wait \u0026 lock using to synchronize the timing a bit), where it is pretty reproducible, almost every time not later than on 10 iteration:\n```python\nimport time\nfrom systemd import journal\nfrom threading import Thread, Lock\nl = Lock(); # just used for \"better\" timing here to get SF\n\ndef test():\n  stat = {};\n  jr = journal.Reader()\n  def mon():\n    print('start')\n    try:\n      jr.seek_head()\n      print('work')\n      stat['started'] = 1\n      l.acquire(); l.release()\n      # *-* [A], thread is here as another thread is on *-* [B]\n      while (j := jr):\n        if j.wait(3) in (journal.NOP, journal.APPEND):\n          j.get_next()\n    except Exception as e:\n      print('ERR: %s' % e)\n    if jr: jr.close()\n  th = Thread(target=mon); \n  th.start()\n  # just \"sync\" wait and close calls:\n  while not stat: time.sleep(0.00001);\n  l.acquire(); l.release()\n  # *-* [B], thread is here as another thread is on *-* [A]\n  # do evil close:\n  jr.close(); jr = None\n  th.join()\n  print('OK')\n\nfor i in range(100): # just 100 attempts, because of sporadic matter\n  test()\n```","author":{"url":"https://github.com/sebres","@type":"Person","name":"sebres"},"datePublished":"2025-03-30T03:29:49.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/143/python-systemd/issues/143"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:66540eac-1857-03f0-5fba-750b746a48e4
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA8BA:2FE0E1:F4E635:15467E6:6A4DF0E1
html-safe-nonce0b5cb2af829922619f13a4d91b711ff38fd39c97cac303d5e9f84db9db61fd6f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOEJBOjJGRTBFMTpGNEU2MzU6MTU0NjdFNjo2QTRERjBFMSIsInZpc2l0b3JfaWQiOiIyMjU4MDM3NTYzOTc2NDQ2MTc4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac8470453f6943c9fd0f01ddab9403efe0951c5e4ec3034b8d3510eea39317518d
hovercard-subject-tagissue:2958637592
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/systemd/python-systemd/143/issue_layout
twitter:imagehttps://opengraph.githubassets.com/10c48acce0cd8cafc8dccb7a5f549b618bb5ebde840b692a7a045b8eb02d334d/systemd/python-systemd/issues/143
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/10c48acce0cd8cafc8dccb7a5f549b618bb5ebde840b692a7a045b8eb02d334d/systemd/python-systemd/issues/143
og:image:altEnv: $ python3 --version Python 3.11.2 $ systemctl --version systemd 252 (252.36-1~deb12u1) +PAM +AUDIT +SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesebres
hostnamegithub.com
expected-hostnamegithub.com
None5818716c93c6a2925b815402541a32814e43a7b1261c322b0c2df75224289566
turbo-cache-controlno-preview
go-importgithub.com/systemd/python-systemd git https://github.com/systemd/python-systemd.git
octolytics-dimension-user_id1918868
octolytics-dimension-user_loginsystemd
octolytics-dimension-repository_id38590109
octolytics-dimension-repository_nwosystemd/python-systemd
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id38590109
octolytics-dimension-repository_network_root_nwosystemd/python-systemd
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasef4bb89367ca678f057d79b1abc45d6675b1bd5b2
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/systemd/python-systemd/issues/143#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsystemd%2Fpython-systemd%2Fissues%2F143
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsystemd%2Fpython-systemd%2Fissues%2F143
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=systemd%2Fpython-systemd
Reloadhttps://github.com/systemd/python-systemd/issues/143
Reloadhttps://github.com/systemd/python-systemd/issues/143
Reloadhttps://github.com/systemd/python-systemd/issues/143
Please reload this pagehttps://github.com/systemd/python-systemd/issues/143
systemd https://github.com/systemd
python-systemdhttps://github.com/systemd/python-systemd
Notifications https://github.com/login?return_to=%2Fsystemd%2Fpython-systemd
Fork 77 https://github.com/login?return_to=%2Fsystemd%2Fpython-systemd
Star 521 https://github.com/login?return_to=%2Fsystemd%2Fpython-systemd
Code https://github.com/systemd/python-systemd
Issues 26 https://github.com/systemd/python-systemd/issues
Pull requests 3 https://github.com/systemd/python-systemd/pulls
Actions https://github.com/systemd/python-systemd/actions
Models https://github.com/systemd/python-systemd/models
Security and quality 0 https://github.com/systemd/python-systemd/security
Insights https://github.com/systemd/python-systemd/pulse
Code https://github.com/systemd/python-systemd
Issues https://github.com/systemd/python-systemd/issues
Pull requests https://github.com/systemd/python-systemd/pulls
Actions https://github.com/systemd/python-systemd/actions
Models https://github.com/systemd/python-systemd/models
Security and quality https://github.com/systemd/python-systemd/security
Insights https://github.com/systemd/python-systemd/pulse
#144https://github.com/systemd/python-systemd/pull/144
SIGSEGV using journal.Reader, thread safety issue?https://github.com/systemd/python-systemd/issues/143#top
#144https://github.com/systemd/python-systemd/pull/144
https://github.com/sebres
sebreshttps://github.com/sebres
on Mar 30, 2025https://github.com/systemd/python-systemd/issues/143#issue-2958637592
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.