Recent

Author Topic: Error in Lazarus when using gtk2  (Read 1116 times)

xchgeaxeax

  • Newbie
  • Posts: 3
Error in Lazarus when using gtk2
« on: February 23, 2025, 09:51:06 am »
After starting debugging even the most basic project and closing it in Lazarus, all windows hang. When launching from the console, I get an error: Application.ProcessMessages crashed with Access violation
At the same time, everything repeats on Lazarus 3.4-0, 3.6-0 and 3.8-0, which I download from SourceForge and compiled from source. Problems when using default gtk2 in Lazarus.
Code: Bash  [Select][+][-]
  1. xchgeaxeax@home-kde ~/.lazarus/Lazarus-3.8-0 $ uname -r
  2. 6.6.57-calculate
  3. xchgeaxeax@home-kde ~/.lazarus/Lazarus-3.8-0 $ eix x11-libs/gtk+
  4. [I] x11-libs/gtk+
  5.      Доступные версии:    
  6.      (2)    2.24.33-r3^t
  7.      (3)    3.24.35^t 3.24.41^t 3.24.41-r1^t 3.24.42-r1^t ~3.24.48^t
  8.        {+X aqua broadway cloudproviders colord cups examples gtk-doc +introspection sysprof test vim-syntax wayland xinerama ABI_MIPS="n32 n64 o32" ABI_S390="32 64" ABI_X86="32 64 x32"}
  9.      Установленные версии:  2.24.33-r3(2)^t(00:59:05 14.05.2023)(cups introspection xinerama -aqua -examples -test -vim-syntax ABI_MIPS="-n32 -n64 -o32" ABI_S390="-32 -64" ABI_X86="32 64 -x32") 3.24.42-r1(3)^t(10:14:44 07.08.2024)(X cups introspection wayland xinerama -aqua -broadway -cloudproviders -colord -examples -gtk-doc -sysprof -test -vim-syntax ABI_MIPS="-n32 -n64 -o32" ABI_S390="-32 -64" ABI_X86="32 64 -x32")
  10.      Домашняя страница:     https://www.gtk.org/
  11.      Описание:              Gimp ToolKit +
  12. xchgeaxeax@home-kde ~/.lazarus/Lazarus-3.8-0 $ gdb -v
  13. GNU gdb (Gentoo 15.2 vanilla) 15.2
  14. Copyright (C) 2024 Free Software Foundation, Inc.
  15. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
  16. This is free software: you are free to change and redistribute it.
  17. There is NO WARRANTY, to the extent permitted by law.
  18. xchgeaxeax@home-kde ~/.lazarus/Lazarus-3.8-0 $ fpc -v
  19. Free Pascal Compiler version 3.2.2 [2022/04/01] for x86_64
  20. Copyright (c) 1993-2021 by Florian Klaempfl and others
  21. Fatal: No source file name in command line
  22. Fatal: Compilation aborted
  23. Error: /usr/bin/ppcx64 returned an error exitcode
  24. xchgeaxeax@home-kde ~/.lazarus/Lazarus-3.8-0 $ ./startlazarus
  25. Gtk-Message: 11:50:06.240: Failed to load module "appmenu-gtk-module"
  26. Info: (startlazarus) [TLazarusManager.Run] starting /home/xchgeaxeax/.lazarus/Lazarus-3.8-0/lazarus ...
  27. Info: (startlazarus) [TLazarusManager.Run] exe=/home/xchgeaxeax/.lazarus/Lazarus-3.8-0/lazarus Params=[--started-by-startlazarus
  28. --no-splash-screen
  29. --force-new-instance
  30. ]
  31. Gtk-Message: 11:50:06.469: Failed to load module "appmenu-gtk-module"
  32. Hint: (lazarus) [TMainIDE.ParseCmdLineOptions] PrimaryConfigPath="/home/xchgeaxeax/.lazarus"
  33. Hint: (lazarus) [TMainIDE.ParseCmdLineOptions] SecondaryConfigPath="/etc/lazarus"
  34. Hint: (lazarus) [TMainIDE.DoOpenProjectFile] "/home/xchgeaxeax/PRJ/lazarus/problem/project1.lpi"
  35. Hint: (lazarus) [TBuildManager.SetBuildTarget] Old=x86_64-linux-gtk2 New=x86_64-linux-gtk2 Changed: OS/CPU=True LCL=False
  36. LoadLFM Creating designer for hidden component of /home/xchgeaxeax/PRJ/lazarus/problem/unit1.pas
  37. InitOpenedProjectFile select form in designer: Form1:TForm1 TDesigner
  38. Hint: (lazarus) [TMainIDE.DoRunProjectWithDebug] INIT
  39. Note: (lazarus) [TMainIDE.DoBuildProject] MainBuildBoss.DoCheckIfProjectNeedsCompilation nothing to be done
  40. Hint: (lazarus) [TMainIDE.DoRunProjectWithDebug] Debugger=TFpDebugDebugger
  41. Hint: (lazarus) [TMainIDE.DoRunProjectWithDebug] END
  42. ----------------
  43. Application.ProcessMessages crashed with Access violation

