http://www.perlmonks.org?node_id=717224

Taulmarill has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

i have a problem installing Text::Metaphone with my Strawberry Perl 5.10.0.2 on Win XP. I get the following error message when running the build in tests:
C:\strawberry\cpan\build\Text-Metaphone-2.01-Cv9Jxg>dmake test C:\strawberry\perl\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_h +arness(0, 'blib\lib', 'blib\arch')" t/*.t t/metaphone....Free to wrong pool 3e4f58 not f0138 at t/metaphone.t li +ne 33. t/metaphone.... Dubious, test returned 5 (wstat 1280, 0x500)

Sadly i can't seem to get this problem solved with google. Any suggestions?

edit: i get this error with versions 2.00 and 2.01, 1.96 seems to work fine though.

Replies are listed 'Best First'.
Re: Can't install Text::Metaphone with Strawberry Perl
by BrowserUk (Patriarch) on Oct 15, 2008 at 14:35 UTC

    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.
      Works for me, thank you.

      I've also posted a reply on RT describing what solves this and linking to this thread.

Re: Can't install Text::Metaphone with Strawberry Perl
by tmaly (Monk) on Oct 15, 2008 at 14:25 UTC
    I originally posted the bug on RT. It was on Strawberry Perl 5.8 not 5.10 and the author of the module fixed the problem recently. the original bug post was here Fails to install on strawberry perl 5.8
      That bug is still open, here's a "fix", in Metaphone.xs, replace
      free(phoned_word);
      with
      FreeMemory(phoned_word);
      and all is well
        This also seems to work. Would anyone care to explain this to me (just for my curiosity, i'm not that experienced with XS).