Last Comment Bug 670788 - Firefox does not run when what is called through $PATH is a symbolic link and a file of the same name exists in the current directory
: Firefox does not run when what is called through $PATH is a symbolic link and...
Status: VERIFIED FIXED
[qa!]
: regression, verified-beta
Product: Core
Classification: Components
Component: XPCOM (show other bugs)
: Trunk
: x86 Linux
: -- normal (vote)
: mozilla8
Assigned To: Nobody; OK to take it and work on it
:
: Nathan Froyd [:froydnj]
Mentors:
: 671397 (view as bug list)
Depends on:
Blocks: 552864
  Show dependency treegraph
 
Reported: 2011-07-11 16:52 PDT by Jeff Hammel
Modified: 2011-09-22 15:58 PDT (History)
12 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---
+
fixed


Attachments
When looking for the executable path on Unix, only use realpath() when we got a file path in the first place (1.35 KB, patch)
2011-07-12 00:18 PDT, Mike Hommey [:glandium]
benjamin: review+
christian: approval‑mozilla‑aurora+
Details | Diff | Splinter Review

Description Jeff Hammel 2011-07-11 16:52:33 PDT
Since sometime in the Firefox 7 days, my symbolic link ~/bin/firefox, which poins to ~/firefox/firefox, stopped working.  This is pretty bad.  I can no longer launch firefox from my menu (ubuntu 11.04, fluxbox), nor click on links in gnome-terminals, nor do my wealth of scripts work to open links.  In short, its a big deficiency for me.  I'm happy to help try things to debug, but am not really sure what to do

