Skip to content

Commit 090612b

Browse files
committed
fix: use -fno-trampolines to replace stack trampolines with register-based ones
The previous approach (-Wl,-z,noexecstack only) caused SIGSEGV during FT8 decode because the WSJT-X Fortran code uses internal procedure pointers at runtime which require trampolines. With the stack non-executable, those trampolines segfaulted. This commit uses a two-part fix: 1. -fno-trampolines (Fortran compile flag): instructs gfortran to use register-based trampolines instead of stack-based ones. GCC 9+ / aarch64 supports this natively. 2. -Wl,-z,noexecstack (linker flag): marks the SO as not requiring executable stack, which is now safe since trampolines no longer live on the stack. If the Fortran code has nested procedure arguments that cannot use register trampolines, CI will fail at compile or test time, indicating code restructuring is needed.
1 parent e9be6ec commit 090612b

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ if(UNIX AND NOT APPLE)
3838
add_compile_options(-fPIC -fvisibility=hidden)
3939
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-overflow -Wno-deprecated-declarations")
4040
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-stringop-overflow -Wno-deprecated-declarations")
41+
# Disable stack-based trampolines in Fortran code.
42+
# Required together with -Wl,-z,noexecstack: modern kernels (OrbStack 6.17+) reject
43+
# dlopen of .so with PT_GNU_STACK RWE. -fno-trampolines tells gfortran to use
44+
# register-based (non-stack) trampolines for internal procedure pointers.
45+
# If this causes a compile error, the Fortran code has nested procedure arguments
46+
# that require restructuring. GCC 9+ on aarch64 supports this without libffi.
47+
add_compile_options($<$<COMPILE_LANGUAGE:Fortran>:-fno-trampolines>)
4148
elseif(APPLE)
4249
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -Wno-deprecated-declarations -Wno-unqualified-std-cast-call")
4350
elseif(WIN32 AND CMAKE_CXX_COMPILER_ID MATCHES "GNU")

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wsjtx-lib",
3-
"version": "1.2.2",
3+
"version": "1.2.3",
44
"description": "Node.js C++ extension for WSJTX digital radio protocol library",
55
"type": "module",
66
"main": "dist/src/index.js",

0 commit comments

Comments
 (0)