public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/51803] New: gfortran getcwd at startup
@ 2012-01-09 20:57 mrs at gcc dot gnu.org
  2012-01-10  7:21 ` [Bug libfortran/51803] " jb at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: mrs at gcc dot gnu.org @ 2012-01-09 20:57 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51803

             Bug #: 51803
           Summary: gfortran getcwd at startup
    Classification: Unclassified
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: mrs@gcc.gnu.org


This code:

  memset (buf, 0, sizeof (buf));
#ifdef HAVE_GETCWD
  cwd = getcwd (buf, sizeof (buf));
#else
  cwd = "";
#endif

  /* exe_path will be cwd + "/" + argv[0] + "\0" */
  path = malloc (strlen (cwd) + 1 + strlen (argv0) + 1);
  sprintf (path, "%s%c%s", cwd, DIR_SEPARATOR, argv0);
  exe_path = path;
  please_free_exe_path_when_done = 1;

from libgfortran/runtime/main.c:store_exe_path is bad.  getcwd can fail with a
0 return status.  I didn't have getdents wired up completely in my simulator,
and fortran fails everything in the testsuite because of it.  :-(

Should be something like:

#ifdef HAVE_GETCWD
  cwd = getcwd (buf, sizeof (buf));
  if (cwd == 0)
    cwd = "";
#else


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libfortran/51803] gfortran getcwd at startup
  2012-01-09 20:57 [Bug libfortran/51803] New: gfortran getcwd at startup mrs at gcc dot gnu.org
@ 2012-01-10  7:21 ` jb at gcc dot gnu.org
  2012-01-10 10:04 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jb at gcc dot gnu.org @ 2012-01-10  7:21 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51803

Janne Blomqvist <jb at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2012-01-10
         AssignedTo|unassigned at gcc dot       |jb at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1

--- Comment #1 from Janne Blomqvist <jb at gcc dot gnu.org> 2012-01-10 07:21:30 UTC ---
Confirmed. I'll fix it for 4.8, while the patch is trivial we're already in
stage 4 for 4.7.

Also, can you state your name so that you'll get the proper attribution in the
ChangeLog?


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libfortran/51803] gfortran getcwd at startup
  2012-01-09 20:57 [Bug libfortran/51803] New: gfortran getcwd at startup mrs at gcc dot gnu.org
  2012-01-10  7:21 ` [Bug libfortran/51803] " jb at gcc dot gnu.org
@ 2012-01-10 10:04 ` rguenth at gcc dot gnu.org
  2012-01-10 16:40 ` mrs at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-01-10 10:04 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51803

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-01-10 10:04:17 UTC ---
(In reply to comment #1)
> Confirmed. I'll fix it for 4.8, while the patch is trivial we're already in
> stage 4 for 4.7.

It's certainly fine for 4.7.

> Also, can you state your name so that you'll get the proper attribution in the
> ChangeLog?


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libfortran/51803] gfortran getcwd at startup
  2012-01-09 20:57 [Bug libfortran/51803] New: gfortran getcwd at startup mrs at gcc dot gnu.org
  2012-01-10  7:21 ` [Bug libfortran/51803] " jb at gcc dot gnu.org
  2012-01-10 10:04 ` rguenth at gcc dot gnu.org
@ 2012-01-10 16:40 ` mrs at gcc dot gnu.org
  2012-01-10 16:45 ` mrs at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mrs at gcc dot gnu.org @ 2012-01-10 16:40 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51803

--- Comment #3 from mrs at gcc dot gnu.org <mrs at gcc dot gnu.org> 2012-01-10 16:39:33 UTC ---
Mike Stump  <mikestump@comcast.net>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libfortran/51803] gfortran getcwd at startup
  2012-01-09 20:57 [Bug libfortran/51803] New: gfortran getcwd at startup mrs at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2012-01-10 16:40 ` mrs at gcc dot gnu.org
