[fpc-pascal] Using a c-library (part 1)

Koenraad Lelong fpascal at brouwerij.homelinux.net
Wed Mar 21 20:47:10 CET 2007


Hi,
I'm trying to use ow-capi from owfs (http://www.owfs.org). I converted 
owcapi.h with h2pas. I was looking for a memory leak so I used valgrind 
(first experience with it). There I found something other that bothered 
me so I tried to solve this first. I made a little test program 
(test00.pas) which could reproduce the problem.
The test program :
program test00;

{$mode objfpc}{$H+}

uses
   {$IFDEF UNIX}{$IFDEF UseCThreads}
   cthreads,
   {$ENDIF}{$ENDIF}
   Classes, owcapi
   { add your units here };

begin

writeln('test00');
end.

Inclusion of owcapi in the uses clause gives this result in valgrind :

==4515== Memcheck, a memory error detector.
==4515== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
==4515== Using LibVEX rev 1575, a library for dynamic binary translation.
==4515== Copyright (C) 2004-2005, and GNU GPL'd, by OpenWorks LLP.
==4515== Using valgrind-3.1.1, a dynamic binary instrumentation framework.
==4515== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
==4515== For more details, rerun with: -v
==4515==
==4515== My PID = 4515, parent PID = 4123.  Prog and args are:
==4515==    ./test00
==4515==
==4515== Invalid free() / delete / delete[]
==4515==    at 0x4020EA1: free (in 
/usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==4515==    by 0x41B356D: free_mem (in /lib/libc-2.4.so)
==4515==    by 0x41B3176: __libc_freeres (in /lib/libc-2.4.so)
==4515==    by 0x401D246: _vgw_freeres (in 
/usr/lib/valgrind/x86-linux/vgpreload_core.so)
==4515==    by 0x805DE25: SYSTEM_SYSTEM_EXIT (in 
/home/koenraad/fpc/owcapi/test00)
==4515==    by 0x80565CC: SYSTEM_DO_EXIT (in 
/home/koenraad/fpc/owcapi/test00)
==4515==    by 0x80481FC: main (in /home/koenraad/fpc/owcapi/test00)
==4515==  Address 0x401C668 is not stack'd, malloc'd or (recently) free'd
==4515==
==4515== Invalid free() / delete / delete[]
==4515==    at 0x4020EA1: free (in 
/usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==4515==    by 0x41B319E: __libc_freeres (in /lib/libc-2.4.so)
==4515==    by 0x401D246: _vgw_freeres (in 
/usr/lib/valgrind/x86-linux/vgpreload_core.so)
==4515==    by 0x805DE25: SYSTEM_SYSTEM_EXIT (in 
/home/koenraad/fpc/owcapi/test00)
==4515==    by 0x80565CC: SYSTEM_DO_EXIT (in 
/home/koenraad/fpc/owcapi/test00)
==4515==    by 0x80481FC: main (in /home/koenraad/fpc/owcapi/test00)
==4515==  Address 0xFFFFFFFF is not stack'd, malloc'd or (recently) free'd
==4515==
==4515== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 7 from 1)
==4515== malloc/free: in use at exit: 0 bytes in 0 blocks.
==4515== malloc/free: 0 allocs, 2 frees, 0 bytes allocated.
==4515== For counts of detected errors, rerun with: -v
==4515== All heap blocks were freed -- no leaks are possible.
Should I worry about this ? Any hints about what could be wrong ? The 
program seems to run fine.
I hope the atachments are accepted by the list. They are cleaned up a 
bit : remarks removed.
Thanks for any help you can provide.
Regards,
Koenraad Lelong.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: owcapi.h
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20070321/52db9b1b/attachment.h>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: owcapi.pas
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20070321/52db9b1b/attachment.ksh>


More information about the fpc-pascal mailing list