[Bug fortran/78387] OpenMP segfault/stack size exceeded writing to internal file
wilson at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jun 28 18:58:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78387
Jim Wilson <wilson at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |wilson at gcc dot gnu.org
--- Comment #7 from Jim Wilson <wilson at gcc dot gnu.org> ---
The testcase can trigger the bug fixed in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81195
if the number of threads is high enough. It also triggers an unrelated problem
which gives the stack size exceeded error.
Looking at this issue, I see that in libgfortran/io/unit.c, the newunit_alloc
function starts with
newunits = xcalloc (16, 1);
newunit_size = 16;
and then if we need more of them, it does
newunit_size *= 2;
newunits = xrealloc (newunits, newunit_size);
However, for stash_internal_unit, we have as global definitions
#define NEWUNIT_STACK_SIZE 16
static gfc_saved_unit newunit_stack[NEWUNIT_STACK_SIZE];
and inside the function we have
if (newunit_tos >= NEWUNIT_STACK_SIZE)
When the testcase fails, newunit_size is 32. So we have allocated more units
than we can stash.
It looks like the fix is to change stash_internal_unit to dynamically resize
newunit_stack, same as the newunit_alloc function already does for newunits.
This appears related to bug 48587, which added the code to increase the size of
newunits array.
More information about the Gcc-bugs
mailing list