I just want one that works. I even updated bookworm, then installed Trixie and still got the same error (except the number before the word Segmentation changes). All this code (case changes are mine) comes from tries with Chrome’s AI question answer (on 2 different days). It looks very simple.
I did find “Security update for GLIBC for a risk 1st noted in 2018 and an accepted alteration last year + a comment that the fix broke (old code). No comment about what code uses it. I have written lots of interoperable demo programs for functions and subroutines, but NEVER had a segmentation fault with them. I really don’t want to abandon the idea of a global module’s interoperable storage type is not currently doable.
How might I go about understanding where this segmentation comes from? [I don’t have any C program debugging experience beyond printf statements.]
$ cat fortran_module.f90
MODULE fortran_module
USE, INTRINSIC :: ISO_C_BINDING
IMPLICIT NONE
INTEGER(C_INT), BIND(C, name=“c_access_int”) :: fortran_int
CONTAINS
SUBROUTINE set_fortran_int(value) BIND(C, name=“set_fortran_int”)
INTEGER(C_INT), INTENT(IN) :: value
fortran_int = value
END SUBROUTINE set_fortran_int
END MODULE fortran_module
$ cat c_program.c
#include <stdio.h>
extern int c_access_int;
extern void set_fortran _int(int_value);
int main(void) {
printf(“Initial value of the Fortran integer: %d\n”, c_access_int);
c_access_int = 42;
printf(“Value after direct C modification: %d\n”, c_access_int);
set_fortran_int(99);
printf(“value after modification by Fortran subroutine: %d\n”, c_access_int);
return 0;
}
$ cat compile_link_and_run.bash
#! /bin/bash
gfortran -c fortran_module.f90
gcc -c c_program.c
gfortran c_program.o fortran_module.o -o mixed_program
./mixed_program
-------- output ------ of that
Initial value of the Fortran integer: 0
Value after direct C modification: 42
./compile_link_and_run.bash: line 5: 5087 Segmentation fault ./mixed_program
$nm -u mixed_program
w _ITM_deregisterTMCloneTable
w _ITM_registerTMCloneTable
w __cx_finalize@GLIBC_2.2.5
w __gmon_start
U __libc_start_main@GLIBC_2.34
U __ printf@GLIBC_2.2.5