-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segmentation fault on pytest exit when creating a SerializableObjectWithMetadata #1474
Comments
When OTIO is built in debug mode, we get a little bit more details:
|
The fact that it crashes it metadata={} is given as an argument kind of suggests me it has to do with the round-trip in https://github.com/AcademySoftwareFoundation/OpenTimelineIO/blob/main/src/py-opentimelineio/opentimelineio-bindings/otio_utils.cpp#L99-L121. This part of the code is pretty painful to debug... |
Alright, with GDB atatched, we get this. The interesting part of that backtrace is:
Notice the |
Some more information: https://github.com/AcademySoftwareFoundation/OpenTimelineIO/blob/main/src/py-opentimelineio/opentimelineio/core/_core_utils.py#L61 is executed properly, which means that at least Also found pytest-dev/pyfakefs#693 which kind of means that pyfakefs can break stuff. Looking at the pyfakefs code, it seems extremely intrusive. |
By doing a small change, we can verify if diff --git a/src/py-opentimelineio/opentimelineio-bindings/otio_serializableObjects.cpp b/src/py-opentimelineio/opentimelineio-bindings/otio_serializableObjects.cpp
index b3338eb..4f37429 100644
--- a/src/py-opentimelineio/opentimelineio-bindings/otio_serializableObjects.cpp
+++ b/src/py-opentimelineio/opentimelineio-bindings/otio_serializableObjects.cpp
@@ -188,7 +188,8 @@ static void define_bases1(py::module m) {
py::class_<SOWithMetadata, SerializableObject,
managing_ptr<SOWithMetadata>>(m, "SerializableObjectWithMetadata", py::dynamic_attr())
.def(py::init([](std::string name, py::object metadata) {
- return new SOWithMetadata(name, py_to_any_dictionary(metadata));
+ auto asd = py_to_any_dictionary(metadata);
+ return new SOWithMetadata(name, asd);
}),
py::arg_v("name"_a = std::string()),
py::arg_v("metadata"_a = py::none()))
diff --git a/src/py-opentimelineio/opentimelineio-bindings/otio_utils.cpp b/src/py-opentimelineio/opentimelineio-bindings/otio_utils.cpp
index c327374..55ed8ea 100644
--- a/src/py-opentimelineio/opentimelineio-bindings/otio_utils.cpp
+++ b/src/py-opentimelineio/opentimelineio-bindings/otio_utils.cpp
@@ -102,7 +102,8 @@ static void py_to_any(py::object const& o, any* result) {
_value_to_any = core.attr("_value_to_any");
}
- result->swap(_value_to_any(o).cast<PyAny*>()->a);
+ py::object tmp = _value_to_any(o);
+ result->swap(tmp.cast<PyAny*>()->a);
}
AnyDictionary py_to_any_dictionary(py::object const& o) { Then in GDB:
So |
Stumbled over this issue today, and created a respective issue in pyfakefs. def test_create_clip(capsys, fs):
fs.clear_cache()
otio.core.SerializableObjectWithMetadata(
metadata={}
) |
Thanks! We will test this workaround to see if it helps. |
Alternatively, you could use a fixture without caching instead of import pytest
from pyfakefs.fake_filesystem_unittest import Patcher
@pytest.fixture
def fs_no_cache():
with Patcher(use_cache=False) as patcher:
yield patcher.fs
...
def test_empty_fs(fs_no_cache):
pass Caching is a performance feature that is only relevant if you run a larger number of tests with |
Ok, I've made a patch release, please check if your tests work with the current version! |
Nice, thanks @mrbean-bremen ! |
A user reported that there is a segmentation fault when running pytest + objects with metadata + the "fs" (fake filesystem) capture system.
Repro:
Output:
(The warning is related to our use of
imp
and appears to be a red herring)The text was updated successfully, but these errors were encountered: