After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 147883 - [PATCH] ximagesink/xvimagesink do not allow for a way to backtrace on X errors
[PATCH] ximagesink/xvimagesink do not allow for a way to backtrace on X errors
Status: RESOLVED NOTABUG
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2004-07-19 11:43 UTC by Thomas Vander Stichele
Modified: 2006-03-09 14:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch to backup/set error handler and GST_ELEMENT_ERROR call from _chain (5.54 KB, patch)
2004-07-19 11:44 UTC, Thomas Vander Stichele
needs-work Details | Review

Description Thomas Vander Stichele 2004-07-19 11:43:37 UTC
by setting an X error handler, one can break on the error handler to figure out
(in synchronous mode) what call triggers the X error.
Comment 1 Thomas Vander Stichele 2004-07-19 11:44:30 UTC
Created attachment 29648 [details] [review]
patch to backup/set error handler and GST_ELEMENT_ERROR call from _chain
Comment 2 David Schleef 2004-07-19 14:11:22 UTC
by setting an X error handler, you break gdk.
Comment 3 Thomas Vander Stichele 2004-07-19 14:21:47 UTC
I think we can still chain up to the old handler by just calling it, no ?
Comment 4 Benjamin Otte (Company) 2004-07-19 15:00:27 UTC
That is very ugly, because it causes side effects in unrelated parts of the
program (other ximagesinks). It also doesn't recover from errors in other parts
of the code - like state changes or buffer allocations, that might not even be
critical (-ENOMEM on buffer alloc for example).

I'd suggest that if you want to be able to debug X errors, use a global mapping
of display <=> element and properly lock it when adding/removing/querying
elements from this mapping.
And check the error stuff after every XSync, if you have avoidable errors (like
buffer_alloc).
Comment 5 Benjamin Otte (Company) 2004-07-19 15:04:19 UTC
Whoops, XSetErrorHandler is not per display but global?

In that case I'd not use it at all, because you cannot guarantee it works
correctly with other error handlers set by other libs/applications.
Comment 6 Thomas Vander Stichele 2004-07-19 15:20:37 UTC
XSetErrorHandler is fine, it's setting a global boolean from the handler that is
the problem.

for making it work with more than one sink, yes, using a global hash of displays
is what I would use.  Only atm it's not that critical since we don't actually
use two sinks at the same time, and even if you do all that will happen is that
concurrent errors will get discarded.
Comment 7 Benjamin Otte (Company) 2004-07-19 18:58:18 UTC
What will happen is that an error for ximagesink1 is triggered and ximagesink2
throws an error.

What will also happen is that libfoo installs a custom error handler, GStreamer
installs a custom error handler, libfoo uninstalls the custom error handler and
then GStreamer uninstalls the custom handler, resetting it to libfoo's handler
(that should already be uninstalled).

Those are 2 bugs I don't want in my code for no real benefit at all.
Comment 8 Thomas Vander Stichele 2004-07-20 10:46:47 UTC
heh, we need the error handler since that's the only way we can check if some
functions (like, XvPutImage) that can fail for whatever reason have failed. 
Let's not conjecture what XSetErrorHandler does, but look into it and verify it.
 Let's not worry about other libs that do the wrong thing when
installing/removing handlers, but make sure GStreamer does the right thing.
Comment 9 David Schleef 2004-07-20 14:25:21 UTC
I already know how XSetErrorHandler() works.  If you set an error handler, you
will steal errors from gdk.

You can attempt to work around it; XSetErrorHandler() will return the old error
handler, and you can call that if a particular error is not for your display,
but this is a problem a) if ximagesink is initialized before gdk (because gdk
will simply complain and abort instead of calling the ximagesink error handler)
or b) if you have multiple ximagesinks, and attempt to free them in a different
order than allocated.

It's not too bad if one sets an error handler, runs some operations, calls
XSync(), and then sets the old error handler.  But having an error handler set
all the time should be reserved for gdk, since gdk really needs it.
It's a problem in Xlib.  It sucks, I know.
Comment 10 Julien MOUTTE 2004-07-26 10:02:36 UTC
I don't think setting an error handler in x(v)imagesink will interfere with gdk
because x(v)imagesink opens its own connection (Display) to the X server.
Comment 11 David Schleef 2004-07-28 02:29:52 UTC
I thought of one reason why one would use XSync() -- between creating an X
window and handing off the XID of that window via an xoverlay call.  The XSync
call guarantees the X server knows about the window before the other caller
attempts to use the window from a different connection.
Comment 12 Stephane Loeuillet 2004-12-12 14:20:02 UTC
confirming bug, adding PATCH keyword
Comment 13 Ronald Bultje 2005-01-29 11:54:50 UTC
Comment on attachment 29648 [details] [review]
patch to backup/set error handler and GST_ELEMENT_ERROR call from _chain

It can be useful for debugging. Therefore, add a property (like the sync
property) to only set the error handler if the specific property is set. That
can be useful for gs-tlaunch pipelines. You also don't need to store the old
handler then, because it'll break anyway. Setting to needs-work to reflect
this.
Comment 14 Andy Wingo 2006-01-11 16:07:52 UTC
Updating for plugins-base and the version. But it's been a year, what's up with this? Julien?
Comment 15 Julien MOUTTE 2006-03-05 20:55:20 UTC
I think we should leave the error handling to gdk.

I don't think that patch is usefull.
Comment 16 Wim Taymans 2006-03-09 14:30:04 UTC
closing, the x(v)imagesink jedi has spoken.