Skip to content

Commit 88f8553

Browse files
committed
test: fix ABI conflict stress test by using loader.execute()
THE INSIGHT: Running a raw `import numpy` directly in the host process permanently maps the C-extension (.so) into memory via `dlopen`. Once mapped, it is impossible to unload or swap in the same process. THE FIX: Switched the stress test to use `loader.execute(...)` instead of raw imports. WHY IT MATTERS & THE CAVEAT: `loader.execute` is vastly safer than raw imports when dealing with C-extensions. If Omnipkg detects a severe ABI conflict, `loader.execute` can actually heal the environment by delegating the execution payload to a daemon worker. CRITICAL LIMITATION: You fundamentally cannot load multiple highly conflicting C-extensions (like different numpy ABIs) simultaneously in a single Python process. Delegation to a clean subprocess/daemon is the *only* way to execute them safely, and `loader.execute` provides the exact bridge to do that.
1 parent e70597c commit 88f8553

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/tests/test_loader_stress_test.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,13 +434,19 @@ def go_deeper_legacy(level):
434434

435435
safe_print(_(' {}{} Level {}: numpy {}').format(indent, '🔻' * level, level, ver))
436436

437-
with omnipkgLoader(f"numpy=={ver}", quiet=False, worker_fallback=True):
437+
with omnipkgLoader(f"numpy=={ver}", worker_fallback=True) as loader:
438+
try:
439+
if loader._worker_mode:
440+
result = loader.execute(
441+
"import numpy as np\nimport sys\nsys.stdout.write(np.__version__)"
442+
)
443+
got = result.get("stdout", "").strip() or "⚠️ no output"
444+
else:
445+
import numpy as np
446+
got = np.__version__
438447
# Import may fail or return wrong version if a cross-ABI switch
439448
# encountered a .so mapping conflict. Catch and continue — this
440449
# is the known limitation we are demonstrating.
441-
try:
442-
import numpy as np
443-
got = np.__version__
444450
except Exception as e:
445451
abi_misses += 1
446452
got = f"⚠️ import failed ({type(e).__name__}: {str(e)})"

0 commit comments

Comments
 (0)