Is it safe to do something like this?
int foo(Display*, XErrorEvent*) {
throw 0;
}
XSetErrorHandler(foo);
I won’t run into any troubles?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
An X11 error handler is a callback provided by the user and called by Xlib. Any exception thrown from an error handler will propagate through Xlib code down to user code calling Xlib (typically XNextEvent or friends).
Since Xlib is not written in C++, the C++ runtime does not necessarily know how to do the stack unwinding of Xlib code. Even if it by sheer luck manages to do the unwinding correctly, resources such as memory allocated by Xlib prior to calling the error handler may be lost. There are no automatic destructors in C!