Skip to content

CI: Fix Segmentation error on module shutdown#528

Merged
stlehmann merged 1 commit into
masterfrom
fix-segfault-2
Jun 7, 2026
Merged

CI: Fix Segmentation error on module shutdown#528
stlehmann merged 1 commit into
masterfrom
fix-segfault-2

Conversation

@stlehmann

@stlehmann stlehmann commented Jun 7, 2026

Copy link
Copy Markdown
Owner

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.

…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>
@stlehmann stlehmann merged commit 8abdc34 into master Jun 7, 2026
7 checks passed
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 27101638500

Coverage at 93.347% (no base build to compare)

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 11514
Covered Lines: 10748
Line Coverage: 93.35%
Coverage Strength: 0.93 hits per line

💛 - Coveralls

@stlehmann stlehmann deleted the fix-segfault-2 branch June 7, 2026 19:05
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI: Segmentation Faults in Github Actions

2 participants