Analysis-Utilities 26.9.9
C++/ROOT utilities for nuclear measurement data analysis
Loading...
Searching...
No Matches
InteractiveEditorX11Guard.hpp File Reference

Stops a recoverable X protocol error from becoming a fatal SIGSEGV. More...

#include <Rtypes.h>
#include <dlfcn.h>
Include dependency graph for InteractiveEditorX11Guard.hpp:

Go to the source code of this file.

Classes

struct  AUXErrorHandlerSave
 What AUInstallTolerantXErrorHandler() needs in order to undo itself. More...

Typedefs

typedef int(* AUXErrorHandler) (void *display, void *event)
 Xlib error handler signature, with opaque pointers so that no libX11 headers are needed here.
typedef AUXErrorHandler(* AUXSetErrorHandlerFn) (AUXErrorHandler)
 Signature of XSetErrorHandler itself, resolved via dlsym.

Functions

int AUIgnoreXError (void *, void *)
 The tolerant handler: ignores the error and reports success.
AUXErrorHandlerSave AUInstallTolerantXErrorHandler ()
 Install the tolerant X error handler for the duration of an event loop.
void AURestoreXErrorHandler (AUXErrorHandlerSave s)
 Put back the handler that was in place before the tolerant one.

Detailed Description

Stops a recoverable X protocol error from becoming a fatal SIGSEGV.

When a TGTextEntry (the editors' number entries, for instance) is redrawn through the TTF backend, TGX11TTF::DrawString issues an XGetGeometry round-trip on the widget's drawable. If that drawable is momentarily stale the X server answers with BadWindow / BadDrawable. Xlib then calls ROOT's RootX11ErrorHandler, which looks the offending window up by id and calls a virtual method on it to format the message — and if that window object is already gone, the handler itself crashes. A recoverable protocol error thus becomes a fatal SIGSEGV that takes down the entire ROOT session.

While an interactive editor pumps its own event loop, these helpers install a no-op handler that swallows such errors — Xlib ignores the return value for non-fatal errors and carries on — and then restore the previous one.

XSetErrorHandler is resolved at runtime via dlsym, so this library keeps no link-time dependency on libX11; the symbol comes from libX11, which ROOT's GUI libraries load transitively whenever a gClient exists.

Definition in file InteractiveEditorX11Guard.hpp.

Typedef Documentation

◆ AUXErrorHandler

typedef int(* AUXErrorHandler) (void *display, void *event)

Xlib error handler signature, with opaque pointers so that no libX11 headers are needed here.

Definition at line 31 of file InteractiveEditorX11Guard.hpp.

◆ AUXSetErrorHandlerFn

typedef AUXErrorHandler(* AUXSetErrorHandlerFn) (AUXErrorHandler)

Signature of XSetErrorHandler itself, resolved via dlsym.

Definition at line 34 of file InteractiveEditorX11Guard.hpp.

Function Documentation

◆ AUIgnoreXError()

int AUIgnoreXError ( void * ,
void *  )
inline

The tolerant handler: ignores the error and reports success.

Returns
Always 0; Xlib disregards this for non-fatal errors.

Definition at line 38 of file InteractiveEditorX11Guard.hpp.

Referenced by AUInstallTolerantXErrorHandler().

◆ AUInstallTolerantXErrorHandler()

AUXErrorHandlerSave AUInstallTolerantXErrorHandler ( )
inline

Install the tolerant X error handler for the duration of an event loop.

Resolves XSetErrorHandler from the default symbol scope; if libX11 was loaded with local scope the lookup is retried against an RTLD_NOLOAD handle, which promotes the already-mapped library rather than loading a second copy.

Returns
State to hand to AURestoreXErrorHandler(). If the symbol could not be resolved the call is a silent no-op and restoring is harmless, so the result never needs checking.
Warning
This suppresses all non-fatal X protocol errors for the whole process while installed, not just the redraw race it targets. Keep the window as narrow as the editor loop, and always pair it with AURestoreXErrorHandler().

Definition at line 70 of file InteractiveEditorX11Guard.hpp.

Referenced by LaunchInteractiveFitEditor(), LaunchInteractiveRooFitEditor(), and LaunchInteractiveSimultaneousFitEditor().

◆ AURestoreXErrorHandler()

void AURestoreXErrorHandler ( AUXErrorHandlerSave s)
inline

Put back the handler that was in place before the tolerant one.

Parameters
sValue returned by AUInstallTolerantXErrorHandler(). Safe to pass a state whose resolution failed; the call then does nothing.

Definition at line 90 of file InteractiveEditorX11Guard.hpp.

Referenced by LaunchInteractiveFitEditor(), LaunchInteractiveRooFitEditor(), and LaunchInteractiveSimultaneousFitEditor().