matyalatte / libui-rubiks-demo

Small and portable app to play with 3x3x3 rubiks cube
MIT License
1 stars 0 forks source link

Segmentation fault occurs when the mouse is over the window on Ubuntu #1

Closed kojix2 closed 7 months ago

kojix2 commented 7 months ago

Hi @matyalatte

Thank you for sharing your project. https://github.com/libui-ng/libui-ng/issues/251#issuecomment-1837048418

I tried this rubiks cube program on Ubuntu. I found that the program crashes when I move the mouse over the window. It crashes on the following line

https://github.com/libui-ng/libui-ng/blob/ac1c0d55f8da2dcacb6bc7a4da7702176d0de2da/unix/area.c#L311

static gboolean onCrossing(areaWidget *aw, int left)
{
    uiArea *a = aw->a;

    (*(a->ah->MouseCrossed))(a->ah, a, left);     // here
    uiprivClickCounterReset(a->cc);
    return GDK_EVENT_PROPAGATE;
}
(gdb) print a
$1 = (uiA$1 = (uiArea *) 0x63e0b0
(gdb) print a->ah
$2 = (uiAreaHandler *) 0x7fffffffd970
(gdb) print a->ah->MouseCrossed
$3 = (void (*)(uiAreaHandler *, uiArea *, int)) 0x7fffffffd9a0
Thread 1 Thread 1 "libui_rubiks_de" received signal SIGSEGV, Segmentation fault.
0x00007fffffffd9a0 in ?? ()

If it works fine on non-Unix platforms, it may be a potential bug in libui-ng?


DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=23.10
DISTRIB_CODENAME=mantic
DISTRIB_DESCRIPTION="Ubuntu 23.10"
libgtk-3 3.24.38-5ubuntu1
matyalatte commented 7 months ago

Thanks for the report! Sorry, I didn't test debug builds. I used a preset for release builds and it worked somehow...

Can you try the latest commit? I think I fixed the bug at 6171fe78fda8a5fbc90a9495ac91354e8054287d

(edit) Tested with the debug build on Ubuntu20.4.

https://github.com/matyalatte/libui-rubiks-demo/assets/69258547/44b0dcd2-48ef-452d-9607-9ff38f0bb368

kojix2 commented 7 months ago

Thank you. This worked fine :tada: