Replies: 1 comment
-
It appears to have been a compiler problem where the compiler for the C++ test & the compiler for the whole codebase with nanobind wrapping wasn't the same. Turns out calling VTK methods compiled with llvm from a gcc code leads to completely random behaviors. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone, hi @wjakob !
I hope everyone is well.
I am coming here because I am completely stuck with a behavior that I do not understand.
I am working on a C++ code with a Python wrapper - so far, with nanobind documentation, I managed to link everything as I wanted and everything runs as expected.
Now, I need to add VTK capabilities to the C++ code ... and I cannot make it work.
For reference, I downloaded the VTK 9.2.6 tarball from here, and I did not personalize the install at all but just ran
mkdir build && cd build && cmake .. && make -j8
.I downloaded the
FindAllArrayNames
example from VTK website - see here. Since the code is small, and for reference, I'll copy-paste it here :The example compiles and works completely fine: I used a VTK file that I own, and this example yield the correct results:
Now, in my C++ codebase, I created a new very simple class:
where the constructor contains the same code as the
FindAllArrayNames
example:and the binding is also very simple:
And now, in a test Python script if I do:
I get wrong results (regarding the pointdata / celldata arrays), and then I get a segfault:
lldb
reveals that the crash happens there :int dataTypeID = polydata->GetPointData()->GetArray(i)->GetDataType();
and somehow it makes sense because there are no PointData fields, so accessing the arrays should fail.
But why is reading the same file directly in C++, or in C++ through a Python binding, with the same code, not producing the same results ? Has anyone seen such a behavior before ?
Note that the
vtk
package is not installed in the python virtual env.Thank you very much for your support !! 🙏
Beta Was this translation helpful? Give feedback.
All reactions