Assert hit when using native file dialogs

Started the juce demo > widget page > open native Load file dialog > selected a file > boom

JUCE v2.1.5
Time and date: 7 Oct 2013 9:28:58am
User logon name: lucio
Full user name: lucio
Operating system: Linux
Locale: English-USA
Memory size: 16011MB
Number of CPUs: 4
CPU vendor: GenuineIntel
CPU speed: 3101MHz
CPU has MMX: yes
CPU has SSE: yes
CPU has SSE2: yes
CPU has SSE3: yes
CPU has 3DNOW: no
Found network card MAC addresses: 2c-27-d7-19-6d-8d
Found IP addresses:,
Current working directory: /home/lucio/Projects/juce/extras/JuceDemo/Builds/Linux
Current executable file: /home/lucio/Projects/juce/extras/JuceDemo/Builds/Linux/build/JuceDemo
Current application file: /home/lucio/Projects/juce/extras/JuceDemo/Builds/Linux/build/JuceDemo
User home directory: /home/lucio
User documents directory: /home/lucio
User application data directory: /home/lucio
Common application data directory: /var
Temp directory: /var/tmp

[New Thread 0x7ffff5100700 (LWP 22547)]
JUCE Assertion failure in juce_File.cpp:152
Program received signal SIGTRAP, Trace/breakpoint trap.
0x00007ffff5d56287 in kill () from /lib64/
(gdb) bt
#0  0x00007ffff5d56287 in kill () from /lib64/
#1  0x0000000000564344 in juce::File::parseAbsolutePath (p=...) at ../../../../modules/juce_core/files/juce_File.cpp:152
#2  0x0000000000563dfd in juce::File::File (this=0x7fffffffc440, fullPathName=...) at ../../../../modules/juce_core/files/juce_File.cpp:30
#3  0x0000000000760969 in juce::FileChooser::showPlatformDialog (results=..., title=..., file=..., isDirectory=false, isSave=false, selectMultipleFiles=true)
    at ../../../../modules/juce_gui_basics/native/juce_linux_FileChooser.cpp:146
#4  0x00000000006fc435 in juce::FileChooser::showDialog (this=0x7fffffffd460, flags=21, previewComp=0x0)
    at ../../../../modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp:109
#5  0x00000000006fc1eb in juce::FileChooser::browseForMultipleFilesToOpen (this=0x7fffffffd460, previewComp=0x0)
    at ../../../../modules/juce_gui_basics/filebrowser/juce_FileChooser.cpp:53
#6  0x000000000043ed42 in WidgetsDemo::performDemoMenuItem (this=0xf1aeb0, result=121) at ../../Source/demos/WidgetsDemo.cpp:1304
#7  0x000000000043e299 in WidgetsDemo::menuItemChosenCallback (result=121, demoComponent=0xf1aeb0) at ../../Source/demos/WidgetsDemo.cpp:1181
#8  0x000000000044164b in juce::ModalCallbackFunction::ComponentCaller1<WidgetsDemo>::modalStateFinished (this=0xf627b0, returnValue=121)
    at ../../Source/demos/../../JuceLibraryCode/modules/juce_audio_processors/../../../../../modules/juce_audio_processors/../juce_gui_basics/components/juce_ModalComponentManager.h:326
#9  0x00000000006dd736 in juce::ModalComponentManager::handleAsyncUpdate (this=0xefb430)
    at ../../../../modules/juce_gui_basics/components/juce_ModalComponentManager.cpp:197
#10 0x00000000005fdc29 in juce::AsyncUpdater::AsyncUpdaterMessage::messageCallback (this=0xefcdb0)
    at ../../../../modules/juce_events/broadcasters/juce_AsyncUpdater.cpp:33
#11 0x00000000005ff427 in juce::InternalMessageQueue::dispatchNextInternalMessage (this=0xeeaab0)
    at ../../../../modules/juce_events/native/juce_linux_Messaging.cpp:202
#12 0x00000000005feea0 in juce::InternalMessageQueue::dispatchNextEvent (this=0xeeaab0) at ../../../../modules/juce_events/native/juce_linux_Messaging.cpp:95
#13 0x00000000005fd269 in juce::MessageManager::dispatchNextMessageOnSystemQueue (returnIfNoPendingMessages=false)
    at ../../../../modules/juce_events/native/juce_linux_Messaging.cpp:388
#14 0x00000000005f9d34 in juce::MessageManager::runDispatchLoopUntil (this=0xeea9b0, millisecondsToRunFor=-1)
    at ../../../../modules/juce_events/messages/juce_MessageManager.cpp:115
#15 0x00000000005f9c89 in juce::MessageManager::runDispatchLoop (this=0xeea9b0) at ../../../../modules/juce_events/messages/juce_MessageManager.cpp:96
#16 0x00000000005f91fa in juce::JUCEApplicationBase::main () at ../../../../modules/juce_events/messages/juce_ApplicationBase.cpp:235
#17 0x00000000005f9122 in juce::JUCEApplicationBase::main (argc=1, argv=0x7fffffffdb58)
    at ../../../../modules/juce_events/messages/juce_ApplicationBase.cpp:213
#18 0x000000000040c0a9 in main (argc=1, argv=0x7fffffffdb58) at ../../Source/ApplicationStartup.cpp:174


I think that in juce_linux_FileChooser.cpp, this does not work in ChildProcess, and probably it's a warning output to stderr which mess up the file name:

args.add ("2>/dev/null");

It's only a warning assertion - I think if you ignore it, it'd probably work ok. But I've added some code to avoid the assertion, so try it again now.

no the problem is that in this machine, zenity launched without "2>/dev/null" produces some warnings, and those warnings gets returned and parsed by the ChildProcess::readAllOutput even if you pass "2>/dev/null" as the last argument of execvp (cause you are actually reading stderr from a pipe, regardless of any redirect you may have setup).

So in the end, passing "2>/dev/null" as last arg of ChildProcess doesn't achieve what you want to do.

This seems to fix the problems, it's a quick and dirty hack but makes the "2>/dev/null" passed in ChildProcess arguments work:

diff --git a/modules/juce_core/native/juce_posix_SharedCode.h b/modules/juce_core/native/juce_posix_SharedCode.h
index 917be77..83285a5 100644
--- a/modules/juce_core/native/juce_posix_SharedCode.h
+++ b/modules/juce_core/native/juce_posix_SharedCode.h
@@ -1007,7 +1007,10 @@ public:
                 // we're the child process..
                 close (pipeHandles[0]);   // close the read handle
                 dup2 (pipeHandles[1], 1); // turns the pipe into stdout
-                dup2 (pipeHandles[1], 2); //  + stderr
+                if (arguments.contains("2>/dev/null"))
+                    close(STDERR_FILENO);
+                else
+                    dup2 (pipeHandles[1], 2); //  + stderr
                 close (pipeHandles[1]);
                 Array<char*> argv;

Any chance to slip in a fix for this ?

Thanks, I've made a slightly less hacky fix! Would be great if you could give it a try and let me know if it works!

this finally fixed it... thanx !