Closed Bug 467405 Opened 16 years ago Closed 10 years ago

FIFO pipe in directory hangs file selector

Categories

(Core :: Widget: Gtk, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla37

People

(Reporter: olesen, Assigned: maciej.a.kaminski)

Details

Attachments

(1 file, 2 obsolete files)

User-Agent:       Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4
Build Identifier: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4

Firefox hangs when file selector navigates to a _directory_ where the FIFO pipe is held. 

Reproducible: Always

Steps to Reproduce:
mkdir testdir
cd testdir
mknod backpipe p

---

1. In firefox: open a file selection dialog from a website (attach file in gmail, etc.)
2. navigate to directory where pipe is stored (not necessary to navigate to the pipe, just the containing directory)
3. file selector hangs. 
Actual Results:  
hang

Expected Results:  
show files

64bit centos 5.1
This bug was reported using Firefox 3.0 or older, which is no longer supported. The bug has also not been changed in over 500 days and is still in UNCO.
Reporter, please retest this bug in Firefox 3.6.10 or later using a fresh profile, http://support.mozilla.com/en-US/kb/managing+profiles. If you still see this problem, please update the bug. If you no longer see the bug, please set the resolution to RESOLVED, WORKSFORME.

This is a mass search of unconfirmed bugs that have no activity on them, so if you feel a bug was marked in error, just remove the CLOSEME comment in the whiteboard within the next month.
Whiteboard: [CLOSEME 2010-11-15]
No reply, INCOMPLETE. Please retest with Firefox 3.6.12 or later and a new profile (http://support.mozilla.com/kb/Managing+profiles). If you continue to see this issue with the newest firefox and a new profile, then please comment on this bug.
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → INCOMPLETE
This bug exists and I have fix for it. Could we please reopen this bug and push my patch? 

diff -r f14dcd1c8c0b widget/gtk/nsFilePicker.cpp
--- a/widget/gtk/nsFilePicker.cpp	Fri Dec 12 17:18:42 2014 -0800
+++ b/widget/gtk/nsFilePicker.cpp	Sun Dec 14 14:36:05 2014 +0100
@@ -4,6 +4,9 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Types.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
 
 #include <gtk/gtk.h>
 
@@ -70,7 +73,7 @@
 {
   GtkImage *preview_widget = GTK_IMAGE(preview_widget_voidptr);
   char *image_filename = gtk_file_chooser_get_preview_filename(file_chooser);
-
+  struct stat st_buf;
   if (!image_filename) {
     gtk_file_chooser_set_preview_widget_active(file_chooser, FALSE);
     return;
@@ -78,6 +81,21 @@
 
   gint preview_width = 0;
   gint preview_height = 0;
+  /* check type of file */
+  if (stat(image_filename, &st_buf)) {
+    g_free(image_filename);
+    gtk_file_chooser_set_preview_widget_active(file_chooser, FALSE);
+    return; /*stat failed */
+  }
+  /* if file is named pipe, Open is blocking which may lead to UI
+   *  nonresponsiveness; if file is directory/socket, it also isn't 
+   *  likely to get preview */
+  if (!S_ISREG(st_buf.st_mode)) {
+    g_free(image_filename);
+    gtk_file_chooser_set_preview_widget_active(file_chooser, FALSE);
+    return;
+  }
+  
   GdkPixbufFormat *preview_format = gdk_pixbuf_get_file_info(image_filename,
                                                              &preview_width,
                                                              &preview_height);
Attached patch Patch solving this problem (obsolete) — Splinter Review
Attachment #8536247 - Flags: review?(jst)
Attachment #8536247 - Attachment is patch: true
Attachment #8536247 - Attachment mime type: text/x-patch → text/plain
Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: INCOMPLETE → ---
Comment on attachment 8536247 [details] [diff] [review]
Patch solving this problem

+  /* check type of file */
+  if (stat(image_filename, &st_buf)) {
+    g_free(image_filename);
+    gtk_file_chooser_set_preview_widget_active(file_chooser, FALSE);
+    return; /*stat failed */
+  }
+  /* if file is named pipe, Open is blocking which may lead to UI
+   *  nonresponsiveness; if file is directory/socket, it also isn't 
+   *  likely to get preview */
+  if (!S_ISREG(st_buf.st_mode)) {
+    g_free(image_filename);
+    gtk_file_chooser_set_preview_widget_active(file_chooser, FALSE);
+    return;
+  }

Thanks for the fix! My only comment is that it'd be a bit less code to maintain if we were to combine the two if checks since the code inside the checks is identical.

Thanks again, r=jst with that, but also requesting review from the gtk widget owner (which I am not).
Attachment #8536247 - Flags: review?(roc)
Attachment #8536247 - Flags: review?(jst)
Attachment #8536247 - Flags: review+
Since you wrote the patch, you get to own the bug :) (and let me know if you need any help!). Once you get review from roc or karlt (who happens to be on vacation until Christmas), please set the checkin flag to ? :jst and we'll make sure to get this landed!
Assignee: nobody → maciej.a.kaminski
(roc should be around before Christmas, in a couple of days IIRC, karlt is the one who's on vacation until Christmas)
Whiteboard: [CLOSEME 2010-11-15]
Attached patch hang.pch (obsolete) — Splinter Review
shorter version of patch. as per jst's suggestion I've combined two checks into one.
Attachment #8536247 - Attachment is obsolete: true
Attachment #8536247 - Flags: review?(roc)
Attachment #8537391 - Flags: review?(roc)
Attachment #8537391 - Attachment is patch: true
Attachment #8537391 - Attachment mime type: text/x-patch → text/plain
Comment on attachment 8537391 [details] [diff] [review]
hang.pch

Review of attachment 8537391 [details] [diff] [review]:
-----------------------------------------------------------------

::: widget/gtk/nsFilePicker.cpp
@@ +90,5 @@
> +    g_free(image_filename);
> +    gtk_file_chooser_set_preview_widget_active(file_chooser, FALSE);
> +    return; /* stat failed or file is not regular */ 
> +  }
> +  

remove trailing whitespace
Attachment #8537391 - Flags: review?(roc) → review+
Thank you sir for review. used emacs' whitespace-mode to make sure, no trailing whitespaces are left. Attaching corrected version of patch.
Attached patch hang.pch2Splinter Review
Attachment #8537391 - Attachment is obsolete: true
Attachment #8538784 - Flags: review+
How do we exactly commit? I have ofc. ran test cases and  I have added checkin needed flag.

What else do I have to do?

Thanks again jst,roc for being so helpful.
Keywords: checkin-needed
can we get a try run for this change ? Thanks !
Flags: needinfo?(maciej.a.kaminski)
Keywords: checkin-needed
yes, why not?
Flags: needinfo?(maciej.a.kaminski)
Builds on try, but I realized that I didn't enable any tests :( However, this change is in gtk widget code which I seriously doubt we have a single test for, cause it's effectively untestable in our harnesses.

Given that, I decided to land this.

https://hg.mozilla.org/integration/mozilla-inbound/rev/c6c7aa17862f

Thanks again maciej.a.kaminski@gmail.com!
https://hg.mozilla.org/mozilla-central/rev/c6c7aa17862f
Status: REOPENED → RESOLVED
Closed: 14 years ago10 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 37
Component: File Handling → Widget: Gtk
Product: Firefox → Core
Target Milestone: Firefox 37 → ---
Target Milestone: --- → mozilla37
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: