From c6b047285419f8986fae962e2734a01522be7ef7 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Wed, 23 Apr 2025 10:56:14 +0200 Subject: [PATCH 1/4] fix segfault in EmbreeScene.__dealloc__, due to use-after-free of EmbreeDevice pytest + gdb backtrace output, with embree v2.17.7 compiled with `-DCMAKE_BUILD_TYPE=RelWithDebInfo`: ============================= test session starts ============================== platform linux -- Python 3.12.9, pytest-8.3.5, pluggy-1.5.0 -- /nix/store/fqm9bqqlmaqqr02qbalm1bazp810qfiw-python3-3.12.9/bin/python3.12 cachedir: .pytest_cache rootdir: /build/source configfile: pyproject.toml collected 13 items tests/test_intersection.py::TestPyEmbree::test_pyembree_should_be_able_to_create_a_device_if_not_provided PASSED [ 7%] tests/test_intersection.py::TestPyEmbree::test_pyembree_should_be_able_to_create_a_scene PASSED [ 15%] tests/test_intersection.py::TestPyEmbree::test_pyembree_should_be_able_to_create_several_scenes PASSED [ 23%] tests/test_intersection.py::TestPyEmbree::test_pyembree_should_be_able_to_display_embree_version PASSED [ 30%] tests/test_intersection.py::TestIntersectionTriangles::test_intersect PASSED [ 38%] Thread 1 "python3.12" received signal SIGSEGV, Segmentation fault. 0x0000000000000000 in ?? () #0 0x0000000000000000 in ?? () #1 0x00007fffb1e7e76f in embree::APIBuffer::free (this=0x8cb7b0) at /build/source/kernels/common/buffer.h:212 #2 embree::APIBuffer::~APIBuffer (this=0x8cb7b0, __in_chrg=) at /build/source/kernels/common/buffer.h:137 #3 std::__new_allocator >::destroy > (this=0x9357a8, __p=0x8cb7b0) at /nix/store/qs54xir5n4vhhbi22aydbkvyyq4v8p0l-gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/new_allocator.h:198 #4 embree::vector_t, std::allocator > >::clear (this=0x9357a8) at /build/source/kernels/common/../../common/sys/vector.h:148 i = 0 #5 embree::vector_t, std::allocator > >::~vector_t (this=0x9357a8, __in_chrg=) at /build/source/kernels/common/../../common/sys/vector.h:42 #6 embree::TriangleMesh::~TriangleMesh (this=0x9356b0, __in_chrg=) at /build/source/kernels/common/scene_triangle_mesh.h:25 #7 embree::avx::TriangleMeshISA::~TriangleMeshISA (this=0x9356b0, __in_chrg=) at /build/source/kernels/common/scene_triangle_mesh.h:220 #8 embree::avx::TriangleMeshISA::~TriangleMeshISA (this=0x9356b0, __in_chrg=) at /build/source/kernels/common/scene_triangle_mesh.h:220 #9 0x00007fffb174744f in embree::Scene::~Scene (this=0xb45dc0, __in_chrg=) at /build/source/kernels/common/scene.cpp:594 i = 0 i = #10 0x00007fffb17475e9 in embree::Scene::~Scene (this=0xb45dc0, __in_chrg=) at /build/source/kernels/common/scene.cpp:599 i = #11 0x00007ffff3565de8 in __pyx_pf_8pyembree_12rtcore_scene_11EmbreeScene_4__dealloc__ (__pyx_v_self=0x7fffb3055e00) at pyembree/rtcore_scene.cpp:3957 (ported from e64a2fab759c7eb5b7be4b632441505a87ab3ba9) --- embreex/rtcore_scene.pyx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/embreex/rtcore_scene.pyx b/embreex/rtcore_scene.pyx index 87424e4..8929f07 100644 --- a/embreex/rtcore_scene.pyx +++ b/embreex/rtcore_scene.pyx @@ -28,9 +28,9 @@ cdef void error_printer(const rtc.RTCError code, const char *_str) noexcept: cdef class EmbreeScene: def __init__(self, rtc.EmbreeDevice device=None, robust=False): if device is None: - # We store the embree device inside EmbreeScene to avoid premature deletion - self.device = rtc.EmbreeDevice() - device = self.device + device = rtc.EmbreeDevice() + # We store the embree device inside EmbreeScene to avoid premature deletion + self.device = device flags = RTC_SCENE_STATIC if robust: # bitwise-or the robust flag From ae8d3e293035f3ff21fb903603f8e7d0ee619cf5 Mon Sep 17 00:00:00 2001 From: Michael Dawson-Haggerty Date: Wed, 22 Oct 2025 13:39:43 -0400 Subject: [PATCH 2/4] try updating cibw --- .github/workflows/wheels.yml | 8 ++++---- pyproject.toml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 4091d36..0e3f176 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -8,16 +8,16 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, windows-latest, macos-13] + os: [ubuntu-latest, windows-latest, macos-latest, macos-15-intel] steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 name: Install Python with: - python-version: '3.11' + python-version: '3.13' - name: Install cibuildwheel run: | - python -m pip install cibuildwheel==2.22.0 + python -m pip install cibuildwheel==3.2.1 - name: Build wheel run: | python -m cibuildwheel --output-dir dist @@ -61,6 +61,6 @@ jobs: - name: Download Wheels uses: actions/download-artifact@v3 - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 + uses: pypa/gh-action-pypi-publish@release/v1.13.0 with: packages-dir: wheels \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 77afc32..3292cc2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta" [project] name = "embreex" -version = "2.17.7.post6" +version = "2.17.7.post7" requires-python = ">=3.8" dependencies = ["numpy"] @@ -32,7 +32,7 @@ find = {namespaces = false} embreex = ["*.pxd"] [tool.cibuildwheel] -skip = "pp* *i686 *-win32 *musllinux*" +skip = "*i686 *-win32 *musllinux*" manylinux-x86_64-image = "manylinux_2_28" before-test = "pip install pytest" test-command = "pytest -v {project}/tests" From 34721965e74233ce3b50ca666bce15fc5d422f00 Mon Sep 17 00:00:00 2001 From: Michael Dawson-Haggerty Date: Wed, 22 Oct 2025 13:41:28 -0400 Subject: [PATCH 3/4] outdated action --- .github/workflows/wheels.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 0e3f176..2dcbe95 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -21,7 +21,7 @@ jobs: - name: Build wheel run: | python -m cibuildwheel --output-dir dist - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: wheels path: dist/ @@ -41,7 +41,7 @@ jobs: run: | export V=$(python -c "print(next(iter(eval(L.split('=')[-1]) for L in open('pyproject.toml') if 'version =' in L)))") echo "tag=${V}" >> "$GITHUB_ENV" - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 - name: Create Release uses: ncipollo/release-action@v1 with: @@ -59,7 +59,7 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - name: Download Wheels - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@release/v1.13.0 with: From 9f14c01e57a3116afc9386a884ab25ae1471cde1 Mon Sep 17 00:00:00 2001 From: Michael Dawson-Haggerty Date: Wed, 22 Oct 2025 13:44:02 -0400 Subject: [PATCH 4/4] drop macos arm --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 2dcbe95..45a94a3 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -8,7 +8,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, windows-latest, macos-latest, macos-15-intel] + os: [ubuntu-latest, windows-latest, macos-15-intel] steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4