dbannon

  • Hero Member
  • *****
  • Posts: 3647
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Error in Lazarus when using gtk2
« Reply #1 on: February 23, 2025, 12:33:38 pm »
Hi xchgeaxeax, welcome to the forum.

I am afraid I have no easy answer to your problem, we'll need more information I think. Some thoughts -
  • Is eix the program you are writing ? It appears any thing but "the most basic project" ?
  • Have you installed your Lazarus 3.8 inside the ~/.lazarus config dir ? Strange thing to do but should not cause a problem.
  • When you see this AV while running Lazarus, does it happen as you start Lazarus or only when you start to debug your app ?
  • You seem to be using gdb, Lazarus has a very functional debugger built in, it understands how Pascal thinks a bit better than gdb, have you tried enabling it ?
  • Given that you seem to be running a KDE gentoo distro, fpc works OK but not Lazarus, I think that the most likely cause of your problem is missing dependencies. Out of the box, I expect that distro to have no gtk2 installed, have you installed the necessary dependencies ? (But I have no real reason to suggest that, its just a guess).


On a more conventional distro, I'd tell you to ensure that libx11-dev and libgtk2.0-dev are installed, the names are probably different on Gentoo.

You probably are using Wayland, it might be interesting to see if these problems go away if you disable Wayland from the logon screen.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

xchgeaxeax

  • Newbie
  • Posts: 3
Re: Error in Lazarus when using gtk2
« Reply #2 on: February 23, 2025, 01:45:50 pm »
Quote
Is eix the program you are writing ?
No. eix is a program for searching in portage (a package tree from a linux distribution). I have provided the output of this program in order to show which versions of gtk2 I have installed.

Quote
It appears any thing but "the most basic project" ?
The simplest project is a standard program that Lazarus creates when selecting Application or Program in the project manager.

Quote
Have you installed your Lazarus 3.8 inside the ~/.lazarus config dir ? Strange thing to do but should not cause a problem.
I wrote that I compiled all the source versions manually. Only Lazarus 2.0.12 is available in the portage tree of my Linux distribution. When trying to install it from the local repository, problems arise that cause the version to roll back to 2.0.12.

Quote
When you see this AV while running Lazarus, does it happen as you start Lazarus or only when you start to debug your app ?
In my previous answer, the output to the console from the program is ./startlazarus. This problem does not appear in the program that I compiled, namely Lazarus itself. It occurs when debugging the program is completed.

Quote
You seem to be using gdb, Lazarus has a very functional debugger built in, it understands how Pascal thinks a bit better than gdb, have you tried enabling it ?
The problem clearly doesn't come out of the debugger, because once you rebuild Lazarus on Qt5 or Qt6, it disappears.

Quote
Given that you seem to be running a KDE gentoo distro, fpc works OK but not Lazarus, I think that the most likely cause of your problem is missing dependencies. Out of the box, I expect that distro to have no gtk2 installed, have you installed the necessary dependencies ? (But I have no real reason to suggest that, its just a guess).
This is what I originally posted the eix output for. It shows that I have gtk2 installed. And even without this library, Lazarus would not have started at all. And I have problems with the Application.ProcessMessages in Lazarus itself when using gtk2 version 2.24.33-r3

Quote
You probably are using Wayland, it might be interesting to see if these problems go away if you disable Wayland from the logon screen.
No. I have a proprietary driver from nvidia that doesn't want to start wayland. I have kde running under x11.

