[Bug fortran/120260] New: dyld runtime error for gfortran code on Mac OS X Sequoia 15.4

2025-05-13 Thread markus.winterer--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120260

Bug ID: 120260
   Summary: dyld runtime error for gfortran code on Mac OS X
Sequoia 15.4
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: markus.winte...@uni-due.de
  Target Milestone: ---

I discovered the following problem using a scientific code to perform Reverse
Monte Carlo simulations ('rmcxas') compiled using gcc/gfortran 14.2.0 (Xcode
including command line tools has been installed) on Mac OS Sequoia 15.4 on an
Apple MacBook Air with M4 processor when starting the software:

dyld[10154]: dyld cache '(null)' not loaded: syscall to map cache into shared
region failed
dyld[10154]: Library not loaded: /usr/lib/libSystem.B.dylib
 Referenced from: <0144F82E-003C-37A9-A544-9AE6336E549B>
/Users/markuswinterer/bin/rmcxas
 Reason: tried: '/usr/lib/libSystem.B.dylib' (no such file),
'/System/Volumes/Preboot/Cryptexes/OS/usr/lib/libSystem.B.dylib' (no such
file), '/usr/lib/libSystem.B.dylib' (no such file, no dyld cache),
'/usr/local/lib/libSystem.B.dylib' (no such file)
zsh: abort  rmcxas

The problem occurs only every 5th time the rmcxas code is started.

Help would be highly appreciated.

[Bug target/120260] dyld runtime error for gfortran code on Mac OS X Sequoia 15.4

2025-05-17 Thread markus.winterer--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120260

--- Comment #2 from Markus Winterer  ---
I could not find a simple solution to the problem such as a compiler option,
instead there seems to be a limit of about 2 GByte static memory at which
programs no longer run reliably although the physically available memory is
much larger (in my case 24 GByte). However, dynamic allocation of memory (by
change the Fortran code) seems to eliminate the problem.

Here I present the results of two similar testprograms generating the same
result but using either static or dynamic memory allocation for a 2D array
(matrix).

The small testprogram teststatic generates a similar behavior than the rmcxas
code: only sometime starting, otherwise failing with the error code. 

Although this will help only after recoding part of the program, I hope it will
also be useful for other users of fortran legacy codes on Apple Mac computers
withs ARM/Silicon CPUs and recent  operating systems.

./teststatic
dyld[4001]: dyld cache '(null)' not loaded: syscall to map cache into shared
region failed
dyld[4001]: Library not loaded: /usr/lib/libSystem.B.dylib
  Referenced from: <68776642-137C-37BD-A260-F21A304027E6>
/Users/markuswinterer/Documents/2025/25may/fortran_test/teststatic
  Reason: tried: '/usr/lib/libSystem.B.dylib' (no such file),
'/System/Volumes/Preboot/Cryptexes/OS/usr/lib/libSystem.B.dylib' (no such
file), '/usr/lib/libSystem.B.dylib' (no such file, no dyld cache),
'/usr/local/lib/libSystem.B.dylib' (no such file)
zsh: abort  ./teststatic

   program teststatic

   implicit none
   integer i,j,m,l,k
   parameter(m=16200)
   real*8 a(m,m)

   write(*,*) 'array dimension l, k: '
   read (*,*) l,k

   do i=1,l
do j=1,k
 a(i,j)=real(i+j-1)
enddo
   enddo

   call out(m,l,k,a)

   end 

   subroutine out(m,l,k,a)
   implicit none
   integer i,j,m,l,k
   real*8 a(m,m)

   open(20,file='teststatic.dat',status='unknown')
do i =1,l
 write(20,*)(int(a(i,j)),j=1,k)
enddo
   close(20,status='keep')

   return
   end

Using the "size" command:

size teststatic

__TEXT  __DATA  __OBJC  others  dec hex
16384   2099527680  0   429564  6394544128  17d25

shows a size of more than 2GByte memory.

Running teststatic with m = n = 16200 uses a similar memory (RSS) according to
the "ps" command

ps -vc
  PID STAT  TIME  SL  RE PAGEIN  VSZRSS   LIM TSIZ  %CPU %MEM
COMMAND
 3991 R+ 0:02.34   0   0  0 412787136 2052224 -0  99,3  8,2
teststatic


The small testprogram testallocate generates no error code and allows the
dynamic memory allocation:

   program testallocate

   implicit none
   integer i,j,m,n
   real*8, dimension(:,:), allocatable :: a

   write(*,*) 'array dimension m, n: '
   read (*,*) m,n

   allocate(a(m,n))

   write(*,*) shape(a)

   do i=1,m
do j=1,n
 a(i,j)=real(i+j-1)
enddo
   enddo

   call out(m,n,a)

   deallocate(a)

   end 

   subroutine out(m,n,a)
   implicit none
   integer i,j,m,n
   real*8 a(m,n)

   open(20,file='testallocate.dat',status='unknown')
do i =1,m
 write(20,*)(int(a(i,j)),j=1,n)
enddo
   close(20,status='keep')

   return
   end

Using the "size" command:

size testallocate
__TEXT  __DATA  __OBJC  others  dec hex
16384   0   0   429564  4295016448  1c000

shows a the us of no memory when not running.

Running testallocate with m = n = 16200 uses a identical memory (RSS) according
to the "ps" command than teststatic

ps -vc
  PID STAT  TIME  SL  RE PAGEIN  VSZRSS   LIM TSIZ  %CPU %MEM
COMMAND
 3972 R+ 0:02.60   0   0  0 412787152 2052224 -0  99,7  8,2
testallocate

But memory allocation is dynamic and the program always starts with no error.