CI: Fix Segmentation error on module shutdown#528
Merged
Conversation
…tdown When Connection objects are GC'd during Python interpreter shutdown, calling AdsPortCloseEx via adslib.so crashes (SIGSEGV / exit 139) because the ADS routing layer is already torn down. Guard __del__ with sys.is_finalizing() so the C library is not called during this phase; the OS reclaims sockets and file descriptors regardless. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Coverage Report for CI Build 27101638500Coverage at 93.347% (no base build to compare)Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
stlehmann
added a commit
that referenced
this pull request
Jun 7, 2026
Mirrors the existing try/except around clear_device_notifications(). If the connection is gone at GC time (e.g. interpreter shutdown, same class of problem fixed in #528), release_handle() would raise and produce an unraisable exception in the destructor. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
stlehmann
added a commit
that referenced
this pull request
Jun 7, 2026
…#261) (#529) * fix symbol info for function block properties with monitoring = call #261 * refactor: replace magic 0xF019 with named constant ADSIGRP_SYM_FB_PROP_CALL Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor: use _acquired_handle flag instead of index_group check in __del__ index_group == ADSIGRP_SYM_VALBYHND is true for any symbol using that access method, not just ones where get_handle() was called internally. The flag precisely tracks whether release_handle() is required on destruction. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: guard release_handle in __del__ against ADSError Mirrors the existing try/except around clear_device_notifications(). If the connection is gone at GC time (e.g. interpreter shutdown, same class of problem fixed in #528), release_handle() would raise and produce an unraisable exception in the destructor. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test: add tests for FB property symbol with monitoring=call Covers four scenarios using mocked adsGetSymbolInfo: - iGroup=0xF019 causes get_handle() and ADSIGRP_SYM_VALBYHND - normal symbols use offset directly, no handle acquired - handle is released via release_handle() on destruction - ADSError from release_handle() in __del__ is suppressed Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs: add changelog entry for FB property symbol fix (#261) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: David Glenck <dgl@climeworks.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #524
fix: skip adsPortCloseEx in Connection.del during interpreter shutdown
When Connection objects are GC'd during Python interpreter shutdown, calling AdsPortCloseEx via adslib.so crashes (SIGSEGV / exit 139) because the ADS routing layer is already torn down. Guard del with sys.is_finalizing() so the C library is not called during this phase; the OS reclaims sockets and file descriptors regardless.