ADD: I'll clarify. Debugging ends and Lazarus successfully switches the window set from debug to normal. Then everything freezes.

All console output from the program being debugged in Lazarus under Linux is redirected to the console window (Alt+Ctrl+O). The output to the console with the error that I have is the output from Lazarus itself. That is, the IDE itself fell into the Application.ProcessMessages. But, obviously, the error appears in the place where gtk2 functions are used.
« Last Edit: February 23, 2025, 02:05:10 pm by xchgeaxeax »

dbannon

  • Hero Member
  • *****
  • Posts: 3647
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Error in Lazarus when using gtk2
« Reply #3 on: February 23, 2025, 11:43:18 pm »

This is what I originally posted the eix output for. It shows that I have gtk2 installed. And even without this library, Lazarus would not have started at all. And I have problems with the Application.ProcessMessages in Lazarus itself when using gtk2 version 2.24.33-r3
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).
ADD: I'll clarify. Debugging ends and Lazarus successfully switches the window set from debug to normal. Then everything freezes.
Right, thats a lot clearer.

Can you run other gtk2 apps ? Its possible, in this day and age that you don't have too many. 

A very wild guesses, please check libx11-xcb is installed. (But if not Wayland system, using gtk2, probably not needed).

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.

Otherwise, I really don't know. strace might just be the next step !

If 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!

(sorry for rushed answer, have meeting....)

Davo


Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12014
  • Debugger - SynEdit - and more
    • wiki
Re: Error in Lazarus when using gtk2
« Reply #4 on: February 24, 2025, 02:09:01 am »
  • You seem to be using gdb, Lazarus has a very functional debugger built in, it understands how Pascal thinks a bit better than gdb, have you tried enabling it ?
If I read it correctly he simple run "gdb -v" to show us the version. He starts lazarus after that, and unrelated to the gdb check. And in Lazarus he uses FpDebug (according to the output)

ADD: I'll clarify. Debugging ends and Lazarus successfully switches the window set from debug to normal. Then everything freezes.

Are you using a docked IDE ? (AnchorDocking?)

So basically when you debug it switches to debug desktop (hides the designer, maybe hides some other windows).
When you stop debugging it restores those windows.

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?

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.


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.


xchgeaxeax

  • Newbie
  • Posts: 3
Re: Error in Lazarus when using gtk2
« Reply #5 on: February 24, 2025, 07:05:39 am »
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).
Code: Bash  [Select][+][-]
  1. $ eix x11-libs/libxcb
  2. [I] x11-libs/libxcb
  3.      Доступные версии:      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"}
  4.      Установленные версии:  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")
  5.      Домашняя страница:     https://xcb.freedesktop.org/ https://gitlab.freedesktop.org/xorg/lib/libxcb
  6.      Описание:              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_qMV4EHBf4YkA

If 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.
« Last Edit: February 24, 2025, 07:41:27 am by xchgeaxeax »

dbannon

  • Hero Member
  • *****
  • Posts: 3647
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Error in Lazarus when using gtk2
« Reply #6 on: February 24, 2025, 09:39:02 am »
If 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.
Sure, but just because Lazarus is built to work with gtk2 by default does not lock you into that. You can built Qt5 and Qt6 apps from a gtk2 lazarus. No problems.  And, if you still find evidence of this problem, build a Qt5 (or 6) version of Lazarus (make sure your libqt5pas is current) -

Code: Bash  [Select][+][-]
  1. $> make LCL_PLATFORM=qt5 bigide

Sure, its a cop out, better to find the problem. But sometimes, life is not perfect.

ADD: I tried using gdb via ssh and the error disappeared.
Gee, thats a strange twist !

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4660
  • I like bugs.
Re: Error in Lazarus when using gtk2
« Reply #7 on: February 24, 2025, 01:14:27 pm »
That's just Lazarus from source, by default it is built specifically to work with gtk2.
Do you have a binary package of Lazarus for Gentoo? At least years ago it was a source only distribution. I remember a long time ago I built and installed the whole KDE system in an Intel 80386 computer. It compiled some 10+ hours and then it worked. I was amazed.

I also recommend the QT5 or QT6 version of Lazarus if it solves the problem.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

 

TinyPortal © 2005-2018