We have fixed this by the following change to mallocnn in support.c. /* malloc that will never return null */ void * mallocnn(int s) {
#ifdef malloc #undef malloc #endif void *m = malloc(s ? s : 1); if (!m) croak("can't malloc"); memset(m, 0, s ? s : 1); return m; } The Perl malloc macro is undefined and so the platform malloc() is used instead. All memory allocation for the structures then uses the platform memory manager and the call to FreeARFieldValueList() works correctly. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Unsworth Sent: 20 June 2007 15:25 To: 'ARSperl User Discussion' Subject: Re: [Arsperl-users] ars_CreateEntry crashing perl Apologies got that wrong. If Perl is compiled to use Perl memory allocation it seems to pick up all memory related functions. So Newz and safefree are also using the Perl memory pool. I guess that you already knew that! -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Unsworth Sent: 14 June 2007 12:25 To: arsperl-users@arsperl.org Subject: Re: [Arsperl-users] ars_CreateEntry crashing perl This crash is caused because the memory management is incorrect. Memory is allocated for the field values by AMALLOCNN(fieldList.fieldValueList,c,ARFieldValueStruct); and released by a call to FreeARFieldValueList(&fieldList, FALSE); These used to be Newz(777,fieldList.fieldValueList,c,ARFieldValueStruct); and safefree(fieldList.fieldValueList); I believe that the safefree() was changed to FreeARFieldValueList() because otherwise any memory allocated to the values was never freed. But the change from Newz to ALLOCNN has caused a memory corruption. AMALLOCNN uses the Perl memory allocation routines and allocates memory from the Perl memory pool. FreeARFieldValueList uses the OS free() function. Since the memory was not allocated using the OS malloc() a memory corruption occurs, the free'd blocks are added to the OS memory list and then and used by both Perl and the platform. A crash will probably occur soon afterwards. The fix is to put back the Newz or to change AMALLOCNN to use Newz. Newz() maps onto the OS malloc() and safefree() maps onto the OS free(). Other functions are affected in a similar way to ars_CreateEntry(). ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Arsperl-users mailing list Arsperl-users@arsperl.org https://lists.sourceforge.net/lists/listinfo/arsperl-users ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Arsperl-users mailing list Arsperl-users@arsperl.org https://lists.sourceforge.net/lists/listinfo/arsperl-users