Compile abort buffer shared lib#362
Open
danbeibei wants to merge 6 commits into
Open
Conversation
16429a5 to
f470c41
Compare
Contributor
Author
|
@jameskermode is this something you would want to merge? |
Owner
|
yes, in principle, sorry for th slow response - just a bit overstreched with teaching this term. Will get to this as soon as I can. |
Owner
|
I had a look and in principal will be happy to merge, just a couple of things to fix first:
|
f470c41 to
fe22371
Compare
Contributor
Author
|
Thank you for the the review. I have updated the commits.
|
f9198f9 to
3ad0ffe
Compare
added 4 commits
February 23, 2026 14:44
3ad0ffe to
e1c6e10
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When many routines are wrapped, compiling the wrapper can take a long time. In our build system, we have set up a way to wrap modules separately, then combine the generated wrappers at a later stage. This allows for parallel compilation and is much faster. However, this approach does not work with the current implementation of the error handler that uses the setjmp/longjmp logic.
Currently, a
environment_bufferand anabort_messagevariable are declared for each separate invocation of f2py-f90wrap, with multiple memory spaces allocated for the same symbols. Combining the shared libraries produced by several f2py-f90wrap invocations creates conflicts and results in segmentation faults.The fix I suggest is to compile a shared library that defines those variables as extern, and then link the f2py-f90wrap generated library with this shared library. This ensures a single address space is allocated to handle the setjmp/longjmp logic. This library is compiled at f90wrap build time and is installed with the f90wrap package.
The example provided shows how we compile in parallel and combine the generated modules afterward. It also reproduces the segmentation fault with the current implementation.
The
environment_bufferandabort_messagevariables were already declared as extern but were not actually used in that way, which suggests that the issue had already been anticipated, perhaps you had a different implementation in mind?