[fpc-pascal] How can i detect what cause the problem

Michael Van Canneyt michael.vancanneyt at wisa.be
Tue Nov 14 13:55:55 CET 2006



On Tue, 14 Nov 2006, Gabor Boros wrote:

> Hi,
> 
> I have a Symbol mobile device with an integrated barcode scanner.
> The scanner's API in C and I cannot use every API calls.
> 
> An example: The problem appears in the
> ScanBuffer:=SCAN_AllocateBuffer(TRUE,dwScanSize);
> line (see the test app below).
> If I run in GDB the error message is:
> 
> warning: Prefetch Abort: Thread=8dcfe8dc Proc=8c329ab0 'project1.exe'
> warning: AKY=00004001 PC=00000000 RA=00011338 BVA=00000000 FSR=000004f0
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x00000000 in ?? ()
> 
> The test app is:
> 
> program test;
> 
> {$apptype console}
> {$PACKRECORDS C}
> 
> uses Windows, dynlibs;
> 
> const
>   MAx_SRC=32;
>   dwScanSize:DWORD=7095;	
> 
> type
>   STRUCT_INFO=record
>     dwAllocated:DWORD;
>     dwUsed:DWORD;
>   end;
> 
>   LABELTYPE = DWORD;
> 
>   LPSCAN_BUFFER = ^SCAN_BUFFER;
>   SCAN_BUFFER=record
>     StructInfo:STRUCT_INFO;
>     dwDataBuffSize:DWORD;
>     dwOffsetDataBuff:DWORD;
>     dwDataLength:DWORD;
>     dwTimeout:DWORD;
>     dwStatus:DWORD;
>     bText:BOOL;
>     dwLabelType:LABELTYPE;
>     dwRequestID:DWORD;
>     TimeStamp:SYSTEMTIME;
>     dwDirection:DWORD;
>     szSource:array[0..MAx_SRC-1] of TCHAR;
>     blsMultiPart:BOOL;
>     dwScanID:DWORD;
>     dwBarcodeID:DWORD;
>     dwNumRemaining:DWORD;
>     dwOffsetAuxDataBuff:DWORD;
>     dwAuxDataLength:DWORD;
>   end;
> 
>   T_SCAN_AllocateBuffer = function (bText:BOOL;dwSize:DWORD):LPSCAN_BUFFER;
> cdecl;

I would be very surprised to see that a Windows DLL uses cdecl; as calling
convention. Try changing this to

  T_SCAN_AllocateBuffer = function (bText:BOOL;dwSize:DWORD):LPSCAN_BUFFER; stdcall;

Michael.



More information about the fpc-pascal mailing list