│which firefox
/home/jhammel/bin/firefox
│firefox
Couldn't load XPCOM.
│strace firefox
execve("/home/jhammel/bin/firefox", ["firefox"], [/* 42 vars */]) = 0
brk(0)                                  = 0x9a0f000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7750000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=118805, ...}) = 0
mmap2(NULL, 118805, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7732000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/i386-linux-gnu/libpthread.so.0", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\20M\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=121644, ...}) = 0
mmap2(NULL, 98824, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7719000
mmap2(0xb772e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15) = 0xb772e000
mmap2(0xb7730000, 4616, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7730000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/i386-linux-gnu/libdl.so.2", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0@\n\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=9736, ...}) = 0
mmap2(NULL, 12408, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7715000
mmap2(0xb7717000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1) = 0xb7717000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/usr/lib/i386-linux-gnu/libstdc++.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\340B\4\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=930044, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7714000
mmap2(NULL, 959532, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7629000
mmap2(0xb7708000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xde) = 0xb7708000
mmap2(0xb770d000, 25644, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb770d000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/i386-linux-gnu/libm.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\2604\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=149392, ...}) = 0
mmap2(NULL, 151680, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7603000
mmap2(0xb7627000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x23) = 0xb7627000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/i386-linux-gnu/libgcc_s.so.1", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0P\37\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=108040, ...}) = 0
mmap2(NULL, 111148, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb75e7000
mmap2(0xb7601000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19) = 0xb7601000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/i386-linux-gnu/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\220o\1\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1434180, ...}) = 0
mmap2(NULL, 1444360, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7486000
mprotect(0xb75e0000, 4096, PROT_NONE)   = 0
mmap2(0xb75e1000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15a) = 0xb75e1000
mmap2(0xb75e4000, 10760, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb75e4000
close(3)                                = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7485000
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7484000
set_thread_area({entry_number:-1 -> 6, base_addr:0xb74846e0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
mprotect(0xb75e1000, 8192, PROT_READ)   = 0
mprotect(0xb7601000, 4096, PROT_READ)   = 0
mprotect(0xb7627000, 4096, PROT_READ)   = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7483000
mprotect(0xb7708000, 16384, PROT_READ)  = 0
mprotect(0xb7717000, 4096, PROT_READ)   = 0
mprotect(0xb772e000, 4096, PROT_READ)   = 0
mprotect(0xb776f000, 4096, PROT_READ)   = 0
munmap(0xb7732000, 118805)              = 0
set_tid_address(0xb7484748)             = 14683
set_robust_list(0xb7484750, 0xc)        = 0
futex(0xbf824180, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0xbf824180, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, NULL, bf824190) = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGRTMIN, {0xb771d6e0, [], SA_SIGINFO}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0xb771d760, [], SA_RESTART|SA_SIGINFO}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
uname({sys="Linux", node="jhammel-THINK", ...}) = 0
getcwd("/home/jhammel", 4096)           = 14
lstat64("/home/jhammel/firefox", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat64("/home/jhammel/firefox", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
getrusage(RUSAGE_SELF, {ru_utime={0, 0}, ru_stime={0, 4000}, ...}) = 0
lstat64("/home", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat64("/home/jhammel", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat64("/home/jhammel/libxpcom.so", 0xbf820f9c) = -1 ENOENT (No such file or directory)
futex(0xb7718064, FUTEX_WAKE_PRIVATE, 2147483647) = 0
readlink("/etc/malloc.conf", 0xbf81ff1d, 4096) = -1 ENOENT (No such file or directory)
mmap2(NULL, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7383000
mmap2(NULL, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7283000
munmap(0xb7283000, 1048576)             = 0
mmap2(0xb7300000, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7283000
munmap(0xb7283000, 1048576)             = 0
mmap2(NULL, 2097152, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7183000
munmap(0xb7183000, 2097152)             = 0
mmap2(0xb7200000, 1048576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7200000
open("/home/jhammel/libxpcom.so", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, "Couldn't load XPCOM.\n", 21Couldn't load XPCOM.
)  = 21
exit_group(255)                         = ?
│^C
│ls -l `which firefox`
lrwxrwxrwx 1 jhammel jhammel 29 2011-06-21 16:34 /home/jhammel/bin/firefox -> /home/jhammel/firefox/firefox
Comment 1 Jeff Hammel 2011-07-11 16:53:12 PDT
This is a problem on three of my computers.  Dunno what the deal is :(
Comment 2 Justin Dolske [:Dolske] 2011-07-11 22:56:25 PDT
Possibly from bug 552864? Regression range?
Comment 3 Mike Hommey [:glandium] 2011-07-11 23:17:36 PDT
I'm pretty sure this is related to bug 552864. I don't know if that was Jeff that mentioned that on irc shortly after bug 552864 landed, but I was aware of someone having that issue, though I can't reproduce the problem...
Comment 4 Mike Hommey [:glandium] 2011-07-11 23:21:22 PDT
Okay I could reproduce. It only happens when running "firefox". If you use the full path to the symbolic link, it works.
Comment 5 Mike Hommey [:glandium] 2011-07-12 00:03:09 PDT
(In reply to comment #4)
> Okay I could reproduce. It only happens when running "firefox". If you use
> the full path to the symbolic link, it works.

It's even more subtle. It only happens when running "firefox" and the current directory contains a "firefox" file or directory.
Comment 6 Mike Hommey [:glandium] 2011-07-12 00:18:47 PDT
Created attachment 545323 [details] [diff] [review]
When looking for the executable path on Unix, only use realpath() when we got a file path in the first place
Comment 7 Reed Loden [:reed] (use needinfo?) 2011-07-13 14:39:00 PDT
*** Bug 671397 has been marked as a duplicate of this bug. ***
Comment 8 Boris Zbarsky [:bz] (still a bit busy) 2011-07-13 20:35:47 PDT
Seems like we should track this regression for 7....  It'll cause starting the browser to mysteriously fail for people in some cases.
Comment 9 Christopher Blizzard (:blizzard) 2011-07-14 14:33:13 PDT
Tracking for Firefox 7.
Comment 10 Benjamin Smedberg [:bsmedberg] 2011-07-20 10:20:01 PDT
Comment on attachment 545323 [details] [diff] [review]
When looking for the executable path on Unix, only use realpath() when we got a file path in the first place

Please use strchr instead of index: index is legacy.
Comment 13 Jeff Hammel 2011-07-22 09:48:22 PDT
Confirmed.  This now works on my nightly.  Thanks a bunch!  Life is good again
Comment 14 Mike Hommey [:glandium] 2011-07-22 10:06:17 PDT
Comment on attachment 545323 [details] [diff] [review]
When looking for the executable path on Unix, only use realpath() when we got a file path in the first place

See comment 8
Comment 15 christian 2011-07-26 15:05:23 PDT
Comment on attachment 545323 [details] [diff] [review]
When looking for the executable path on Unix, only use realpath() when we got a file path in the first place

Approved for mozilla-aurora. Please land asap.
Comment 16 Mike Hommey [:glandium] 2011-07-27 00:47:30 PDT
http://hg.mozilla.org/releases/mozilla-aurora/rev/7d7d783b8663
Comment 17 Mihaela Velimiroviciu (:mihaelav) 2011-08-22 23:38:30 PDT
I was able to reproduce the "Couldn't load XPCOM." error on Ubuntu with Firefox 7 beta 1 (Mozilla/5.0 (X11; Linux x86_64; rv:7.0) Gecko/20100101 Firefox/7.0)

Steps:
1. Removed previous Firefox version
2. Unpacked Firefox 7 beta 1
3. Launched Firefox from the download directory
   -> double click on "firefox" in directory -> works fine
   -> from command line: # ./firefox -> works fine
   -> from command line: # firefox -> bash: /usr/bin/firefox: No such file or directory -> this might be because Firefox script doesn't create any shortcut
4. If I copy Firefox script in /bin and run it, I get:
      /bin$ firefox
      Couldn't load XPCOM.

  If I create a symlink of firefox file in bin/firefox 
      Downloads/firefox# ln -s firefox /bin/firefox
   and run /bin $ firefox, I get: 
      /bin$ firefox
      bash: /bin/firefox: Too many levels of symbolic links
  If I create a symlink of run-mozilla.sh in bin/firefox
      /Downloads/firefox# ln -s run-mozilla.sh /bin/firefox
  and run /bin $ firefox, I get: 
      bash: /bin/firefox: No such file or directory
Comment 18 Mike Hommey [:glandium] 2011-08-22 23:52:19 PDT
(In reply to Mihaela Velimiroviciu from comment #17)
> I was able to reproduce the "Couldn't load XPCOM." error on Ubuntu with
> Firefox 7 beta 1 (Mozilla/5.0 (X11; Linux x86_64; rv:7.0) Gecko/20100101
> Firefox/7.0)
> 
> Steps:
> 1. Removed previous Firefox version
> 2. Unpacked Firefox 7 beta 1
> 3. Launched Firefox from the download directory
>    -> double click on "firefox" in directory -> works fine
>    -> from command line: # ./firefox -> works fine
>    -> from command line: # firefox -> bash: /usr/bin/firefox: No such file
> or directory -> this might be because Firefox script doesn't create any
> shortcut
> 4. If I copy Firefox script in /bin and run it, I get:
>       /bin$ firefox
>       Couldn't load XPCOM.

"firefox" is not a script. So copying "firefox" in /bin is not going to work nor is it supposed to.

>   If I create a symlink of firefox file in bin/firefox 
>       Downloads/firefox# ln -s firefox /bin/firefox
>    and run /bin $ firefox, I get: 
>       /bin$ firefox
>       bash: /bin/firefox: Too many levels of symbolic links

That is because you created a /bin/firefox symbolic that points to itself. You need to do ln -s /path/to/Downloads/firefox/firefox /bin/firefox

>   If I create a symlink of run-mozilla.sh in bin/firefox
>       /Downloads/firefox# ln -s run-mozilla.sh /bin/firefox
>   and run /bin $ firefox, I get: 
>       bash: /bin/firefox: No such file or directory

Running "run-mozilla.sh" is not going to start firefox. And you're doing the same mistake as above, except now /bin/firefox points at /bin/run-mozilla.sh.
Comment 19 Mihaela Velimiroviciu (:mihaelav) 2011-08-23 02:54:31 PDT
I created the symlink again and it works now:
~/Downloads/firefox$ sudo ln -s /home/mihaelavelimiroviciu//Downloads/firefox/firefox /bin/firefox

~/Downloads/firefox$ firefox
/bin$ firefox
-> firefox launches successfully
Comment 20 Anthony Hughes (:ashughes) [GFX][QA][Mentor] 2011-09-22 15:58:03 PDT
Based on comment 19, QA can call this VERIFIED.

Note You need to log in before you can comment on or make changes to this bug.