[Bug fortran/51090] New: libgfortran main.c missing NULL check on return value from getenv()
joel at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Nov 11 00:06:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51090
Bug #: 51090
Summary: libgfortran main.c missing NULL check on return value
from getenv()
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: joel@gcc.gnu.org
PATH is not set in an RTEMS environment so getenv("PATH") is returning NULL.
Besides, there is no executable file on the target to do
_gfortrani_find_addr2line() on and this in runtime/main.c blows up.
void
find_addr2line (void)
{
#ifdef HAVE_ACCESS
#define A2L_LEN 10
char *path = getenv ("PATH");
size_t n = strlen (path);
It did not blow up before because the autoconf probe didn't find access(). I
went through addressing symbols RTEMS has but the autoconf probe didn't see.
I have attached a proposed solution. I haven't run every test but the first
few 100 are passing where the first test failed before.
Here is the backtrace.
getenv (name=0x8805dd30 "PATH")
at /users/joel/test-gcc/gcc-svn/newlib/libc/stdlib/getenv.c:90
90 return _findenv_r (_REENT, name, &offset);
(gdb)
87 {
(gdb) n
90 return _findenv_r (_REENT, name, &offset);
(gdb)
87 {
(gdb)
90 return _findenv_r (_REENT, name, &offset);
(gdb)
91 }
(gdb)
0x880036ec in _gfortrani_find_addr2line ()
(gdb)
Single stepping until exit from function _gfortrani_find_addr2line,
which has no line number information.
mips-core: 1 byte read to unmapped address 0x0 at 0x8804e7d4
Program received signal SIGBUS, Bus error.
0x8804e7d4 in strlen ()
More information about the Gcc-bugs
mailing list