This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/78387] OpenMP segfault/stack size exceeded writing to internal file


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78387

--- Comment #10 from Jim Wilson <wilson at gcc dot gnu.org> ---
newunit_stack needs to be allocated dynamically, just like the newunits array.

I modified libgfortran to compute the highest value of newunit_tos, and print
it when the program exits.  I set NEWUNIT_STACK_SIZE to 128 so I could go up to
128 threads.

weathertop:2188$ OMP_NUM_THREADS=8 ./a.out 2> /dev/null
newunit_tos_max = 8
weathertop:2188$ OMP_NUM_THREADS=16 ./a.out 2> /dev/null
newunit_tos_max = 16
weathertop:2189$ OMP_NUM_THREADS=32 ./a.out 2> /dev/null
newunit_tos_max = 32
weathertop:2190$ OMP_NUM_THREADS=64 ./a.out 2> /dev/null
newunit_tos_max = 64
weathertop:2191$ OMP_NUM_THREADS=128 ./a.out 2> /dev/null
newunit_tos_max = 128
Segmentation fault (core dumped)
weathertop:2192$

So the size of newunit stack depends on the number of threads, and can be any
number.  If you don't want to put a hard limit of the number of threads that
gfortran can support, then you need to dynamically allocate it.

There is some variation from one run to the next, so using 16 threads doesn't
guarantee failure, and using 8 threads doesn't guarantee success.

weathertop:2192$ OMP_NUM_THREADS=8 ./a.out 2> /dev/null
newunit_tos_max = 8
weathertop:2193$ OMP_NUM_THREADS=8 ./a.out 2> /dev/null
newunit_tos_max = 8
weathertop:2193$ OMP_NUM_THREADS=8 ./a.out 2> /dev/null
newunit_tos_max = 8
weathertop:2193$ OMP_NUM_THREADS=8 ./a.out 2> /dev/null
newunit_tos_max = 8
weathertop:2193$ OMP_NUM_THREADS=8 ./a.out 2> /dev/null
newunit_tos_max = 3
weathertop:2193$ OMP_NUM_THREADS=8 ./a.out 2> /dev/null
newunit_tos_max = 8
weathertop:2193$ OMP_NUM_THREADS=8 ./a.out 2> /dev/null
newunit_tos_max = 5
weathertop:2193$ OMP_NUM_THREADS=8 ./a.out 2> /dev/null
newunit_tos_max = 8
weathertop:2193$ OMP_NUM_THREADS=8 ./a.out 2> /dev/null
newunit_tos_max = 8
weathertop:2193$

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]