Skip to content

Conversation

@dgburr
Copy link
Contributor

@dgburr dgburr commented Oct 23, 2025

The switch to thread-local contexts in #1419 stores a pointer to the newly created PJ_CONTEXT using Thread Specific Storage. However the value stored in TSS is not cleared when the PJ_CONTEXT is destroyed, meaning that a subsequent call to pyproj_context_create() will return a pointer to an invalid PJCONTEXT, leading to a segmentation fault.

My specific use case is in a multithreaded QT app with symptoms similar to #1509. However this issue can occur in any multithreaded app which performs multiple calls to pyproj_context_create() from the same thread.

  • [❌] Tests added
  • [✅] Fully documented, including history.rst for all changes and api/*.rst for new API

@snowman2 snowman2 added the bug label Oct 23, 2025
@snowman2 snowman2 added this to the 3.8.0 milestone Oct 23, 2025
@dgburr
Copy link
Contributor Author

dgburr commented Oct 24, 2025

@snowman2: should I also try to fix the linting issue in this PR, or should I create another one?

@snowman2
Copy link
Member

@snowman2: should I also try to fix the linting issue in this PR, or should I create another one?

A separate PR would be perfect.

@dgburr dgburr mentioned this pull request Oct 24, 2025
@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.84%. Comparing base (b78a50d) to head (d0fdb83).
⚠️ Report is 19 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1541      +/-   ##
==========================================
- Coverage   96.55%   95.84%   -0.72%     
==========================================
  Files          20       20              
  Lines        1827     1827              
==========================================
- Hits         1764     1751      -13     
- Misses         63       76      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@snowman2 snowman2 changed the title Clear CONTEXT_THREAD_KEY when destroying the PJ_CONTEXT BUG: Clear CONTEXT_THREAD_KEY when destroying the PJ_CONTEXT Oct 24, 2025
@snowman2 snowman2 merged commit 47c1454 into pyproj4:main Oct 24, 2025
18 checks passed
@snowman2
Copy link
Member

Thanks @dgburr 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants