Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0003486 [JEDI VCL] 00 JVCL Components crash always 2006-02-01 04:50 2006-03-20 04:53
Reporter robbo77 View Status public  
Assigned To AHUser
Priority normal Resolution fixed  
Status resolved   Product Version 3.10
Summary 0003486: JvIntepreter crashes on assigning nil to a variable of TObject type
Description The following code used to work with JVCL 2.10, but since ver. 3.00 causes program using it to crash:

    with TJvInterpreterProgram.Create(nil) do
    try
        Pas.Add('var a: TObject;');
        Pas.Add('begin');
        Pas.Add('a := nil;');
        Pas.Add('end;');
        Run();
    finally
        Free();
    end;


Regards,
robert
Additional Information
Tags No tags attached.
Attached Files ? file icon JvInterpreter.pas.patch [^] (1,117 bytes) 2006-02-03 06:21

- Relationships

-  Notes
(0008486)
ivan_ra (developer)
2006-02-01 08:47
edited on: 2006-02-01 08:48

This works with latest CVS files:

procedure TForm1.Button1Click(Sender: TObject);
begin
    with TJvInterpreterProgram.Create(nil) do
    try
        Pas.Add('var a: TObject;');
        Pas.Add('begin');
        Pas.Add('a := nil;');
        Pas.Add('end;');
        Run();
    finally
        Free();
    end;
end;

Where error?

(0008502)
robbo77 (reporter)
2006-02-03 03:31

It doesn't work for me even with the latest daily snapshot file.

When I run the compiled program, it just disappears (on Win2000) or fails with "Stack Overflow" (on WinXP) message.

However, when I run the program in Delphi debugger I get the following message:
  Project c:\temp\Project1.exe faulted with message: 'access violation at 0x77e3bb26: write of address 0x00030c64'. Process Stopped. Use Step or Run to continue.
The exception seems to be generated by the VarAsType function, called by JvInterpreterVarAsType function in JvInterpreter.pas line 2393.

Call Stack:
JvInterpreterVarAsType(???,275)
TJvInterpreterVarList.SetValue(???,???,$EEB4A8)
TJvInterpreterFunction.SetValue('a',???,$EEB4A8)
TJvInterpreterUnit.SetValue(???,???,$EEB4A8)
TJvInterpreterFunction.InternalSetValue('a')
TJvInterpreterFunction.InterpretIdentifier
TJvInterpreterFunction.InterpretStatement
TJvInterpreterFunction.InterpretBegin
TJvInterpreterFunction.InFunction(nil)
TJvInterpreterUnit.Run
TJvInterpreterProgram.Run
TForm1.Button1Click(???)
Project1

I'm using Delphi 7 (build 8.1).
(0008503)
robbo77 (reporter)
2006-02-03 03:59

It seems that TCustomVariantType.CastTo recursively calls itself, causing the stack overflow.
Note this happens only when the variable is a TObject type. It does not happen when you use any other type.

Call Stack:
TCustomVariantType.CastTo((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nil, nil, 0, False, nil, 0, 0, 0, 0, 0, nil, nil, nil, nil, (0, 0, 0), (0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0)),(276, 0, 0, 0, 0, 0, 0, 0, 0, 0, nil, nil, 0, False, nil, 0, 0, 0, 0, 0, nil, nil, nil, nil, (0, 0, 0), (0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (276, 0, 0, 0)),275)
TCustomVariantType.CastTo((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nil, nil, 0, False, nil, 0, 0, 0, 0, 0, nil, nil, nil, nil, (0, 0, 0), (0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0)),(276, 0, 0, 0, 0, 0, 0, 0, 0, 0, nil, nil, 0, False, nil, 0, 0, 0, 0, 0, nil, nil, nil, nil, (0, 0, 0), (0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (276, 0, 0, 0)),275)
TCustomVariantType.CastTo((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nil, nil, 0, False, nil, 0, 0, 0, 0, 0, nil, nil, nil, nil, (0, 0, 0), (0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0)),(276, 0, 0, 0, 0, 0, 0, 0, 0, 0, nil, nil, 0, False, nil, 0, 0, 0, 0, 0, nil, nil, nil, nil, (0, 0, 0), (0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (276, 0, 0, 0)),275)
TCustomVariantType.CastTo((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nil, nil, 0, False, nil, 0, 0, 0, 0, 0, nil, nil, nil, nil, (0, 0, 0), (0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0)),(276, 0, 0, 0, 0, 0, 0, 0, 0, 0, nil, nil, 0, False, nil, 0, 0, 0, 0, 0, nil, nil, nil, nil, (0, 0, 0), (0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (276, 0, 0, 0)),275)
TCustomVariantType.CastTo((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nil, nil, 0, False, nil, 0, 0, 0, 0, 0, nil, nil, nil, nil, (0, 0, 0), (0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0)),(276, 0, 0, 0, 0, 0, 0, 0, 0, 0, nil, nil, 0, False, nil, 0, 0, 0, 0, 0, nil, nil, nil, nil, (0, 0, 0), (0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (276, 0, 0, 0)),275)
TCustomVariantType.CastTo((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nil, nil, 0, False, nil, 0, 0, 0, 0, 0, nil, nil, nil, nil, (0, 0, 0), (0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0)),(276, 0, 0, 0, 0, 0, 0, 0, 0, 0, nil, nil, 0, False, nil, 0, 0, 0, 0, 0, nil, nil, nil, nil, (0, 0, 0), (0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (276, 0, 0, 0)),275)
TCustomVariantType.CastTo((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nil, nil, 0, False, nil, 0, 0, 0, 0, 0, nil, nil, nil, nil, (0, 0, 0), (0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0)),(276, 0, 0, 0, 0, 0, 0, 0, 0, 0, nil, nil, 0, False, nil, 0, 0, 0, 0, 0, nil, nil, nil, nil, (0, 0, 0), (0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (276, 0, 0, 0)),275)
VarCastRare((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nil, nil, 0, False, nil, 0, 0, 0, 0, 0, nil, nil, nil, nil, (0, 0, 0), (0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0)),(51308, 65, 51048, 65, -14436, 4310940, 6,0409136018e-39, 1,9780056463e-307, 1,851520888e+12, 1,9780056463e-307, '???????????', $41C79C, 4310940, True, $41C79C, -100, 156, 51100, 4310940, 18515208880375708, $41C79C, $41C79C, $41C79C, $41C79C, (4310888, 4310940, 4310908), (65, 51048, 65, 51100, 65, 51068, 65), (65, 0, 104, 199, 65, 0, 156, 199, 65, 0, 124, 199, 65, 0), (4311148, 4310888, 4310940, 4310908)),275)
@VarCast(???,???,???)
VarAsType(???,???)
JvInterpreterVarAsType(???,275)
TJvInterpreterVarList.SetValue(???,???,$F2CDC8)
TJvInterpreterFunction.SetValue('a',???,$F2CDC8)
(0008504)
ivan_ra (developer)
2006-02-03 06:24
edited on: 2006-02-03 06:50

Yes, this is because variants in D6 was changed (I tested your example in D5), and because class TJvSimpleVariantType is incomplete.
You can apply this simple patch for JvInterpreter.pas

(0008520)
ivan_ra (developer)
2006-02-08 12:58

I think this typecasting must be added to CVS. Otherwise this mistake will repeat on each assigning
pointer->TObject or
TObject->pointer
inside JvInterpreter scripts
(0008703)
AHUser (developer)
2006-03-20 04:53

Fixed in CVS.

- Issue History
Date Modified Username Field Change
2006-02-01 04:50 robbo77 New Issue
2006-02-01 08:47 ivan_ra Note Added: 0008486
2006-02-01 08:47 ivan_ra Note Edited: 0008486
2006-02-01 08:48 ivan_ra Note Edited: 0008486
2006-02-03 03:31 robbo77 Note Added: 0008502
2006-02-03 03:59 robbo77 Note Added: 0008503
2006-02-03 06:21 ivan_ra File Added: JvInterpreter.pas.patch
2006-02-03 06:24 ivan_ra Note Added: 0008504
2006-02-03 06:50 ivan_ra Note Edited: 0008504
2006-02-08 12:58 ivan_ra Note Added: 0008520
2006-03-20 04:53 AHUser Status new => resolved
2006-03-20 04:53 AHUser Resolution open => fixed
2006-03-20 04:53 AHUser Assigned To => AHUser
2006-03-20 04:53 AHUser Note Added: 0008703


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker