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

Py_finalize and segmentation fault - Running multiple routines #23

Closed
wilsoniain opened this issue Apr 28, 2020 · 2 comments
Closed

Py_finalize and segmentation fault - Running multiple routines #23

wilsoniain opened this issue Apr 28, 2020 · 2 comments

Comments

@wilsoniain
Copy link

wilsoniain commented Apr 28, 2020

Calling a forpy subroutine multiple times results in a segmentation fault. This happens when the second instance of calling forpy_initialize() occurs.

Based on discussion here: #1
Is this related to requiring multiple interpreters / threading support?

Or, also related to operation of py_finalize?

Bugs and caveats: The destruction of modules and objects in modules is done in random order; this may cause destructors (__del__() methods) to fail when they depend on other objects (even functions) or modules. Dynamically loaded extension modules loaded by Python are not unloaded. Small amounts of memory allocated by the Python interpreter may not be freed (if you find a leak, please report it). Memory tied up in circular references between objects is not freed. Some memory allocated by extension modules may not be freed. Some extensions may not work properly if their initialization routine is called more than once; this can happen if an application calls Py_Initialize() and Py_Finalize() more than once.

Any help appreciated.

@wilsoniain
Copy link
Author

wilsoniain commented Apr 28, 2020

Based on the above py_finalize caveat, it seems the best solution is to call py_initialize and py_finalize in from their own individual subroutines. This avoids multiple calls to py_initialize and the resulting segmentation fault.

@ylikx
Copy link
Owner

ylikx commented Apr 28, 2020

Hi, the segmentation fault is due to a bug in numpy, finalizing and reinitializing is not possible with numpy. I recommend calling py_finalize once at the end of your program. See #10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants