public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/38966]  New: libiberty make_relative_prefix_1 mistakes directories for executables
@ 2009-01-25 14:55 mmlr at mlotz dot ch
  2009-01-25 14:56 ` [Bug other/38966] " mmlr at mlotz dot ch
                   ` (7 more replies)
  0 siblings, 8 replies; 13+ messages in thread
From: mmlr at mlotz dot ch @ 2009-01-25 14:55 UTC (permalink / raw)
  To: gcc-bugs

When GCC tries to resolve paths to executables it generates an exec prefix
based on argv[0]. It does that using the make_relative_prefix_1 function in
libiberty (make-relative-prefix.c). If argv[0] doesn't contain a path (i.e. it
only reads "gcc"), make_relative_prefix_1 searches the PATH to find the full
path to the current executable.

When checking candidates however, it only checks the executable bit to
determine whether or not it found the current executable. This means that when
there is a directory with the same name as the executable in the PATH, this
mechanism will produce a wrong prefix.

Attached is a patch that uses stat to determine whether the candidate file is a
regular file at all, hence skipping directories.


-- 
           Summary: libiberty make_relative_prefix_1 mistakes directories
                    for executables
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mmlr at mlotz dot ch
  GCC host triplet: i586-pc-haiku
GCC target triplet: i586-pc-haiku


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


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

* [Bug other/38966] libiberty make_relative_prefix_1 mistakes directories for executables
  2009-01-25 14:55 [Bug other/38966] New: libiberty make_relative_prefix_1 mistakes directories for executables mmlr at mlotz dot ch
@ 2009-01-25 14:56 ` mmlr at mlotz dot ch
  2009-01-26 19:24 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: mmlr at mlotz dot ch @ 2009-01-25 14:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from mmlr at mlotz dot ch  2009-01-25 14:56 -------
Created an attachment (id=17181)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17181&action=view)
Proposed fix for make_relative_prefix_1


-- 


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


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

* [Bug other/38966] libiberty make_relative_prefix_1 mistakes directories for executables
  2009-01-25 14:55 [Bug other/38966] New: libiberty make_relative_prefix_1 mistakes directories for executables mmlr at mlotz dot ch
  2009-01-25 14:56 ` [Bug other/38966] " mmlr at mlotz dot ch
@ 2009-01-26 19:24 ` pinskia at gcc dot gnu dot org
  2009-01-26 19:47 ` dj at redhat dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-01-26 19:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2009-01-26 19:23 -------
*** Bug 37995 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mvanier at cs dot caltech
                   |                            |dot edu


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


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

* [Bug other/38966] libiberty make_relative_prefix_1 mistakes directories for executables
  2009-01-25 14:55 [Bug other/38966] New: libiberty make_relative_prefix_1 mistakes directories for executables mmlr at mlotz dot ch
  2009-01-25 14:56 ` [Bug other/38966] " mmlr at mlotz dot ch
  2009-01-26 19:24 ` pinskia at gcc dot gnu dot org
@ 2009-01-26 19:47 ` dj at redhat dot com
  2009-01-27  1:23 ` mmlr at mlotz dot ch
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: dj at redhat dot com @ 2009-01-26 19:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from dj at redhat dot com  2009-01-26 19:46 -------
Subject: Re:   New: libiberty make_relative_prefix_1 mistakes directories for
executables


Your code conditionally includes <sys/stat.h> but doesn't
conditionally enable the other code.  If sys/stat.h isn't found,
perhaps the code could revert to the old access() code?


-- 


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


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

* [Bug other/38966] libiberty make_relative_prefix_1 mistakes directories for executables
  2009-01-25 14:55 [Bug other/38966] New: libiberty make_relative_prefix_1 mistakes directories for executables mmlr at mlotz dot ch
                   ` (2 preceding siblings ...)
  2009-01-26 19:47 ` dj at redhat dot com
@ 2009-01-27  1:23 ` mmlr at mlotz dot ch
  2009-02-23 18:01 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: mmlr at mlotz dot ch @ 2009-01-27  1:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from mmlr at mlotz dot ch  2009-01-27 01:23 -------
Created an attachment (id=17189)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17189&action=view)
Proposed fix with conditional use of stat based on HAVE_SYS_STAT_H

This only conditionally uses stat() if HAVE_SYS_STAT_H is defined. Not sure
about the indentation style at all, sorry.


-- 

mmlr at mlotz dot ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #17181|0                           |1
        is obsolete|                            |


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


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

* [Bug other/38966] libiberty make_relative_prefix_1 mistakes directories for executables
  2009-01-25 14:55 [Bug other/38966] New: libiberty make_relative_prefix_1 mistakes directories for executables mmlr at mlotz dot ch
                   ` (3 preceding siblings ...)
  2009-01-27  1:23 ` mmlr at mlotz dot ch
@ 2009-02-23 18:01 ` pinskia at gcc dot gnu dot org
  2009-02-24  1:17 ` howarth at nitro dot med dot uc dot edu
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-02-23 18:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2009-02-23 18:01 -------
*** Bug 39278 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dickie at acm dot org


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


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

* [Bug other/38966] libiberty make_relative_prefix_1 mistakes directories for executables
  2009-01-25 14:55 [Bug other/38966] New: libiberty make_relative_prefix_1 mistakes directories for executables mmlr at mlotz dot ch
                   ` (4 preceding siblings ...)
  2009-02-23 18:01 ` pinskia at gcc dot gnu dot org
@ 2009-02-24  1:17 ` howarth at nitro dot med dot uc dot edu
  2009-02-24 17:16 ` mmlr at mlotz dot ch
  2009-06-25  1:25 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 13+ messages in thread
From: howarth at nitro dot med dot uc dot edu @ 2009-02-24  1:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from howarth at nitro dot med dot uc dot edu  2009-02-24 01:17 -------
The currently proposed patch doesn't solve the problem where 'make -k
check-libiberty' executed at the top level of the build directory results in
gcc being used instead of xgcc. If you execute 'make -k check' in
darwin_objdir/libiberty, you get...

/sw/src/fink.build/gcc44-4.3.999-20090221/darwin_objdir/./prev-gcc/xgcc
-B/sw/src/fink.build/gcc44-4.3.999-20090221/darwin_objdir/./prev-gcc/
-B/sw/lib/gcc4.4/i686-apple-darwin10/bin/ -DHAVE_CONFIG_H -g -O2
-fomit-frame-pointer -I..
-I../../../gcc-4.4-20090221/libiberty/testsuite/../../include  -o test-demangle
\
                ../../../gcc-4.4-20090221/libiberty/testsuite/test-demangle.c
../libiberty.a

whereas if you execute 'make -k check-libiberty' in darwin_objdir, you get the
incorrect compiler...

gcc -DHAVE_CONFIG_H -g -O2 -I..
-I../../../gcc-4.4-20090221/libiberty/testsuite/../../include  -o test-demangle
\
                ../../../gcc-4.4-20090221/libiberty/testsuite/test-demangle.c
../libiberty.a


-- 


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


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

* [Bug other/38966] libiberty make_relative_prefix_1 mistakes directories for executables
  2009-01-25 14:55 [Bug other/38966] New: libiberty make_relative_prefix_1 mistakes directories for executables mmlr at mlotz dot ch
                   ` (5 preceding siblings ...)
  2009-02-24  1:17 ` howarth at nitro dot med dot uc dot edu
@ 2009-02-24 17:16 ` mmlr at mlotz dot ch
  2009-06-25  1:25 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 13+ messages in thread
From: mmlr at mlotz dot ch @ 2009-02-24 17:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from mmlr at mlotz dot ch  2009-02-24 17:16 -------
(In reply to comment #6)
> The currently proposed patch doesn't solve the problem where 'make -k
> check-libiberty' executed at the top level of the build directory results in
> gcc being used instead of xgcc.

That's not really the scope of this patch though. This is just to correct the
case where a directory is mistaken for an executable. The other issue looks
like a separate bug to me.


-- 


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


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

* [Bug other/38966] libiberty make_relative_prefix_1 mistakes directories for executables
  2009-01-25 14:55 [Bug other/38966] New: libiberty make_relative_prefix_1 mistakes directories for executables mmlr at mlotz dot ch
                   ` (6 preceding siblings ...)
  2009-02-24 17:16 ` mmlr at mlotz dot ch
@ 2009-06-25  1:25 ` pinskia at gcc dot gnu dot org
  7 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-06-25  1:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pinskia at gcc dot gnu dot org  2009-06-25 01:25 -------
*** Bug 40548 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |psmith at gnu dot org


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


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

* [Bug other/38966] libiberty make_relative_prefix_1 mistakes directories for executables
       [not found] <bug-38966-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2012-08-16  6:59 ` jakub at gcc dot gnu.org
@ 2012-08-16 13:00 ` ttignor at us dot ibm.com
  3 siblings, 0 replies; 13+ messages in thread
From: ttignor at us dot ibm.com @ 2012-08-16 13:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Tom Tignor <ttignor at us dot ibm.com> 2012-08-16 12:59:39 UTC ---
Hi Jakub,
Can you tell me what gcc version has the fix? Read through 48306 and saw 
"Fixed in 4.5+" but I have a colleague here who is able to reproduce on 
4.5.1.

Tom    :-)




From:   "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To:     Thomas Tignor/Marlborough/IBM@IBMUS
Date:   08/16/2012 02:59 AM
Subject:        [Bug other/38966] libiberty make_relative_prefix_1 
mistakes directories for executables



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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |jakub at gcc dot gnu.org
         Resolution|                            |DUPLICATE

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-08-16 
06:58:19 UTC ---
Dup of PR48306.

*** This bug has been marked as a duplicate of bug 48306 ***


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

* [Bug other/38966] libiberty make_relative_prefix_1 mistakes directories for executables
       [not found] <bug-38966-4@http.gcc.gnu.org/bugzilla/>
  2012-08-15 21:33 ` ttignor at us dot ibm.com
  2012-08-15 21:36 ` ttignor at us dot ibm.com
@ 2012-08-16  6:59 ` jakub at gcc dot gnu.org
  2012-08-16 13:00 ` ttignor at us dot ibm.com
  3 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-08-16  6:59 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |jakub at gcc dot gnu.org
         Resolution|                            |DUPLICATE

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-08-16 06:58:19 UTC ---
Dup of PR48306.

*** This bug has been marked as a duplicate of bug 48306 ***


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

* [Bug other/38966] libiberty make_relative_prefix_1 mistakes directories for executables
       [not found] <bug-38966-4@http.gcc.gnu.org/bugzilla/>
  2012-08-15 21:33 ` ttignor at us dot ibm.com
@ 2012-08-15 21:36 ` ttignor at us dot ibm.com
  2012-08-16  6:59 ` jakub at gcc dot gnu.org
  2012-08-16 13:00 ` ttignor at us dot ibm.com
  3 siblings, 0 replies; 13+ messages in thread
From: ttignor at us dot ibm.com @ 2012-08-15 21:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Tom Tignor <ttignor at us dot ibm.com> 2012-08-15 21:34:50 UTC ---
Created attachment 28023
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28023
Simple repro for "gcc" subdir in PATH bug.


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

* [Bug other/38966] libiberty make_relative_prefix_1 mistakes directories for executables
       [not found] <bug-38966-4@http.gcc.gnu.org/bugzilla/>
@ 2012-08-15 21:33 ` ttignor at us dot ibm.com
  2012-08-15 21:36 ` ttignor at us dot ibm.com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 13+ messages in thread
From: ttignor at us dot ibm.com @ 2012-08-15 21:33 UTC (permalink / raw)
  To: gcc-bugs

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

Tom Tignor <ttignor at us dot ibm.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ttignor at us dot ibm.com

--- Comment #9 from Tom Tignor <ttignor at us dot ibm.com> 2012-08-15 21:31:57 UTC ---
I ran into the related 37995 bug today (now closed as a duplicate of this one)
on gcc version 4.4.6. The bug reproduces simply by having a directory with a
"gcc" subdirectory in your PATH ahead of the directory which holds the gcc
binary. I have session output showing the repro procedure which I'll attach.


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

end of thread, other threads:[~2012-08-16 13:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-25 14:55 [Bug other/38966] New: libiberty make_relative_prefix_1 mistakes directories for executables mmlr at mlotz dot ch
2009-01-25 14:56 ` [Bug other/38966] " mmlr at mlotz dot ch
2009-01-26 19:24 ` pinskia at gcc dot gnu dot org
2009-01-26 19:47 ` dj at redhat dot com
2009-01-27  1:23 ` mmlr at mlotz dot ch
2009-02-23 18:01 ` pinskia at gcc dot gnu dot org
2009-02-24  1:17 ` howarth at nitro dot med dot uc dot edu
2009-02-24 17:16 ` mmlr at mlotz dot ch
2009-06-25  1:25 ` pinskia at gcc dot gnu dot org
     [not found] <bug-38966-4@http.gcc.gnu.org/bugzilla/>
2012-08-15 21:33 ` ttignor at us dot ibm.com
2012-08-15 21:36 ` ttignor at us dot ibm.com
2012-08-16  6:59 ` jakub at gcc dot gnu.org
2012-08-16 13:00 ` ttignor at us dot ibm.com

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).