Recent

Author Topic: Strange SIGSEGV error in release mode but not in debug mode?  (Read 2033 times)

hgbk

  • New member
  • *
  • Posts: 9
When I run my Pascal program built in release mode I encounter a SIGSEGV error. When running the same program in debug mode the program runs without any error. I use Lazarus 2.0.12 on Windows 10.
Has anybody seen this before?

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1470
  • Former Delphi 1-7, 10.2 user
Re: Strange SIGSEGV error in release mode but not in debug mode?
« Reply #1 on: May 05, 2021, 11:48:39 am »
Yes - running in debug mode re-arranges the code somewhat compared with release mode which omits the debug code. Good luck finding the issue.
Lazarus 2.1 r65061 FPC 3.3.1 r49223 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.1 r65182 FPC 3.3.1 r49223 macOS 11.4 aarch64 Xcode 12.4
Lazarus 2.1 r61574 FPC 3.3.1 r42318 FreeBSD 12.1 amd64 VMware VM
Lazarus 2.1 r61574 FPC 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 FPC 3.2.0 Win10 Parallels VM

y.ivanov

  • Full Member
  • ***
  • Posts: 125
Re: Strange SIGSEGV error in release mode but not in debug mode?
« Reply #2 on: May 05, 2021, 11:55:13 am »
May be you should "Run/Clean up and Build..." first. There is a slight chance to help.

hgbk

  • New member
  • *
  • Posts: 9
Re: Strange SIGSEGV error in release mode but not in debug mode?
« Reply #3 on: May 05, 2021, 01:35:55 pm »
The "Run/Clean up and Build" does not help - unfortuantely

dseligo

  • Sr. Member
  • ****
  • Posts: 276
Re: Strange SIGSEGV error in release mode but not in debug mode?
« Reply #4 on: May 05, 2021, 01:45:19 pm »
Did you try to run both build modes from Lazarus and outside Lazarus? Maybe it has something to do with bitness of Lazarus/your program.
When do you get SIGSEGV error, can you isolate that code? I would place ShowMessage('1'), ShowMessage('2'), ShowMessage('3'), ... around that code so you can tell what line of code is producing error.

y.ivanov

  • Full Member
  • ***
  • Posts: 125
Re: Strange SIGSEGV error in release mode but not in debug mode?
« Reply #5 on: May 05, 2021, 02:10:43 pm »
The "Run/Clean up and Build" does not help - unfortuantely

Can you then enable the debug information in release mode and include an exception handler like in: https://wiki.freepascal.org/Logging_exceptions#TApplication.OnException?
In theory this should dump the exception stack and give a clue at least for the name of the subroutine under suspicion.

jamie

  • Hero Member
  • *****
  • Posts: 4565
Re: Strange SIGSEGV error in release mode but not in debug mode?
« Reply #6 on: May 05, 2021, 11:04:53 pm »
One needs to be careful when using some debug features..

For example the Preprocessor evaluations between a debugged version of an app and the release, done incorrectly things go wrong..

Also, the use of the "Assert" can break code if not property used. It must be used in such a way that if the Assert was removed at the current position you must ensure the code following will behave proper. This happens in Release mode when the Assert is not asserted in the code.


 Of course there is also the times where you actually do have a bug but the debugger is masking it due to how it operates at times and when its out of the picture this bug appears. Basically the bug Is there, its just getting masked with debug functionality.
  For example, the debug can cause a little lag in message handling and if you stepping it in code, it can also allow for messages to be processed where as, in non debug mode there is no delay and no stopping and allowing the GUI message system to catch up..

 So a more understanding of what kind of code you are using may help.
The only true wisdom is knowing you know nothing

hgbk

  • New member
  • *
  • Posts: 9
Re: Strange SIGSEGV error in release mode but not in debug mode?
« Reply #7 on: May 12, 2021, 11:08:45 am »
Thank you all for your hints. I'm following the recommendation to manually iterate to isolate the code where the error ocurrs. It seems to be in a LazWebsockets routine called wsstream - but I'm not yet sure. Just to give you an update here.
The problem now is just prio 2 for the program runs fine in debug mode. I'll keep you updated.

Thanks again!

Warfley

  • Sr. Member
  • ****
  • Posts: 451
Re: Strange SIGSEGV error in release mode but not in debug mode?
« Reply #8 on: May 12, 2021, 05:00:12 pm »
It could be a race condition that only occurs if your code runs at a certain speed and the speed up of release mode triggers it

440bx

  • Hero Member
  • *****
  • Posts: 2362
Re: Strange SIGSEGV error in release mode but not in debug mode?
« Reply #9 on: May 12, 2021, 08:21:04 pm »
When I run my Pascal program built in release mode I encounter a SIGSEGV error. When running the same program in debug mode the program runs without any error. I use Lazarus 2.0.12 on Windows 10.
Has anybody seen this before?
A little more information would be useful.  Specifically, is the program a console or GUI app ? (it sounds like it's a GUI app but, your confirming that would be helpful.)  Also, is it a 32bit program or a 64bit program ?  Whatever bitness it is, can it be compiled for the other bitness ?  if it's a GUI app, change it to CONSOLE (add, {$APPTYPE CONSOLE} in the .lpr, it won't bother anything), run it and does the SIGSEGV still occur ?  if it does, that's good news, you may even get the address of the SIGSEGV on the console when it occurs.

The next step depends on what the answers to the above questions are.

HTH.
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

jamie

  • Hero Member
  • *****
  • Posts: 4565
Re: Strange SIGSEGV error in release mode but not in debug mode?
« Reply #10 on: May 12, 2021, 10:58:36 pm »
The 3.2.0 compiler does have some issues with optimizer levels performing some code..

could it be the release version has jacked up the optimizer level above 2 ?
The only true wisdom is knowing you know nothing

hgbk

  • New member
  • *
  • Posts: 9
Re: Strange SIGSEGV error in release mode but not in debug mode?
« Reply #11 on: May 20, 2021, 01:02:29 pm »
Version information: Lazarus #2.0.12 (2021-02-212), FPC Version 3.2.0, SVN Revision 64642, win64

I'm using Lazarus just as an intelligent editor and the compile, run, debug options with old-style from-the-scratch-programming (no GUI mode).

 

TinyPortal © 2005-2018