Refactor C/Fortran interfaces and enforce non-executable stack#125
Refactor C/Fortran interfaces and enforce non-executable stack#125williamjameshandley merged 5 commits intomasterfrom
Conversation
• Added the linker flag "-Wl,-z,noexecstack" in Makefile_gnu to disable executable stacks for improved security. • In src/polychord/interfaces.F90: move all functions defined internally in contains functions to module-level definitions with module-level variables. This fixes the bug found in #124 which has arisen for glibc 2.41 which does not allow executable stack calls
lukashergt
left a comment
There was a problem hiding this comment.
OK, an hours marathon vibing with o3-mini high eventually revealed the problem to be a combination of needing to add some linker flags, and a re-write of the interfaces so that it does not define functions within a function's contains section.
Cool, nice to see that I wasn't too far off with my link from #124, which addresses the issue with nested functions.
This PR indeed fixes my install issue, and python run_pypolychord.py now runs without issue.
However, since this so far only modifies interfaces.F90, but I stumbled upon that little X in both interfaces.o and maximiser.o (see the last paragraph in my first post in #124), I dug a bit further. There are indeed nested functions in maximiser.F90 as well, and when adding settings.maximise = True to run_pypolychord.py, then it will segfault the moment it starts trying to maximise the likelihood. So I guess the same needs to be done for maximiser.F90.
- Moved nested func() from do_maximisation contains section to module-level maximisation_func() - Added module-level variables (func_settings, func_posterior, stored_loglikelihood, stored_prior) - Used procedure pointers with save attribute to maintain function context - Completes fix for Issue #124 alongside interfaces.F90 changes - Eliminates all nested functions that cause executable stack requirements with glibc 2.41+ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Version 1.22.2 includes: - Fixed maximiser segfaults on Arch Linux (glibc 2.41+) by eliminating nested functions - Fixed Fortran write statement comma formatting issues - Added Python 3.12 support and updated CI to test Python 3.8-3.12 - Complete Arch Linux compatibility for modern systems 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
…hord#125) * Refactor C/Fortran interfaces and enforce non-executable stack • Added the linker flag "-Wl,-z,noexecstack" in Makefile_gnu to disable executable stacks for improved security. • In src/polychord/interfaces.F90: move all functions defined internally in contains functions to module-level definitions with module-level variables. This fixes the bug found in PolyChord#124 which has arisen for glibc 2.41 which does not allow executable stack calls * Fix maximiser.F90 nested function causing segfaults on Arch Linux - Moved nested func() from do_maximisation contains section to module-level maximisation_func() - Added module-level variables (func_settings, func_posterior, stored_loglikelihood, stored_prior) - Used procedure pointers with save attribute to maintain function context - Completes fix for Issue PolyChord#124 alongside interfaces.F90 changes - Eliminates all nested functions that cause executable stack requirements with glibc 2.41+ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * Bump version to 1.22.2 Version 1.22.2 includes: - Fixed maximiser segfaults on Arch Linux (glibc 2.41+) by eliminating nested functions - Fixed Fortran write statement comma formatting issues - Added Python 3.12 support and updated CI to test Python 3.8-3.12 - Complete Arch Linux compatibility for modern systems 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
• Added the linker flag "-Wl,-z,noexecstack" in Makefile_gnu to disable executable stacks for improved security.
• In src/polychord/interfaces.F90:
move all functions defined internally in contains functions to module-level definitions with module-level variables.
This fixes the bug found in #124 which has arisen for glibc 2.41 which does not allow executable stack calls