Recent

Author Topic: Strange SIGSEGV error in release mode but not in debug mode?  (Read 3085 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: 2020
  • 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.

alpine

  • Hero Member
  • *****
  • Posts: 1032
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.
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

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

  • Hero Member
  • *****
  • Posts: 1177
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.

alpine

  • Hero Member
  • *****
  • Posts: 1032
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.
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

hgbk

  • New member
  • *
  • Posts: 9
Re: Strange SIGSEGV error in release mode but not in debug mode?
« Reply #6 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

  • Hero Member
  • *****
  • Posts: 1499
Re: Strange SIGSEGV error in release mode but not in debug mode?
« Reply #7 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: 3921
Re: Strange SIGSEGV error in release mode but not in debug mode?
« Reply #8 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) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

hgbk

  • New member
  • *
  • Posts: 9
Re: Strange SIGSEGV error in release mode but not in debug mode?
« Reply #9 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