Forum > General
[SOLVED] When is nil not nil?
(1/1)
BigChimp:
x86 FPC trunk, Lazarus trunk:
I'm feeling fairly stupid, but... here goes:
I had code like this (dbf_dbffile in FPC trunk):
--- Code: ---procedure TDbfFile.SetFieldData(Column: Integer; DataType: TFieldType;
Src, Dst: Pointer; NativeFormat: boolean);
...
var
...
Len: Integer;
--- End code ---
--- Code: --- Len := PWord(Src)^;
if Len > FieldSize then
Len := FieldSize;
--- End code ---
I suspected Src could be an unassigned pointer and changed the code to
--- Code: --- if Src = nil then
Len := 0
else
begin
Len := PWord(Src)^;
if Len > FieldSize then
Len := FieldSize;
end;
--- End code ---
Running through the debugger, I break on the first line, if Src = nil.
The debugger shows Src is indeed nil, but when I try to step past, I get a SIGSEGV.
Any ideas?
Bart:
Probably a debugger (gdb) problem?
Throw in some writeln()'s to debug it?
Bart
BigChimp:
Edit: not solved yet:
I had been testing dbtestframework_gui against MS SQL server under Lazarus debugger.
When I compile & run dbtestframework.pas, the command line version, edit: using the SAME db as previously (instead of a different one that does not support the field type in question... sorry), the test still has errors:
--- Quote --- 00.162 TestDBFExport_VisualFoxPro Error: EAccessViolation
Exception: Access violation
Source unit:
Method name:
Line number: 0
--- End quote ---
Now going to add some writelns...
BigChimp:
Interesting. On my Linux x64 system, the second code snippet works fine. It should be running the same tests (same database backend) unless I messed up again.
Throwing in some writelns and recompiling indicates the text mode test program works fine on Windows now, too, so I guess it was the debugger in Lazarus after all....
Thanks.
Navigation
[0] Message Index