fix: raise instead of segfaulting when OcTree/ColorOcTree.read() gets a bad path - #70
Conversation
… a bad path octomap's C++ AbstractOcTree::read() returns NULL when the path is missing or unreadable. The wrappers assigned that straight to thisptr, so the next method call dereferenced NULL and crashed the interpreter with SIGSEGV. NULL-check after read() and raise a Python exception (FileNotFoundError for a missing path, OSError for an unreadable/corrupt one, ValueError for bad serialized bytes). Covers both OcTree and ColorOcTree. Closes #68
7bd6636 to
46b6e0c
Compare
Verdict: Rebased onto current Verified the fix end-to-end: rebuilt the extension and ran the new read-error tests (OcTree + ColorOcTree, missing path and corrupt file) — all pass. The NULL-pointer segfault is now turned into Code review found no correctness issues: Ready for your review and merge. |
OcTree.read()/ColorOcTree.read()segfaulted instead of raising when handed a missing or unreadable path (#68). octomap's C++AbstractOcTree::read()returnsNULLin that case; the wrappers assigned it straight tothisptr, so the next method call dereferencedNULLand took down the interpreter with SIGSEGV.Now the wrappers NULL-check after
read()and raise a Python exception:FileNotFoundErrorfor a missing path,OSErrorfor an unreadable/corrupt file, andValueErrorfor bad serialized bytes. BothOcTreeandColorOcTreego through one shared helper.Test plan
octomap.OcTree.read("/nonexistent.ot").getTreeType()now raisesFileNotFoundError(exit 0) instead of exit 139test_read_missing_path_raisesandtest_read_unreadable_file_raisesintests/octomap_test.pyandtests/color_octree_test.pyuv run pytest tests/— 40 passeduv run ruff checkon the touched tests — cleanCloses #68