[Bug 430229] New: after closing child process of forked yast, bad things happen
https://bugzilla.novell.com/show_bug.cgi?id=430229 Summary: after closing child process of forked yast, bad things happen Product: openSUSE 11.1 Version: Beta 1 Platform: Other OS/Version: Other Status: NEW Severity: Normal Priority: P5 - None Component: YaST2 AssignedTo: mvidner@novell.com ReportedBy: jsuchome@novell.com QAContact: jsrain@novell.com CC: sh@novell.com, visnov@novell.com Found By: --- SCR agent in yast2-fingerprint-reader forks itself, so the child process can do some work and parent process returns back to YCP and reports the progress of the work done. When the child process is done, it exits. This worked fine in openSUSE11.0. Now, after the exit I get some red messages in y2log: 2008-09-26 16:04:12 <3> linux-1ps9(14373) [ui] YUI.cc(~YUI):73 shutdownThreads() was never called! 2008-09-26 16:04:12 <3> linux-1ps9(14373) [ui] YUI.cc(~YUI):74 shutting down now - this might segfault .. The parent process reports that the child process was killed, altough it should exit correctly (the check is done with waitpid and WIFSIGNALED): 2008-09-26 16:04:12 <3> linux-1ps9(14331) [agent-thinkfinger] ThinkFingerAgent.cc(Read):216 child process was killed -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=430229 User jsuchome@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=430229#c1 --- Comment #1 from Jiří Suchomel <jsuchome@novell.com> 2008-09-26 08:15:40 MDT --- Created an attachment (id=241977) --> (https://bugzilla.novell.com/attachment.cgi?id=241977) y2log snippet -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=430229 User jsuchome@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=430229#c2 Jiří Suchomel <jsuchome@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |NEEDINFO Info Provider| |sh@novell.com --- Comment #2 from Jiří Suchomel <jsuchome@novell.com> 2008-09-26 08:16:12 MDT --- Stefan, do you have an idea what's wrong? -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=430229 Jiří Suchomel <jsuchome@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|Normal |Major Priority|P5 - None |P2 - High -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=430229 User visnov@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=430229#c3 Stanislav Visnovsky <visnov@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|mvidner@novell.com |sh@novell.com Status|NEEDINFO |NEW Info Provider|sh@novell.com | --- Comment #3 from Stanislav Visnovsky <visnov@novell.com> 2008-09-29 08:49:30 MDT --- Hmmm, shutdownThreads is libyui specific functionality. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=430229 User sh@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=430229#c4 Stefan Hundhammer <sh@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dmueller@novell.com, matz@novell.com --- Comment #4 from Stefan Hundhammer <sh@novell.com> 2008-09-30 04:11:45 MDT --- Hm - isn't the log message self-evident? 2008-09-26 16:04:12 <3> linux-1ps9(14373) [ui] YUI.cc(~YUI):73 shutdownThreads() was never called! 2008-09-26 16:04:12 <3> linux-1ps9(14373) [ui] YUI.cc(~YUI):74 shutting down now - this might segfault i.e. the proper shutdown sequence of the UI was violated. This might work, or it might segfault. In this particular case, it segfaulted. fork() just copies the running process - with everything, including the UI, and probably also with both its threads (Michael?): The YCP thread that listens to the YCP (UI-) command stream and the UI thread that responds to X11 events (mouse, keyboard, but also window redraw, window resize, etc.). In other scenarios (in other SCR agents), system() works. system(), however, also is just a fork() followed by exec(). So that combination seems to work. If you don't exec(), but simply call your own code, at some point you call exit(). That will also call C++ destructors, and this is where that error message comes from: The YUI destructor is called. From there on, things go downhill: It doesn't work as simply as that any more. There is a shutdown sequence for the UI and its threads that must be obeyed. Now, if fork() actually copies both threads (which it should IMHO), you could simply call YUI::ui()->shutdownThreads() at some point to do a proper shutdown. Another possibility would be to use a thread (a pthread), not a separate process. This might be somewhat safer. I recall Dirk Müller saying something about a GLIBC loop being differently in our latest libqt4. Maybe there is a connection to this problem. Dirk? -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=430229 User sh@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=430229#c5 Stefan Hundhammer <sh@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|sh@novell.com |jsuchome@novell.com --- Comment #5 from Stefan Hundhammer <sh@novell.com> 2008-09-30 04:12:57 MDT --- Marcus Meissner also just recommended to use a thread, not fork(). -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=430229 User visnov@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=430229#c6 --- Comment #6 from Stanislav Visnovsky <visnov@novell.com> 2008-09-30 04:16:15 MDT --- forked process does not inherit threads. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=430229 User jsuchome@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=430229#c7 Jiří Suchomel <jsuchome@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |NEEDINFO Info Provider| |visnov@novell.com --- Comment #7 from Jiří Suchomel <jsuchome@novell.com> 2008-09-30 04:29:50 MDT --- Originally, I used threads, but than I realized I need a way to kill the part that is running in the separate thread. I did not find a way how to do it, so I used fork, which worked correctly in openSUSE11.0. (In reply to comment #6 from Stanislav Visnovsky)
forked process does not inherit threads.
What does this mean? Is there a problem with my fork or with yast? -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=430229 User sh@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=430229#c8 --- Comment #8 from Stefan Hundhammer <sh@novell.com> 2008-09-30 05:17:38 MDT --- "man fork" says: "The child process is created with a single thread — the one that called fork(). The entire virtual address space of the parent is replicated in the child, including the states of mutexes, condition variables, and other pthreads objects; the use of pthread_atfork(3) may be helpful for dealing with problems that this can cause." -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=430229 User dmueller@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=430229#c9 --- Comment #9 from Dirk Mueller <dmueller@novell.com> 2008-09-30 05:33:10 MDT --- · else if (child_pid == 0) · { · · close (data_pipe[0]); // close the read-only FD · · int state = · · FPrintAPI::instance().acquire (data_pipe[1], path); · · y2milestone ("acquire done with state %d", state); · · close (data_pipe[1]); · · exit (state); · } you should call _exit() to exit the child process, not exit(). -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=430229 Dirk Mueller <dmueller@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEEDINFO |ASSIGNED Info Provider|visnov@novell.com | -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=430229 User sh@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=430229#c10 --- Comment #10 from Stefan Hundhammer <sh@novell.com> 2008-09-30 05:42:17 MDT --- Why the segfault probably happened: YUI has a member variable pthread_t _uiThread where the thread handle for the UI thread is stored. fork() of course copies that member variable, too, along with all other data of the original process. But this _uiThread has now become invalid since only the main thread (the YCP thread) has been copied. Based on the value of this YUI::_uiThread, however, the YUI destructor tries to shut down that other thread - which fails. There is no other thread at that memory location. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=430229 User sh@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=430229#c11 --- Comment #11 from Stefan Hundhammer <sh@novell.com> 2008-09-30 05:43:22 MDT --- I'd like to make that code more robust against this, but I don't see a chance to do that; I'd need to get some notification when somebody outside the UI calls fork() and invalidate YUI::_uiThread. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=430229 User dmueller@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=430229#c12 --- Comment #12 from Dirk Mueller <dmueller@novell.com> 2008-10-01 02:07:37 MDT --- It should just work fine in this case when the one liner fix is applied. if not, please attach a valgrind trace. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=430229 User jsuchome@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=430229#c13 --- Comment #13 from Jiří Suchomel <jsuchome@novell.com> 2008-10-01 02:41:14 MDT --- (In reply to comment #12 from Dirk Mueller)
It should just work fine in this case when the one liner fix is applied. if not, please attach a valgrind trace.
Yes, it was enough. Thanks a much! -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=430229 User jsuchome@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=430229#c14 Jiří Suchomel <jsuchome@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution| |FIXED --- Comment #14 from Jiří Suchomel <jsuchome@novell.com> 2008-10-01 03:58:56 MDT --- fixed in svn now -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
participants (1)
-
bugzilla_noreply@novell.com