View Issue Details

IDProjectCategoryView StatusLast Update
0017537LazarusDebuggerpublic2010-10-13 10:24
ReporterJuha ManninenAssigned ToMartin Friebe 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version0.9.29 (SVN)Product Build 
Target Version0.9.30Fixed in Version0.9.29 (SVN) 
Summary0017537: Debugger: added a typecast to prevent a range check error
DescriptionWhen Lazarus is built with -Cr (range check enabled), subtracting QWords gives an error. It can be fixed by a typecast.

It is not a functional error, meaning that the code works correctly when range check is disabled. However it makes it more difficult to use -Cr for "real" errors.

Patch is included.
TagsNo tags attached.
Fixed in Revision27569
LazTarget0.9.30
Widgetset
Attached Files
  • 0001-Debugger-add-typecast-to-prevent-a-range-check-error.patch (933 bytes)
    From b04cbe672d8f26670a0e7952725b31be43be15ba Mon Sep 17 00:00:00 2001
    From: Juha Manninen <juha@JuhanLinux.(none)>
    Date: Sun, 3 Oct 2010 01:19:08 +0300
    Subject: [PATCH] Debugger: add typecast to prevent a range check error.
    
    ---
     debugger/gdbmidebugger.pp |    2 +-
     1 files changed, 1 insertions(+), 1 deletions(-)
    
    diff --git a/debugger/gdbmidebugger.pp b/debugger/gdbmidebugger.pp
    index 612194e..8eb2c5c 100644
    --- a/debugger/gdbmidebugger.pp
    +++ b/debugger/gdbmidebugger.pp
    @@ -1538,7 +1538,7 @@ end;
     
     function DisasmSortCompare(AItem1, AItem2: Pointer): Integer;
     begin
    -  Result := PGDBMIDisasm(AItem1)^.Address - PGDBMIDisasm(AItem2)^.Address;
    +  Result := Int64(PGDBMIDisasm(AItem1)^.Address) - Int64(PGDBMIDisasm(AItem2)^.Address);
     end;
     
     function TGDBMIDebugger.GDBDisassemble(AAddr: TDbgPtr; ABackward: Boolean; out ANextAddr: TDbgPtr; out ADump, AStatement, AFile: String; out ALine: Integer): Boolean;
    -- 
    1.7.2.2
    
    

Relationships

duplicate of 0016132 closedMartin Friebe Patches Overflow in diassembler when compiled in debug mode 
related to 0017531 closedZeljan Rikalo Lazarus LCL: typecasts for different integer type assignments 
has duplicate 0016318 closedMartin Friebe Lazarus Arithmetic overflow except in debugger disassembler 

Activities

2010-10-03 00:38

 

0001-Debugger-add-typecast-to-prevent-a-range-check-error.patch (933 bytes)
From b04cbe672d8f26670a0e7952725b31be43be15ba Mon Sep 17 00:00:00 2001
From: Juha Manninen <juha@JuhanLinux.(none)>
Date: Sun, 3 Oct 2010 01:19:08 +0300
Subject: [PATCH] Debugger: add typecast to prevent a range check error.

---
 debugger/gdbmidebugger.pp |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/debugger/gdbmidebugger.pp b/debugger/gdbmidebugger.pp
index 612194e..8eb2c5c 100644
--- a/debugger/gdbmidebugger.pp
+++ b/debugger/gdbmidebugger.pp
@@ -1538,7 +1538,7 @@ end;
 
 function DisasmSortCompare(AItem1, AItem2: Pointer): Integer;
 begin
-  Result := PGDBMIDisasm(AItem1)^.Address - PGDBMIDisasm(AItem2)^.Address;
+  Result := Int64(PGDBMIDisasm(AItem1)^.Address) - Int64(PGDBMIDisasm(AItem2)^.Address);
 end;
 
 function TGDBMIDebugger.GDBDisassemble(AAddr: TDbgPtr; ABackward: Boolean; out ANextAddr: TDbgPtr; out ADump, AStatement, AFile: String; out ALine: Integer): Boolean;
-- 
1.7.2.2

Martin Friebe

2010-10-03 23:02

manager   ~0041458

Thanks for the patch.
Applied with modification.
please test and close if ok.

Martin Friebe

2010-10-04 13:24

manager   ~0041477

Changed last fix:
comparing (virtual?) addresses with highest bit set would lead to wrong order.

$8000 0000 0000 0000 would be typecast to negative number and appear smaller than $7fff 0000 0000 0000.

Juha Manninen

2010-10-05 11:40

developer   ~0041503

That means the original code was wrong, too, even with range check disabled.
So, we fixed a "real" bug.

Issue History

Date Modified Username Field Change
2010-10-03 00:38 Juha Manninen New Issue
2010-10-03 00:38 Juha Manninen Status new => assigned
2010-10-03 00:38 Juha Manninen Assigned To => Marc Weustink
2010-10-03 00:38 Juha Manninen File Added: 0001-Debugger-add-typecast-to-prevent-a-range-check-error.patch
2010-10-03 00:38 Juha Manninen LazTarget => -
2010-10-03 01:10 Juha Manninen Relationship added related to 0017531
2010-10-03 22:11 Juha Manninen Relationship added duplicate of 0016132
2010-10-03 22:32 Martin Friebe Relationship added has duplicate 0016318
2010-10-03 22:50 Martin Friebe Assigned To Marc Weustink => Martin Friebe
2010-10-03 23:02 Martin Friebe Fixed in Revision => 27554
2010-10-03 23:02 Martin Friebe LazTarget - => 0.9.30
2010-10-03 23:02 Martin Friebe Status assigned => resolved
2010-10-03 23:02 Martin Friebe Fixed in Version => 0.9.29 (SVN)
2010-10-03 23:02 Martin Friebe Resolution open => fixed
2010-10-03 23:02 Martin Friebe Note Added: 0041458
2010-10-03 23:02 Martin Friebe Target Version => 0.9.30
2010-10-04 13:24 Martin Friebe Fixed in Revision 27554 => 27569
2010-10-04 13:24 Martin Friebe Note Added: 0041477
2010-10-05 11:40 Juha Manninen Note Added: 0041503
2010-10-13 10:24 Juha Manninen Status resolved => closed