Re: signal handler problems in screenshot plug-in

2000-11-08 Thread Raphael Quinet

On Tue, 07 Nov 2000, Sven Neumann [EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] (Raphael Quinet) writes:
  I think that the best way to fix the screenshot plug-in is to add this
  before the call to fork():
gimp_signal_private (SIGCHLD, SIG_DFL, SA_RESTART);
  (don't forget to #include libgimp/gimpsignal.h)
 
 This seems to work fine (at least under Linux). I'm only wondering why
 the gz, bzip2 and mail plugins do work under Solaris then. Or is this
 not the case ?

Alas, these plug-ins have been broken under Solaris since a couple of
months.  I thought this was reported in the bug database, but
apparently it isn't.  That should have been a "grave" bug, at least.

And the fix is exactly the same as for the screenshot plug-in:
- make the code safer by checking the return value of waitpid, as
  described in my followup to #27786,
- include libgimp/gimpsignal.h,
- call gimp_signal_private (SIGCHLD, SIG_DFL, SA_RESTART) before
  calling fork().

A quick grep shows the list of plug-ins that call waitpid() in an
unsafe way (do not check the result) and are affected by the race
condition between the system call and the signal handler:

- plug-ins/common/bz2.c (twice, for loading and saving)
- plug-ins/common/gz.c (twice, for loading and saving)
- plug-ins/common/mail.c
- plug-ins/common/screenshot.c
- plug-ins/common/url.c (twice, with ifdef/ifndef __EMX__)

The print plug-in also calls waitpid, but it uses it only for its
blocking effect and not for collecting the status of the child, so
this plug-in is safe.  It looks like all plug-ins authors copied and
pasted the same code, because the same structure and the same argument
names are used in all plug-ins.  But this code was wrong: it was
unsafe since the begining in 1.0.x, and broken when the new signal
handlers were installed.  It's a pity that the problem was not
detected and fixed earlier (I am partly to blame for that, because I
knew the problem and I did not check if it was reported in the bug
database - I just told my users to avoid compressing files until the
bugs were found and fixed).

Anyway, I just fixed these five plug-ins and the patch should be in
the incoming directory of ftp.gimp.org in a few minutes.

Regarding bug #27786, I don't know if it is still open or not.  I do
not see any crashes under Solaris 2.6, but maybe Solaris 8 is still
affected by the bug that was originally reported by Austin Donnelly.
Could someone test this, as I don't have access to a Solaris 8 machine
right now?

-Raphael




Re: signal handler problems in screenshot plug-in

2000-11-07 Thread Sven Neumann

Hi,

[EMAIL PROTECTED] (Raphael Quinet) writes:

 I took a look at bug #27786 "screenshot plugin on Solaris takes bus
 error on exit" because I wanted to see if I could reproduce it.  Well,
 I got another problem: the screenshot plug-in exits with "xwd didn't
 work" before giving any results.  If my followup message makes it to
 #27786 (http://bugs.gnome.org/db/27/27786.html), you will read that
 xwd does work but the plug-in thinks that it doesn't.  As a result, it
 exits prematurely and leaves the temporary files in the user's dir.
 
 I tried to debug this and I finally came to the conclusion that
 waitpid() fails because the SIGCHLD signal handler installed by
 libgimp steals the return status of the xwd child before waitpid() in
 screenshot.c has a chance to get it.  In libgimp/gimp.c, the signal
 handler gimp_plugin_sigchld_handler() calls waitpid() in a loop and
 throws away the child status before returning.

 I think that the best way to fix the screenshot plug-in is to add this
 before the call to fork():
   gimp_signal_private (SIGCHLD, SIG_DFL, SA_RESTART);
 (don't forget to #include libgimp/gimpsignal.h)

This seems to work fine (at least under Linux). I'm only wondering why
the gz, bzip2 and mail plugins do work under Solaris then. Or is this
not the case ?


Salut, Sven




Re: signal handler problems in screenshot plug-in

2000-11-07 Thread Nem W Schlecht

Sven Neumann e-mailed me on Tue Nov  7 12:37:43 2000
(Re: "Re: signal handler problems in screenshot plug-in")

 I took a look at bug #27786 "screenshot plugin on Solaris takes bus

 I think that the best way to fix the screenshot plug-in is to add this
 before the call to fork():
   gimp_signal_private (SIGCHLD, SIG_DFL, SA_RESTART);
 (don't forget to #include libgimp/gimpsignal.h)

This seems to work fine (at least under Linux). I'm only wondering why
the gz, bzip2 and mail plugins do work under Solaris then. Or is this
not the case ?

This *is* the case, at least under Solaris 8_x86.  None of these plugins
work for me.

-- 
Nem W Schlecht   [EMAIL PROTECTED]
Empyreal Technologieshttp://www.emptec.com/
"Perl did the magic.  I just waved the wand."