http://qs1969.pair.com?node_id=717239


in reply to Can't install Text::Metaphone with Strawberry Perl

Tweak Metaphone.xs by adding #undef free as shown below, and the problem will probably go away:

#include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "metaphone.h" MODULE = Text::Metaphone PACKAGE = Text::Metaphone PROTOTYPES: ENABLE SV * Metaphone(word, ...) char* word PROTOTYPE: $;$ PREINIT: int max_length = 0; INIT: char* phoned_word; CODE: if( items > 1 ) { max_length = SvIV(ST(1)); } metaphone(word, max_length, &phoned_word); RETVAL = newSVpv(phoned_word, 0); #undef free free(phoned_word); OUTPUT: RETVAL

If this works for you, contact the module author and suggest the change to him.

Rational: The memory being freed is allocated using the C-runtime's malloc(), but the XS environment redefines free() to use it's idea of what that function should be, and it is in that redirected function things go awry. (Which is totally bogus because they haveSafefree() for memory allocated by the Perl allocator.)

By using #undef free before calling it, you get back the CRT free, and the error message and subsequent traps go away (in those cases I've tried).


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.