View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0003486 | JEDI VCL | 00 JVCL Components | public | 2006-02-01 04:50 | 2006-03-20 04:53 |
Reporter | robbo77 | Assigned To | AHUser | ||
Priority | normal | Severity | crash | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 3.10 | ||||
Target Version | Fixed in Version | 3.30 | |||
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 | ||||
Tags | No tags attached. | ||||
|
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? |
|
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). |
|
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) |
2006-02-03 06:21
|
JvInterpreter.pas.patch (1,117 bytes)
Index: run/JvInterpreter.pas =================================================================== RCS file: /cvsroot/jvcl/dev/JVCL3/run/JvInterpreter.pas,v retrieving revision 1.71 diff -u -r1.71 JvInterpreter.pas --- run/JvInterpreter.pas 17 Jan 2006 20:40:36 -0000 1.71 +++ run/JvInterpreter.pas 3 Feb 2006 13:32:42 -0000 @@ -1033,6 +1033,8 @@ procedure Clear(var V: TVarData); override; procedure Copy(var Dest: TVarData; const Source: TVarData; const Indirect: Boolean); override; + procedure CastTo(var Dest: TVarData; const Source: TVarData; + const AVarType: TVarType); override; end; TJvRecordVariantType = class(TJvSimpleVariantType); @@ -1350,6 +1352,14 @@ //=== { TJvSimpleVariantType } =============================================== +procedure TJvSimpleVariantType.CastTo(var Dest: TVarData; + const Source: TVarData; const AVarType: TVarType); +begin + //support only inherited classes + Dest.VPointer := Source.VPointer; + //inherited; +end; + procedure TJvSimpleVariantType.Clear(var V: TVarData); begin SimplisticClear(V); |
|
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 |
|
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 |
|
Fixed in CVS. |
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 |