[Mesa-users] Is there a better way to validate wl_display passed in at eglGetDispaly()?
Ruei, Eric
e-ruei1 at ti.com
Fri Jan 27 18:29:18 UTC 2017
To whom it may concern:
We would like to bring your attention to a potential wayland-egl issue with openCV Python script.
The issue is that both Mesa and our mechanism to identify the wl_display client from eglGetDIspaly() call fails for openCV Python script.
Mesa implementation:
...
if (_eglPointerIsDereferencable(nativeDisplay)) {
void *first_pointer = *(void **) nativeDisplay;
(void) first_pointer; /* silence unused var warning */
#ifdef HAVE_WAYLAND_PLATFORM
/* wl_display is a wl_proxy, which is a wl_object.
* wl_object's first element points to the interfacetype. */
if (first_pointer == &wl_display_interface)
return _EGL_PLATFORM_WAYLAND;
#endif
TI wayland-egl WS implementation:
if (hNativeDisplay && is_ptr(hNativeDisplay)) {
struct wl_display *dpy = (struct wl_display *)hNativeDisplay;
if (*(void **)dpy == &wl_display_interface)
return WSEGL_SUCCESS;
}
The problem is that the link address of wl_dispaly_interface at the caller and callee of API eglGetDispaly(wl_dispaly) are different.
Here is what we found:
The following parameters from libwayland-client.so are dumped at three different *.so location.
§ mDisplay(dpy): struct wl_display* return from API wl_display_connect
§ *mDisplay(*dby): the first element within struct wl_display and it should be a pointer to constant table wl_display_interface
§ &wl_display_interface: address of this const table (@libwayland-client.so)
§ wl_display_interface.name: the first entry within the wl_display_interface and it should be "wl_display"
§ wl_display_connect: address of this API (@libwayland-client.so)
What I found is that the const table wl_display_interface resides at different location at different *.so as shown below:
libQt5WaylandClient.so: mDisplay is created here and therefore all parameters are consistent:
QWaylandDisplay: mDisplay=0xd6770, *mDisplay=0xb0b0c6ac &wl_display_interface=0xb0b0c6ac, wl_display_interface.name=wl_display, wl_display_connect=0xb0cb5aec,
init done
QT plugins\wayland-graphics-integration-client\libwayland-egl.so: only wl_display_interface is moved, the API wl_display_connect stays at the same location:
QWaylandEglClientBufferIntegration::initialize: mDisplay=0xd6770, *mDisplay=0xb0b0c6ac &wl_display_interface=0xb0cc9970, wl_display_interface.name=wl_display, wl_display_connect=0xb0cb5aec
SGX DDK libpvrws_WAYLAND.so: only wl_display_interface is moved, the API wl_display_connect stays at the same location
wlpvr: dpy=0xd6770, *dpy=0xb0b0c6ac &wl_display_interface=0xb1df96b0 wl_display_connect =0xb0cb5aec, wl_display_interface.name=wl_display
With python openCV API cv2.imShow, the location of data table such as wl_display_interface is moved at each plugin as shown at the previous comment. However, the table content seems to be preserved at the old location. The following log shows the table content at the first and last location.
// old location = 0xb0bb46ac, new location = 0xb1ea16b0
wlpvr: dpy=0xd6770, *dpy=0xb0bb46ac &wl_display_interface=0xb1ea16b0 wl_display_connect =0xb0d5daec, wl_display_interface.name=wl_display
// new location; name @0xb1e905f8 = "wl_display", where methods and events are also table pointers
wlpvr: wl_display_interface (new location):name=0xb1e905f8, version=1, method_count=2, methods=0xb1ea16e0, event_count=2, events=0xb1ea16c8
// old location: name @0xb0b7c228 = "wl_display"
wlpvr: wl_display_interface:name=0xb0b7c228, version=1, method_count=2, methods=0xb0bb46dc, event_count=2, events=0xb0bb46c4
We have also confirmed that the WL connection handle wl_display still works even though it still points to the old interface table.
Best regards,
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-users/attachments/20170127/c3c2e9c8/attachment.html>
More information about the mesa-users
mailing list