Re: [Arsperl-users] ars_CreateEntry crashing perl
Brought to you by:
jeffmurphy
|
From: John U. <joh...@cr...> - 2007-06-20 14:25:43
|
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: ars...@ar...
[mailto:ars...@ar...] On Behalf Of John Unsworth
Sent: 14 June 2007 12:25
To: ars...@ar...
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=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().
|