stweil / OSXvnc

VNC Server for macOS
GNU General Public License v3.0
198 stars 64 forks source link

The server crashes if the remote cursor shape changes #34

Open mykola-mokhnach opened 5 years ago

mykola-mokhnach commented 5 years ago

It looks like the current implementation of cursor bitmap capture does not properly handle "locate cursor" feature which is available in the recent MacOS releases (the arrow grows in size for a moment if one shakes it for a while)

stweil commented 5 years ago

I cannot reproduce this issue. The cursor grows when I shake it on the Mac with macOS 10.13.6, I have OSXvnc-server -rfbnoauth running on the same Mac. A Linux vncclient ist connected. That setting works with no crash.

stweil commented 5 years ago

The crash dump looks like it might be related to something unexpected in your copy+paste buffer.

mykola-mokhnach commented 5 years ago

Sorry, the screenshot is from the other crash. The original issue was happening inside loadCurrentCursorData, free_tiny call. Unfortunately I didn't save the original stack trace and I am unable to reproduce it right now.

But anyway thanks for looking into it.

mykola-mokhnach commented 5 years ago

For me it looked like there was some race condition while we were trying to call free(cursorData);, but I cannot say for sure

mykola-mokhnach commented 5 years ago
    cursorData = (unsigned char*)malloc(sizeof(unsigned char) * cursorDataSize);
    err = CGSGetGlobalCursorData(connection,
                                 cursorData,
                                 &cursorDataSize,
                                 &cursorRowBytes,
                                 &cursorRect,
                                 &hotspot,
                                 &cursorDepth,
                                 &components,
                                 &cursorBitsPerComponent);

    //CGSReleaseConnection(connection);
    if (err != kCGErrorSuccess) {
                // maybe cursorDataSize here is not the same as it was while malloc has been executed
        free(cursorData);
stweil commented 5 years ago

CGSGetGlobalCursorData seems to be an undocumented function. Either we need a documented method to get the cursor image, or we simply ignore the cursor image and always use the same cursor on the VNC viewer side.

stweil commented 5 years ago

Some links:

stweil commented 5 years ago

@mykola-mokhnach, would it be acceptable to use the default cursor on the viewer side (until someone finds working code to get the cursor image)?