Lazarus

Using the Lazarus IDE => Debugger => Topic started by: hakelm on February 22, 2017, 12:08:23 pm

Title: Blank form, program hanging in debug
Post by: hakelm on February 22, 2017, 12:08:23 pm
I have the following little annoying problem:
When I start my application in the IDE-debugger a blank form is opened up and the program (debugger?) hangs and can only be stopped with ctrl-F2
If I however single step to
Application.Run;
in the project file and then press F9 everything seems to work.
What can I do?
H
Ps
I am using Lazarus 1.6+dfsg-1 on Ubuntu 16.04
Title: Re: Blank form, program hanging in debug
Post by: Martin_fr on February 22, 2017, 06:06:47 pm
Strange...

Does "Pause" work?

You can try (far fetched) http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#On_Windows_Open.2FSave.2FFile_or_System_Dialog_cause_gdb_to_crash

------------------
Which version of gdb?

anything above gdb 7.7 may have issues with stabs. (afaik default by fpc)

Setting is in Project options / debug
AND fore EACH package in the package options.

(or use "Additions and overrides)
Either way, try changing ALL debug info to dwarf (with sets) / (But not dwarf 3)

---------
If still no success, go to the bottom of the page I linked above, and provide a log file.

--
Btw always use F9 to start your app (or "Run" from the menu, or the run button).
Do not start your app with F7 or F8, only use those if the app is already running/paused.
Title: Re: Blank form, program hanging in debug
Post by: hakelm on February 22, 2017, 07:51:49 pm
Thanks
Synaptic tells me I have GDB 7.11.1-0ubuntu1~16.04, which I assume Lazarus uses.
I tested the different choices for debugger info and it is only Dwarf3(beta) (-gw3) that seems to work but Pause does not work:

The file "../sysdeps/unix/syscall-template.S" was not found.
Do you want to locate it yourself?

There is no file syscall-template.S on my system. What can I do about that?
Pls note my system has worked flawlessly earlier but in order to get anchordockingdsgn to work having tried some different Lazaruses but now I have reverted to 1.6+dfsg-1.
H
Title: Re: Blank form, program hanging in debug
Post by: Sieben on October 26, 2020, 06:06:53 pm
Sorry for reviving an old thread, but it describes exactly what's happening here now. Unfortunately the origininal OP didn't leave a solution. It seems to happen only with new projects, my older and more complex projects all seem to work.

With new projects the main form seems to start ok with first compile, but on second ord third start comes up blank and cannot be closed other than Ctrl+F2. Sometimes it additionally freezes and produces a SIGKILL when halted.

Starting with F8 and slowly stepping to Application.Run isn't reliable as well, as though it seems to work more often than pure F9. Toggling between F9 and Start via Toolbar gives similar results - it starts more often, but not reliably.

I have recompiled the IDE, rebooted several times, started new projects from scratch to no avail. Tried to compare project settings but can't find a difference. No recent changes to IDE or other settings.

GDB reports:

Code: Bash  [Select][+][-]
  1. GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
  2. Copyright (C) 2016 Free Software Foundation, Inc.
  3. ...
  4. This GDB was configured as "i686-linux-gnu".
  5. ...
  6. This GDB was configured as follows:
  7.    configure --host=i686-linux-gnu --target=i686-linux-gnu
  8.              --with-auto-load-dir=$debugdir:$datadir/auto-load
  9.              --with-auto-load-safe-path=$debugdir:$datadir/auto-load
  10.              --with-expat
  11.              --with-gdb-datadir=/usr/share/gdb (relocatable)
  12.              --with-jit-reader-dir=/usr/lib/gdb (relocatable)
  13.              --without-libunwind-ia64
  14.              --with-lzma
  15.              --with-python=/usr (relocatable)
  16.              --without-guile
  17.              --with-separate-debug-dir=/usr/lib/debug (relocatable)
  18.              --with-system-gdbinit=/etc/gdb/gdbinit
  19.              --with-babeltrace

Ubuntu 16.04.7 32Bit (up to date), Lazarus 2.0.10 with FPC 3.2.0 deb install. Second install Lazarus trunk seems to work ok.

It's annoying and i'm stuck...
Title: Re: Blank form, program hanging in debug
Post by: Thaddy on October 26, 2020, 08:35:43 pm
"i686-linux-gnu" is not "i386-linux-gnu"....  There is another reference that it is configured for 64 bit (the usually unusual IA-64).
See https://en.wikipedia.org/wiki/IA-64
See also https://packages.ubuntu.com/bionic/devel/gcc-6-i686-linux-gnu where you can also find a reference to the proper GDB....

You state that you have a 32 bit OS. That is not a problem, but your GDB configuration is completely configured for 64 bit and probably even with the wrong processor except maybe for cross compilation if you are REALLY using an IA-64 which is usually unlikely. I would expect X64 in that case.

Can you type:
Code: Bash  [Select][+][-]
  1. uname -a
and report back?
Then we know what we are dealing with.
Title: Re: Blank form, program hanging in debug
Post by: Sieben on October 27, 2020, 05:56:12 pm
Code: Bash  [Select][+][-]
  1. $ uname -a
  2. Linux 4.15.0-122-generic #124~16.04.1-Ubuntu SMP Thu Oct 15 16:14:02 UTC 2020 i686 i686 i686 GNU/Linux

And uname -m states i686 as well. Ancient Intel Core 2 Duo.
Title: Re: Blank form, program hanging in debug
Post by: Martin_fr on October 28, 2020, 11:06:58 am
If the first run usually works, then in tools > options, set under debugger "reset after each run".

Also try changing the "internal start break" in the property grid.

Or use FpDebug.

--------------
I am away. If you create a log
https://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Log_info_for_debug_session

and ping me in about 10 days, I can check if I can spot anything else....
Title: Re: Blank form, program hanging in debug
Post by: Sieben on October 28, 2020, 02:45:50 pm
Quote
If the first run usually works, then in tools > options, set under debugger "reset after each run".

Tried that already (and resetting via Tools menu) to no avail. And it might happen on first run as well.

Quote
Also try changing the "internal start break" in the property grid.

Tried all available options now, also to no avail.

Quote
Or use FpDebug.

Installed package LazDebuggerFp from ../components/lazdebuggers now, set debugger info to 'dwarf 2 with sets' as IDE suggested and it seems to work for now, with a strange effect remaining however. I have a very simple test project with an event handler that crashes on application terminate (which I think should not happen) - but only when running inside IDE and with debugger. Running outside or without debugger (Ctrl+Shift+F9) it does not crash. And if memory serves all this troubles seem to have started after this happened for the first time. And every project created prior to that still runs happily with gdb...
Title: Re: Blank form, program hanging in debug
Post by: Martin_fr on October 28, 2020, 05:59:50 pm
Can you sent me the crashing example ?

I am away though, so only going to look at it in 1 or 2 weeks....
Title: Re: Blank form, program hanging in debug
Post by: Sieben on October 28, 2020, 06:16:15 pm
It's this one, originally meant to demonstrate an issue with TShellTreeView here. Crash happens on the Collapsed/Expanded handler (and can be prevented with if not Application.Terminated of course).

Created and published with 2.0.10/3.2.0.
Title: Re: Blank form, program hanging in debug
Post by: bytebites on October 28, 2020, 09:51:39 pm
Missing package rkUtil
Title: Re: Blank form, program hanging in debug
Post by: Sieben on October 28, 2020, 09:55:04 pm
Sorry, tried to be fast... just remove it.

Edit: removed dependency above.
Title: Re: Blank form, program hanging in debug
Post by: Sieben on November 09, 2020, 06:21:13 pm
Sorry, forgot to create a log like you suggested, but since you seem to be back did you possibly have a look...?
Title: Re: Blank form, program hanging in debug
Post by: Martin_fr on November 10, 2020, 02:36:54 pm
Sorry, forgot to create a log like you suggested, but since you seem to be back did you possibly have a look...?
I meant "I can have a look at the log file". This is in case gdb reports any error, but the error is hidden by the IDE.
If there is a detect-able error, then there may be a way to deal with it. At least make sure it is reported to the user. If not, then this is more complicated. (I do not have Ubuntu, and the problem does not happen on my (older) Fedora).

The gdb based debugger also has an option to skip loading library symbols => worth a try....


Btw, not sure if any relationship at all, but there is another thread mentioning issues on Ubuntu: https://forum.lazarus.freepascal.org/index.php/topic,51407.0.html.


About the crash during app-closing: label gets destroyed first (at least for me), so accessing it crashes. However this crash does not manifest always. ( It can be forced by -gh ).
Crashes during app-close are not always (visible) reported. On windows, I can see the crash outside the debugger, if I run with a console, as it is printed out. The app closes however before it can report it via gui.
IMHO it is "unfortunate" that the collapse/expand event is called during destroy, maybe that should be changed, but that is a diff topic.
Title: Re: Blank form, program hanging in debug
Post by: Sieben on November 10, 2020, 05:17:52 pm
Thank for coming back on this issue. I created a log file now as suggested, started Lazarus with said parameters und it did me the favour of starting the project blank and dead on first try. App was then killed via Linux Task Manager, not Lazarus Halt (Ctrl+F2). File attached. Odd thing is still that projects that have been created earlier still run without problems, still no blank forms, no hanging.

As for crash on app closing I mentioned it mainly because trouble seems(!) to have started after this happened for the first time. But as I said this 'unfortunate' behaviour can be prevented by just adding if not Application.Terminated. Changing creation/destruction order seems not to be possible, and switching positions of objects in *.lfm also didn't help. It's not he only 'unfortunate' issue with TTreeView/TShellTreeView but that is indeed a different topic. The debug trouble seems to have no connection with them either. It also happens with the most simple projects with just a TButton on the form.
Title: Re: Blank form, program hanging in debug
Post by: Martin_fr on November 10, 2020, 05:40:54 pm
Thank for coming back on this issue. I created a log file now as suggested, started Lazarus with said parameters und it did me the favour of starting the project blank and dead on first try. App was then killed via Linux Task Manager, not Lazarus Halt (Ctrl+F2). File attached. Odd thing is still that projects that have been created earlier still run without problems, still no blank forms, no hanging.

I can see you killing it:
Code: [Select]
"*stopped,reason="exited-signalled",signal-name="SIGKILL",signal-meaning="Killed""
Unfortunately nothing else suspicious before.
All that happens is, that libraries are loaded. (There is a very tiny change that DisableLoadLibrarySymbols (or similar) in the gdb debugger settings may affect that. But I would not count on it.

If it works in fpdebug, then keep using this. FpDebug is meant to take over eventually. (except for remote debug).

Otherwise you can look at the other thread I linked. It says to install some package and that would help the problem in the other thread. However I can't comment much on this, as that is more of a gtk issues than a debug issue (and outside my scope of expertise)

Quote
As for crash on app closing I mentioned it mainly because trouble seems(!) to have started after this happened for the first time. But as I said this 'unfortunate' behaviour can be prevented by just adding if not Application.Terminated. Changing creation/destruction order seems not to be possible, and switching positions of objects in *.lfm also didn't help. It's not he only 'unfortunate' issue with TTreeView/TShellTreeView but that is indeed a different topic.
Label is a GrapicsControl, so its in a different bucket when it comes to creation order. But a need to change the order IMHO should not be there.
IMHO that even should not fire. Anyway that should be a different thread. Or maybe try reporting it on the bugtracker.
I looked at the stack, and the node for which the event is fired, is in its destructor. So no point to fire the event.

Quote
The debug trouble seems to have no connection with them either. It also happens with the most simple projects with just a TButton on the form.
Indeed, those are 2 different issues.
Title: Re: Blank form, program hanging in debug
Post by: Sieben on November 10, 2020, 08:30:12 pm
Thanks again. While FpDebug is fine for your own code it does not seem to step in lcl etc code. I don't know if I can recompile stable with necessary debug info, and I don't know if I want to. So I'd be glad if this issue went away like it came - for no apparent reason. That said I d/led a test project here yesterday that to my surprise did not fail yet. I'll keep a close watch but didn't find any differences with my failing projects so far, just like I didn't with my non-failing projects...
Title: Re: Blank form, program hanging in debug
Post by: Martin_fr on November 10, 2020, 09:44:18 pm
Thanks again. While FpDebug is fine for your own code it does not seem to step in lcl etc code. I don't know if I can recompile stable with necessary debug info, and I don't know if I want to.
It should step in. Unless fpc still defaults to "stabs".

Recompiling stable should be easy. In fact it is done always, if you install a package into the IDE. However, you do not need to rebuild the IDE.

Menu: Tools > Configure Build IDE
To the big "options" memo, add:  -gw3
"Save settings"

Now build your project, it should recompile the LCL.

Title: Re: Blank form, program hanging in debug
Post by: Sieben on November 10, 2020, 10:25:11 pm
That's good news, thanks, will give it a try. I thought with a package install or the like it would only be sort of 're-linked', not really recompiled.
Title: Re: Blank form, program hanging in debug
Post by: Sieben on November 10, 2020, 11:01:34 pm
Works (of course...). However, IDE always suggested '-gs -godwarfsets' for projects with FpDebug, I guess I should switch that to '-gw3' as well?
Title: Re: Blank form, program hanging in debug
Post by: Martin_fr on November 10, 2020, 11:34:55 pm
Works (of course...). However, IDE always suggested '-gs -godwarfsets' for projects with FpDebug, I guess I should switch that to '-gw3' as well?
gw or gs??
The suggestion should be -gw -godwarfsets

Yes, -gw3.

The debugger backend currently only flags what it supports. But not what preference it has within those. So the IDE list them all, and picks the one that is safe for other backends too.

FpDebug works best with dwarf 3.
The dwarf level does not affect single stepping, only watches/locals display.

--
Mind, if you switch back to gdb => go back to the -gw -godwarfsets

gdb crashes slightly more often, if using -gw3
Title: Re: Blank form, program hanging in debug
Post by: Sieben on November 10, 2020, 11:39:03 pm
Thanks once more. :)

Edit: with gdb, setting was 'automatic (-g)'. And you are right re '-gw -godwarfsets'.
TinyPortal © 2005-2018