Recent

Author Topic: release mode find error at line number  (Read 1124 times)

Packs

  • Sr. Member
  • ****
  • Posts: 490
release mode find error at line number
« on: September 16, 2025, 07:35:10 am »
Dear All,

I have a Lazarus command-line application that exposes a REST API. In release mode I am seeing runtime errors (for example, access violations), but I cannot determine the source file and line number where the error occurs.

So far I have tried:

Top-level exception handling and logging E.Message.

Using third-party components and libraries (which may be involved).

A few basic debugging steps (rebuilds, testing in the IDE).

cdbc

  • Hero Member
  • *****
  • Posts: 2464
    • http://www.cdbc.dk
Re: release mode find error at line number
« Reply #1 on: September 16, 2025, 09:52:41 am »
Hi
Switch to 'Debug' mode...  :P
/b
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6 -> FPC 3.2.2 -> Lazarus 4.0 up until Jan 2025 from then on it's both above &: KDE6/QT6 -> FPC 3.3.1 -> Lazarus 4.99

Packs

  • Sr. Member
  • ****
  • Posts: 490
Re: release mode find error at line number
« Reply #2 on: September 17, 2025, 10:34:25 am »
Thanks

Packs

  • Sr. Member
  • ****
  • Posts: 490
Re: release mode find error at line number
« Reply #3 on: September 17, 2025, 01:20:38 pm »
if I build debug application and deploy while closing getting following error and it is not closing also
---------------------------
Error
---------------------------
  $000000010004E2  $0000000100026CBE

  $0000000100025DC0

Call trace for block $00000000063D2B30 size 2551

dbannon

  • Hero Member
  • *****
  • Posts: 3557
    • tomboy-ng, a rewrite of the classic Tomboy
Re: release mode find error at line number
« Reply #4 on: September 17, 2025, 01:45:13 pm »
Packs, are you running the application in the Lazarus IDE so the debugger can catch the problem ? If you are running from the command line, you may need to use an external debugger, gdb to so so.


If the IDE, perhaps check the debugger is configured correctly ?  And that the debug mde you have selected really does have the necessary debug settings. You might need to tell us which version of OS and FPC/Lazarus you are using to get more specific advice on how to do so.

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

Zvoni

  • Hero Member
  • *****
  • Posts: 3135
Re: release mode find error at line number
« Reply #5 on: September 17, 2025, 01:50:26 pm »
Or use Try/Except at critical code, and then log UnitName and Linenumber to a textfile
there are ready-to-use macros for that
https://wiki.freepascal.org/$include

Or use LazLogger
https://wiki.freepascal.org/LazLogger
« Last Edit: September 17, 2025, 01:53:04 pm by Zvoni »
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

jamie

  • Hero Member
  • *****
  • Posts: 7308
Re: release mode find error at line number
« Reply #6 on: September 17, 2025, 11:23:01 pm »
In one my Delphi apps that I sold, I created a MAP file of the final project and stashed that away on each final version project.

  If the program faulted on a user, it would generate a addresses and with that report I could look at the MAP file and determine where the issues are without distributing a debug version of the code.

  I don't know if FPC can generate a MAP file like that for the release version?

Jamie


The only true wisdom is knowing you know nothing

n7800

  • Hero Member
  • *****
  • Posts: 547
  • Lazarus IDE contributor
    • GitLab profile
Re: release mode find error at line number
« Reply #7 on: September 18, 2025, 12:51:56 am »
FPC can create a separate file with debug data.

And it seems like you can just try rebuilding (in debug) the same version with the same options. But there are a lot of nuances. This was discussed somewhere on the forum, and Martin described it in detail.

jamie

  • Hero Member
  • *****
  • Posts: 7308
Re: release mode find error at line number
« Reply #8 on: September 18, 2025, 12:10:11 pm »
Having the compiler create a map file shouldn't be a big issue since all the symbol tables have been created during the process anyways.
The only true wisdom is knowing you know nothing

PascalDragon

  • Hero Member
  • *****
  • Posts: 6191
  • Compiler Developer
Re: release mode find error at line number
« Reply #9 on: September 20, 2025, 09:24:58 am »
Having the compiler create a map file shouldn't be a big issue since all the symbol tables have been created during the process anyways.

The switch for a map file is -Xm.

jamie

  • Hero Member
  • *****
  • Posts: 7308
Re: release mode find error at line number
« Reply #10 on: September 20, 2025, 11:41:07 am »
Perfect. Thanks
The only true wisdom is knowing you know nothing

Thaddy

  • Hero Member
  • *****
  • Posts: 18324
  • Here stood a man who saw the Elbe and jumped it.
Re: release mode find error at line number
« Reply #11 on: September 20, 2025, 03:20:58 pm »
I would also recommend the use of assertions for such things: these can be turned of with one switch. When assertions are off, code generation is not affected compared to leaving them out.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

jamie

  • Hero Member
  • *****
  • Posts: 7308
Re: release mode find error at line number
« Reply #12 on: September 20, 2025, 03:54:51 pm »
it looks like I need to write a util for that generated output of the map file.

It's not selective as to what you need to see.

I need to see the unit's inner functions and procedures addresses and so on, not the complete log of the paths etc.

But it's nice to have that information.

 I didn't look long enough in the file to see if the actual UNIT contents are listed by use yet, I will build a until to display such things creates a file pointer table looking into the file so not to try to load the complete list in memory.

Jamie
The only true wisdom is knowing you know nothing

Thaddy

  • Hero Member
  • *****
  • Posts: 18324
  • Here stood a man who saw the Elbe and jumped it.
Re: release mode find error at line number
« Reply #13 on: September 20, 2025, 04:24:53 pm »
Then you need to compile with debug info or - what I often do - generate the assembler output with -al
Release settings give otherwise very sparse info if any, so examine the assembler output (if you are capable enough versed in assembler for your CPU target)
There are only very rare - timing - cases where debug mode has different behavior from release mode. Especially if the optimization is limited to -O2.
But first try with liberately used assertions.
« Last Edit: September 20, 2025, 04:28:04 pm by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

 

TinyPortal © 2005-2018