Commit e64246b
committed
fix(loader): detect linker-locked TF .so via /proc/self/maps; guard zombie purge
Problem: after loading TF 2.13.0 and exiting the context, a second
with-block requesting TF 2.12.0 would still activate in-process,
corrupting interpreter state and crashing.
Two root causes fixed in loader.py:
1. /proc/self/maps fallback for cext detection
The existing _tf_loaded_pids check requires omnipkg.isolation.patchers
to be imported first. In bare subprocesses (test runner, user scripts)
that module is never loaded, so _abi_so_mapped stayed False and the
loader fell through to in-process activation of the wrong version.
Fix: read /proc/self/maps directly — OS-level, survives sys.modules
purging, no import dependencies.
2. Zombie purge was wiping linker-locked TF modules
_aggressive_module_cleanup correctly preserved pywrap_tensorflow and
friends, but the POST-EXIT zombie scan (which checks __file__ for
.omnipkg_versions paths) then purged those same modules, leaving Load 2
with no Python layer for a still-mapped C backend — causing reinit
failures. Fix: zombie purge now skips all tensorflow.* modules when
pywrap_tensorflow is present in sys.modules, matching the same guard
already used by _aggressive_module_cleanup.
3. Graceful no-daemon path
When _abi_so_mapped=True but no daemon is available, execution
previously fell through to Strategy 1/2/3 (in-process activation).
Now returns self immediately with _abi_conflict_detected=True —
caller gets the already-loaded version, no crash, no corrupt state.
Also in this commit:
- refactor(tests): move src/tests/ → src/omnipkg/tests/ so the test
package lives inside the omnipkg namespace and does not pollute
site-packages for end users
- fix(pyproject.toml): update packages.find include to omnipkg.tests*
- chore(.gitignore): exclude __pycache__/ and *.pyc1 parent 981340d commit e64246b
20 files changed
Lines changed: 50 additions & 24 deletions
File tree
- src/omnipkg
- isolation
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
| 155 | + | |
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
431 | | - | |
432 | 431 | | |
433 | 432 | | |
434 | 433 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4085 | 4085 | | |
4086 | 4086 | | |
4087 | 4087 | | |
| 4088 | + | |
| 4089 | + | |
| 4090 | + | |
4088 | 4091 | | |
4089 | 4092 | | |
| 4093 | + | |
| 4094 | + | |
4090 | 4095 | | |
4091 | 4096 | | |
4092 | 4097 | | |
| |||
5719 | 5724 | | |
5720 | 5725 | | |
5721 | 5726 | | |
| 5727 | + | |
| 5728 | + | |
| 5729 | + | |
| 5730 | + | |
| 5731 | + | |
| 5732 | + | |
| 5733 | + | |
5722 | 5734 | | |
5723 | 5735 | | |
5724 | 5736 | | |
| |||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
0 commit comments