Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential crash because of exception in WL event handler #112

Open
iusyk opened this issue May 27, 2020 · 1 comment
Open

Potential crash because of exception in WL event handler #112

iusyk opened this issue May 27, 2020 · 1 comment

Comments

@iusyk
Copy link
Collaborator

iusyk commented May 27, 2020

Description

Event handler OnDevice is registered in wl_drm_listener
The code of the handler make the instance(in heap) of type DisplayWayland.
The class DisplayWayland inherits the Drm::Display, the ctor of which can throw the exception (type Exception)
In general - event handler must not throw the exception because there are not any guarantees that C code can handle it
see code

void WaylandZCopy::onDevice(const string& name)
{
lock_guard lock(mMutex);

LOG(mLog, DEBUG) << "onDevice name: " << name;

mDrmDevice.reset(new Drm::DisplayWayland(name));

authenticate();

}

Display::Display ()
{
...
if (mDrmFd < 0)
{
throw Exception("Cannot open DRM device: " + mName, errno);
}
...
if (drmGetCap(mDrmFd, DRM_CAP_DUMB_BUFFER, &hasDumb) < 0 || !hasDumb)
{
throw Exception("Drm device does not support dumb buffers", errno);
}
}

Solution

Wrap code inside OnDevice in block try{}catch(const Exception&){}

iusyk added a commit to iusyk/displ_be that referenced this issue Jun 18, 2020
Reference:xen-troops#112

The event handler (onDevice) does not catch an exception.
The code is wrapped into try-catch block

Signed-off-by: Ihor Usyk <[email protected]>
@iusyk
Copy link
Collaborator Author

iusyk commented Jun 18, 2020

fix #129

iusyk added a commit to iusyk/displ_be that referenced this issue Jun 24, 2020
Reference:xen-troops#112

The event handler (onDevice) does not catch an exception.
The code is wrapped into try-catch block

Signed-off-by: Ihor Usyk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant