Phil,
Thanks for providing a compact example. I ran the test and found out what was happening. Essentially, if two pointers contained the same value but the finaliser was associated with the later entry in the vol table it was possible that the internal memory used to hold the pointer value could have been freed before the finaliser was called. The value used in the finaliser would then be the contents of the freed memory which may well be nonsense. I've fixed this so that finalisers are called before any internal memory is freed. Your example seems to work now at least on X86/32.

Regards,
David

On 13/11/2011 13:41, Phil Clayton wrote:
I am using setFinal to free a string (char *) whose pointer is returned
via a parameter (char **) with address/deref to construct/destruct the
char ** parameter. Unfortunately, I cannot get this to work.

It seems that a function registered with setFinal is not always passed
the C pointer (of the vol) that it was registered with, in particular,
when the vol supplied to setFinal is derived from address/deref. E.g.

setFinal mycfun (deref (address v))

does not call mycfun with the same C pointer as for

setFinal mycfun v

This seems like an issue to me but perhaps I have misunderstood something.
_______________________________________________
polyml mailing list
polyml@inf.ed.ac.uk
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml

Reply via email to