Skip to content
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

Dlite v0.5.24 causes segmentation fault in linux for pytest startup #327

Open
CasperWA opened this issue Dec 5, 2024 · 5 comments
Open
Labels
BLOCKING This issue/PR is blocking further development dependencies Issue or PR related to dependencies/requirements

Comments

@CasperWA
Copy link
Contributor

CasperWA commented Dec 5, 2024

See for example this run or this run.

@CasperWA CasperWA added BLOCKING This issue/PR is blocking further development dependencies Issue or PR related to dependencies/requirements labels Dec 5, 2024
@jesper-friis
Copy link
Contributor

This is not a bug in DLite, but caused by the changes in commit a24efd4. Commit a24efd4 should be fixed or revoked.

Checking out commit fdd527d does not result in segfault.

One part of the issue is pytest that during its collection phase loads modules without importing them properly.
This is a design bug. The test framework should be adapted to the code to test, not the other way around.

But the real problem is commit fdd527d.
Until commit fdd527d the SWIG-generated C-function SWIG_init() was called even during the pytest collection phase.

With the changes in commit a24efd4, SWIG_init() is not called during the pytest collection phase. That results in a segfault when any other SWIG-generated function is called. This happens in the SWIG-generated API and has nothing to do with DLite.

@CasperWA
Copy link
Contributor Author

I am getting the same segmentation fault in other repositories for DLite version later than v0.5.23 when running pytest and dlite is imported and used.

Until a solution is found for not having DLite result in segmentation faults, I cannot see a reason to upgrade.

If the solution can be found outside of changing the internals or build of DLite that is fine, but a universal solution should be found that does not result in segmentation faults for the later versions.

@francescalb
Copy link
Contributor

For some reason the segmenatition fault does not occur when the line about treating warnings as errors in the pytest settings in pyproject is commented out.

Some other issues pop up though.

@francescalb
Copy link
Contributor

This might be relevant:
swig/swig#2881

When using Dlite-Pyhon==0.5.24 I get the followin warning:
=========================================================================== warnings summary ===========================================================================
:241
:241: DeprecationWarning: builtin type SwigPyPacked has no module attribute

And a search on that points me to the above isse. Support for Swig 4.3.0 was introduced in DLite-Pyton==0.5.24. Apparently there is an issue there that we are not the only ones encountering. They have a milestone on fixing this for the next release.

Does pytest just shut down everything in a manner so that DLite is not able to shut down properly and causes a segmantation fault, if warnings> errors?

@CasperWA
Copy link
Contributor Author

Well spotted and debugged @francescalb ! 😃 Raising Python warnings to error level definitely should not cause segmentation faults. So there seems to be some race conditions happening concerning SWIG, DLite and their interaction with the Python interpreter executing pytest, wherein the exception at the SWIG level (i.e., when the DeprecationWarning happens) is not handled properly before a "shutdown".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BLOCKING This issue/PR is blocking further development dependencies Issue or PR related to dependencies/requirements
Projects
None yet
Development

No branches or pull requests

3 participants