Sisyphus <[EMAIL PROTECTED]> writes:
>Hi,
>
>void fault() {
>  int a[3] = {0};
>  Safefree(a);
>}
>
>Naturally enough, when perl calls the fault() function, it produces the 
>fatal "Free to wrong pool..." error.
>
>I thought I could trap the error with:
>
>eval{fault()};
>
>but the script still crashes at that point. Is there a way to trap that 
>error from perl (ie without doing anything different at the xs level) ?

No. To do almost anything at perl level you need to be able to 
allocate/free memory and the error above has just broken the heap
so you are stuck.

( For other kinds of fatal errors it might be possible to write some 
XS code ;-) to turn them into perl die style exceptions. )

>
>Is it something that might vary from one OS to the next ? 

What happens when you do the bad free will vary. Win32 seems to 
be relatively friendly here as it checks the address passed.
Most UNIXes don't check - so their free() is faster - and will 
instead get some kind of memory fault (protection or alignment)
possibly MUCH later in execution. 

>I'm using perl 
>5.8.6 on Windows2000.
>
>Cheers,
>Rob

Reply via email to