Hi,

Why is this access violation occuring?  The tiIsVariantOfType method
comes from the tiOPF2 project - I am trying to get rid of the last few
Unit Test failures in the tiOPF code using FPC.
tiIsVariantOfType is simplified for the purpose of this example.

I get the output ">>>>> 11111111" and then the "Passed" message, and
then a Access Violation when the app is complete.  I also included a
backtrace that shows something strange - VARUTILS_NOINTERFACES().

I am using FPC 2.1.1 (r4760) under Ubuntu Linux 6.06.

Regards,
 - Graeme -


---------------  variant_test.lpr  -------------------------
program variant_test;

{$mode objfpc}{$H+}

uses
 {$IFDEF UNIX}{$IFDEF UseCThreads}
 cthreads,
 {$ENDIF}{$ENDIF}
 Classes
 ,Variants;


function tiIsVariantOfType(pVariant : Variant; pVarType : TVarType) : boolean;
begin
 if pVarType = varArray then
 begin
   writeln('>>>>>>> 11111111');
   Result := VarIsArray(pVariant);
 end
 else
 begin
   writeln('>>>>>>> 22222222');
   Result := False;
   { actual code removed to simplify test }
 end;
end;


var
 lVar: Variant;
begin
 lVar := VarArrayOf(['xxx', 'yyy']);
 if tiIsVariantOfType(lVar, varArray) then
   writeln('Passed')
 else
   writeln('Failed');
end.

---------------------------------------------------------------


-----------  Backtrace ----------------------------
(gdb) run
Starting program: /home/graemeg/programming/tests/variants/variant_test
11111111
Passed

Breakpoint 1, 0x08053476 in fpc_raiseexception ()
(gdb) bt
#0  0x08053476 in fpc_raiseexception ()
#1  0x08099e99 in VARUTILS_NOINTERFACES ()
#2  0xb7f071a8 in ?? ()
#3  0x0809d51f in VARUTILS_SAFEARRAYCLEARDATASPACE$PVARARRAY$BOOLEAN$$HRESULT ()
#4  0x0809dab4 in VARUTILS_SAFEARRAYDESTROYDATA$PVARARRAY$$HRESULT ()
#5  0x0809d96f in VARUTILS_SAFEARRAYDESTROY$PVARARRAY$$HRESULT ()
#6  0x0809cbca in VARUTILS_VARIANTCLEAR$TVARDATA$$HRESULT ()
#7  0x08077ac6 in VARIANTS_SYSVARCLEARPROC$TVARDATA ()
#8  0x08053b67 in SYSTEM_VARIANT_CLEAR$TVARDATA ()
#9  0x080bf540 in operatingsystem_parameter_argv ()
#10 0x08055ccd in fpc_finalize ()
#11 0x080bf7d4 in U_SYSTEM_OUTPUT ()
#12 0x080bf550 in U_P$VARIANT_TEST_LVAR ()
#13 0x080483b2 in P$VARIANT_TEST_finalize_implicit () at variant_test.lpr:37
#14 0x08056452 in SYSTEM_FINALIZEUNITS ()
#15 0x080564b3 in SYSTEM_INTERNALEXIT ()
#16 0x08056705 in SYSTEM_DO_EXIT ()
#17 0x08048368 in main () at variant_test.lpr:37
(gdb)

-------------------------------------------------------

--
There's no place like 127.0.0.1
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to