Re: [Arsperl-users] ars_CreateEntry crashing perl
Brought to you by:
jeffmurphy
|
From: John U. <joh...@cr...> - 2007-06-14 11:25:11
|
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=20
Newz(777,fieldList.fieldValueList,c,ARFieldValueStruct);
and=20
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().
|