Are you saying you see two problems ? A freeze at the end of debugging AND whenever Lazarus itself calls Application.ProcessMessages ? Or ONLY at the end of a debugging session ? (Lazarus itself probably calls PrrocessMessages lots of time before then).
I see a message that the IDE has crashed in the Application.ProcessMessages with an Access Violation error only at the end of debugging.
Apparently, the error itself is not related to debugging and Application.ProcessMessages. But it occurs in the code somewhere along the way.
Here are my observations of the IDE's behavior step by step.
1) Opening the IDE.
2) Creating a new project (not necessarily a graphical application). That is, even the usual console program, which does not use the Application object.
3) Select the project parameters: namely, we create debugging and release build modes. (Project->Project options->Compiller options->...->Create debug and release modes)
4) Start debugging via F9 or by clicking on the panel in the main window.
4.1) The IDE moves windows from the development desktop mode to the debugging desktop.
4.2) Closing the program (or it terminates itself if it is not an Application).
4.3) The IDE moves windows from the debugging desktop mode to the development desktop.
4.4) The following message appears in the console from which ./startlazarus is launched: Application.ProcessMessages crashed with Access violation
4.5) Everything freezes. Rather, the windows are being redrawn, but all the elements in them are no longer responding.
I found out the order of paragraph 4.4 by running lazarus through gdb
Can you run other gtk2 apps ?
As I have already found out, the problem is not even in gtk. The rest of the programs are working normally. The error appears only in one place in the IDE (i.e. not even in the Application.ProcessMessages).
Most likely, there is something in the window release code after debugging when using gtk. Because the environment is actively changing the position and set of desktop windows.
A very wild guesses, please check libx11-xcb is installed. (But if not Wayland system, using gtk2, probably not needed).
$ eix x11-libs/libxcb
[I] x11-libs/libxcb
Доступные версии: 1.17.0(0/1.12)^t {doc selinux test +xkb ABI_MIPS="n32 n64 o32" ABI_S390="32 64" ABI_X86="32 64 x32"}
Установленные версии: 1.17.0(0/1.12)^t(23:25:32 18.05.2024)(xkb -doc -selinux -test ABI_MIPS="-n32 -n64 -o32" ABI_S390="-32 -64" ABI_X86="32 64 -x32")
Домашняя страница: https://xcb.freedesktop.org/ https://gitlab.freedesktop.org/xorg/lib/libxcb
Описание: X C-language Bindings library
1.17.0
Even wilder suggestion, as Lazarus development if focused on using its own internal, debugger, possible that incompatibilities with gdb have slipped in. Especially in an rare system like Gentoo. So, again, I suggest switching to the internal debugger.
I've already tried it. The problem remains.
Otherwise, I really don't know. strace might just be the next step !
https://disk.yandex.ru/d/I_qMV4EHBf4YkAIf debugging works under Qt5 and Qt6, why not just use them ? I consider Qt5/6 far better alternatives than gtk2 as already some distros are leaving gtk2 out, its a 200meg download and Qt5 only about 45Meg (preinstalled on your KDE). And its most likely any bug you are chasing will be in your own code and therefore show up in gtk2/Qt5/6. I know thats a weak solution but spending too much time on gtk2 is not a great idea!
That's just Lazarus from source, by default it is built specifically to work with gtk2.
Are you using a docked IDE ? (AnchorDocking?)
No.
In the main window, underneath the main menu is an icon (first row) depicting a "computer monitor" with a dropdown. It allows you to switch desktops. Does that get the crash too?
No.
Alternatively in menu: Tools > Options
Page: Debugger > Debugger Backend
at the top is a dropdown, choose the gdb debugger.
Test if the issue still happens.
I've already tried that. I found out that it wasn't the debugger before the first post. That's why I showed the gdb version so that it could be checked.
But ultimately, I recommend to try to get 3.8 (or 4.0RC2) to run.
If our installer does not work, then try fpcupdeluxe.
2.0.x is not maintained anymore.
So, the best you can hope for is to find some setting that works around the issue.
I wrote that everything repeats itself in 3 different versions. I didn't roll back until 2.0.12. Tested 3.4-0, 3.6-0 and 3.8-0
ADD: I tried using gdb via ssh and the error disappeared.