Re: [Gimp-developer] soft handling of X11 errors (Was: Unplugging Wacom crashes GIMP)

2009-08-05 Thread gg
Martin Cracauer wrote:
> wino wrote on Wed, Aug 05, 2009 at 05:12:58PM +0200: 
>> Martin Cracauer wrote:
>>> [Keeping quote below for reference]
>>>
>>> The is another class of X11 errors that GIMP should survive:
>> That was my first reaction on seeing the Wacom issue.
>>
>> It sounds to me like a memory object related to the resource has been 
>> distroyed and gimp is accessing a now invalid pointer.
> 
> No, it's not a segfault.
> 
> It is errors from system calls (as in return -1, set errno) when
> reading the pipes connecting GIMP through the X11 server to these
> devices and displays.
> 
>> If this crashes gimp it is a messy bug that reveals insufficient error 
>> handling. This sort of exception should be trapped and dealt with 
>> without gimp falling on it's arse.
> 
> But it's messy.  X11 error handling is often left at the default error
> handlers (which exit the application).  Explicitly dealing with them
> will require you to sort out what exactly the error condition was
> connected to, whether there was a device that caused this and whether
> it is optional.  Then, if it was a device or display that is allowed
> to go away, you need to clean up the application (GIMP) to remove
> entries that tell GIMP to communicate with these devices (such as the
> display draw routine drawing on all displays it knows about) to make
> them forget about the optional device that reported an error.
> 
> When you are finished with that you will also have to deal with the
> fact that errors might come from other conditions than these devices
> going away.  Presumably you'd want to attempt a recovery of some sort
> in some cases.  Just throwing errnous devices out is better that
> exit(), though.
> 
> To make the mess complete, X11 error handling inside a GTK+
> application isn't exactly the same thing either.
> 
> Martin
> 

oops, cross post with Martins reply to my earlier message that missed 
the ML due to wrong sender.

Thanks for the detailed account , Martin.

So whatever the thorough way to completely recover from such an error 
(which sounds like hard work), should not something be done to prevent 
gimp just dumping out and losing any current work changes?

/gg
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] soft handling of X11 errors (Was: Unplugging Wacom crashes GIMP)

2009-08-05 Thread Martin Cracauer
wino wrote on Wed, Aug 05, 2009 at 05:12:58PM +0200: 
> Martin Cracauer wrote:
> >[Keeping quote below for reference]
> >
> >The is another class of X11 errors that GIMP should survive:
> 
> That was my first reaction on seeing the Wacom issue.
> 
> It sounds to me like a memory object related to the resource has been 
> distroyed and gimp is accessing a now invalid pointer.

No, it's not a segfault.

It is errors from system calls (as in return -1, set errno) when
reading the pipes connecting GIMP through the X11 server to these
devices and displays.

> If this crashes gimp it is a messy bug that reveals insufficient error 
> handling. This sort of exception should be trapped and dealt with 
> without gimp falling on it's arse.

But it's messy.  X11 error handling is often left at the default error
handlers (which exit the application).  Explicitly dealing with them
will require you to sort out what exactly the error condition was
connected to, whether there was a device that caused this and whether
it is optional.  Then, if it was a device or display that is allowed
to go away, you need to clean up the application (GIMP) to remove
entries that tell GIMP to communicate with these devices (such as the
display draw routine drawing on all displays it knows about) to make
them forget about the optional device that reported an error.

When you are finished with that you will also have to deal with the
fact that errors might come from other conditions than these devices
going away.  Presumably you'd want to attempt a recovery of some sort
in some cases.  Just throwing errnous devices out is better that
exit(), though.

To make the mess complete, X11 error handling inside a GTK+
application isn't exactly the same thing either.

Martin

> 
> /gg
> 
> 
> 
> >
> >when you have a view on another display, these days you can open an
> >entirely new display, on a different computer.  Works great as such, I
> >use it regularly.
> >
> >However, if you shut down that display (or the computer that it is
> >running on, or the network or the ssh forwarder) while the view is in
> >use, then GIMP crashes.
> >
> >In both cases, the disappearing display and the disappearing device,
> >what GIMP would need is a resource stack that is supposed to be
> >unrolled on certain X11 errors.  At the top of that cleanup stack
> >should be a GIMP that is still running but has forgotten about the
> >device or display that caused the error.
> >
> >Martin
> >
> >Alexia Death wrote on Wed, Aug 05, 2009 at 09:03:50AM +0300: 
> >>On Wed, Aug 5, 2009 at 12:26 AM, Patrick Horgan  
> >>wrote:
> >>
> >>>1) If I plug it in after the gimp is already started it isn't recognized
> >>>as a tablet, i.e. doesn't appear as an extended input device that can be
> >>>configured and works only as a mouse.
> >>>2) If I plug it in before starting the gimp, it's recognized and works
> >>>well, but if I unplug it before exiting the gimp, gimp will crash in a
> >>>little bit.
> >>>
> >>>Inkscape has exactly the same behavior including the crash.
> >>
> >>This is a known issue, and exists because there is no agreed interface  
> >>for
> >>X to tell applications about appearing and disapearing devices(there is
> >>DBUS, but im not sure if X sends the type notifications needed for this 
> >>use)
> >>and no mechanism in the toolkits(in this case, GTK) to handle it, because
> >>its rather new for X to have appearing and disapearing input devices. Gimp
> >>sees what devices are available on startup and wont be aware of the 
> >>devices
> >>added later. When you remove a device however, gimp(or rather GTK IIRC) 
> >>will
> >>try to get data from a noinexisting device and crash. I quickly looked at
> >>the issue when I encountered it myself and it was quite above ma
> >>capabilities to fix,  but I dont remember the details any more.
> >>
> >>-- 
> >>--Alexia
> >>
> >>P.S Sorry for the spam, Patrick.
> >
> >>___
> >>Gimp-developer mailing list
> >>Gimp-developer@lists.XCF.Berkeley.EDU
> >>https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer
> >
> >

-- 
%%%
Martin Cracauerhttp://www.cons.org/cracauer/
FreeBSD - where you want to go, today.  http://www.freebsd.org/
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


Re: [Gimp-developer] soft handling of X11 errors (Was: Unplugging Wacom crashes GIMP)

2009-08-05 Thread Martin Cracauer
[Keeping quote below for reference]

The is another class of X11 errors that GIMP should survive:

when you have a view on another display, these days you can open an
entirely new display, on a different computer.  Works great as such, I
use it regularly.

However, if you shut down that display (or the computer that it is
running on, or the network or the ssh forwarder) while the view is in
use, then GIMP crashes.

In both cases, the disappearing display and the disappearing device,
what GIMP would need is a resource stack that is supposed to be
unrolled on certain X11 errors.  At the top of that cleanup stack
should be a GIMP that is still running but has forgotten about the
device or display that caused the error.

Martin

Alexia Death wrote on Wed, Aug 05, 2009 at 09:03:50AM +0300: 
> On Wed, Aug 5, 2009 at 12:26 AM, Patrick Horgan  wrote:
> 
> >
> > 1) If I plug it in after the gimp is already started it isn't recognized
> > as a tablet, i.e. doesn't appear as an extended input device that can be
> > configured and works only as a mouse.
> > 2) If I plug it in before starting the gimp, it's recognized and works
> > well, but if I unplug it before exiting the gimp, gimp will crash in a
> > little bit.
> >
> > Inkscape has exactly the same behavior including the crash.
> 
> 
> This is a known issue, and exists because there is no agreed interface  for
> X to tell applications about appearing and disapearing devices(there is
> DBUS, but im not sure if X sends the type notifications needed for this use)
> and no mechanism in the toolkits(in this case, GTK) to handle it, because
> its rather new for X to have appearing and disapearing input devices. Gimp
> sees what devices are available on startup and wont be aware of the devices
> added later. When you remove a device however, gimp(or rather GTK IIRC) will
> try to get data from a noinexisting device and crash. I quickly looked at
> the issue when I encountered it myself and it was quite above ma
> capabilities to fix,  but I dont remember the details any more.
> 
> -- 
> --Alexia
> 
> P.S Sorry for the spam, Patrick.

> ___
> Gimp-developer mailing list
> Gimp-developer@lists.XCF.Berkeley.EDU
> https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


-- 
%%%
Martin Cracauerhttp://www.cons.org/cracauer/
FreeBSD - where you want to go, today.  http://www.freebsd.org/
___
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer