This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libfortran/61035] New: Crash in getcwd intrinsic due to stack overflow
- From: "jb at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 02 May 2014 13:30:48 +0000
- Subject: [Bug libfortran/61035] New: Crash in getcwd intrinsic due to stack overflow
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61035
Bug ID: 61035
Summary: Crash in getcwd intrinsic due to stack overflow
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: libfortran
Assignee: unassigned at gcc dot gnu.org
Reporter: jb at gcc dot gnu.org
The example program below crashes (my stack size limit is 8 MiB).
program getcwd_overflow
implicit none
character(len=10485760) :: str ! 10 MiB
call getcwd(str)
print *, trim(str)
end program getcwd_overflow
The reason is that in libgfortran/intrinsics/getcwd.c we try to allocate space
for a NULL-terminated duplicate of the string on the stack.