@ 2012-01-10 16:45 ` mrs at gcc dot gnu.org
  2012-01-11  7:35 ` jb at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mrs at gcc dot gnu.org @ 2012-01-10 16:45 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51803

--- Comment #4 from mrs at gcc dot gnu.org <mrs at gcc dot gnu.org> 2012-01-10 16:44:24 UTC ---
Oh, a related, but different bug would be, if getcwd isn't on the system, or
fails, I think "." might be better than "", as we form getcwd '/' argv[0], and
that doesn't make any sense as "" really.  ./a.out seems better than /a.out for
example.  I merely copied the bug from the other code path for uniformity, not
because I thought it was the right value.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libfortran/51803] gfortran getcwd at startup
  2012-01-09 20:57 [Bug libfortran/51803] New: gfortran getcwd at startup mrs at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2012-01-10 16:45 ` mrs at gcc dot gnu.org
@ 2012-01-11  7:35 ` jb at gcc dot gnu.org
  2012-01-11  7:48 ` jb at gcc dot gnu.org
  2012-01-12  9:59 ` jb at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jb at gcc dot gnu.org @ 2012-01-11  7:35 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51803

--- Comment #5 from Janne Blomqvist <jb at gcc dot gnu.org> 2012-01-11 07:34:22 UTC ---
Author: jb
Date: Wed Jan 11 07:34:16 2012
New Revision: 183090

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183090
Log:
PR 51803 Handle getcwd failure and lack of the function better.

2012-01-11  Janne Blomqvist  <jb@gcc.gnu.org>
            Mike Stump  <mikestump@comcast.net>
    PR libfortran/51803
    * runtime/main.c (store_exe_path): Handle getcwd failure and lack
    of the function better.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/runtime/main.c


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libfortran/51803] gfortran getcwd at startup
  2012-01-09 20:57 [Bug libfortran/51803] New: gfortran getcwd at startup mrs at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2012-01-11  7:35 ` jb at gcc dot gnu.org
@ 2012-01-11  7:48 ` jb at gcc dot gnu.org
  2012-01-12  9:59 ` jb at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jb at gcc dot gnu.org @ 2012-01-11  7:48 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51803

Janne Blomqvist <jb at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #6 from Janne Blomqvist <jb at gcc dot gnu.org> 2012-01-11 07:48:04 UTC ---
Closing as fixed, thanks for the report.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libfortran/51803] gfortran getcwd at startup
  2012-01-09 20:57 [Bug libfortran/51803] New: gfortran getcwd at startup mrs at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2012-01-11  7:48 ` jb at gcc dot gnu.org
@ 2012-01-12  9:59 ` jb at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jb at gcc dot gnu.org @ 2012-01-12  9:59 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51803

--- Comment #7 from Janne Blomqvist <jb at gcc dot gnu.org> 2012-01-12 09:58:39 UTC ---
Author: jb
Date: Thu Jan 12 09:58:34 2012
New Revision: 183122

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183122
Log:
PR 51803 Avoid malloc if getcwd fails or is not available.

2012-01-12  Janne Blomqvist  <jb@gcc.gnu.org>
        Tobias Burnus  <burnus@net-b.de>

    PR libfortran/51803
    * runtime/main.c (store_exe_path): Avoid malloc if getcwd fails or
    is not available.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/runtime/main.c


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-01-12  9:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-09 20:57 [Bug libfortran/51803] New: gfortran getcwd at startup mrs at gcc dot gnu.org
2012-01-10  7:21 ` [Bug libfortran/51803] " jb at gcc dot gnu.org
2012-01-10 10:04 ` rguenth at gcc dot gnu.org
2012-01-10 16:40 ` mrs at gcc dot gnu.org
2012-01-10 16:45 ` mrs at gcc dot gnu.org
2012-01-11  7:35 ` jb at gcc dot gnu.org
2012-01-11  7:48 ` jb at gcc dot gnu.org
2012-01-12  9:59 ` jb at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).