Recent

Author Topic: Scrollbox divide by zero error  (Read 192 times)

Hansvb

  • Hero Member
  • *****
  • Posts: 909
Scrollbox divide by zero error
« on: April 25, 2026, 06:34:41 pm »
Hi,
On a scrollbox I put a few panels and splitters. Because updating the scrollbox is very slow, I was looking what happened when i use ScrollBox1.DisableAutoSizing. Then I get a divide by zero error and the LazTracer unit opens. It stops in the procedure RaiseGDBException of the unit unit LazTracer.

This is the function:
Code: Pascal  [Select][+][-]
  1. procedure RaiseGDBException(const Msg: string);
  2. begin
  3.   DebugLn(lrsERRORInCode, Msg);
  4.   // creates an exception, that gdb catches:
  5.   DebugLn(lrsCreatingGdbCatchableError);
  6.   DumpStack;
  7.   {$ifndef HASAMIGA} // On Amiga Division by 0 is not catchable, just crash
  8.   if (length(Msg) div (length(Msg) div 10000))=0 then ;  
  9.   {$endif}
  10. end;

the error happens in the line:
Code: Pascal  [Select][+][-]
  1. if (length(Msg) div (length(Msg) div 10000))=0 then ;

The cause is that Msg is empty.
It should have been something like this:
Code: Pascal  [Select][+][-]
  1.   {$ifndef HASAMIGA} // On Amiga Division by 0 is not catchable, just crash
  2.   if  Msg = '' then Exit;
  3.   if (length(Msg) div (length(Msg) div 10000))=0 then ;  
  4.   {$endif}


If i look in the callstack window and if I see it correctly then the function is called from
Code: Pascal  [Select][+][-]
  1. procedure TWinControl.DoAllAutoSize;
from wincontrol.inc. The call for it is:
Code: Pascal  [Select][+][-]
  1. if cfAutoSizeNeeded in FControlFlags then RaiseGDBException('');
this one calls RaiseGDBException with an empty Msg?


Reproducible with attached project. If you move splitter 2 you will get the divide by zero message. It feels like  a bug.

Used: Windows 11,  Lazarus 4.6.

 

TinyPortal © 2005-2018