Hi Eric,
> <philosophical question>
> Is this the appropriate forum for the following question, or should I direct
> these to perl-xs? This mailing list is so much snappier, it's hard to
> resist. And the code below _was_ Inline'd after all.
> </philosophical question>
Personally, I like seeing questions on this list if they have to do with
Inline. Yours seems to qualify :)
> I have a Perl::Tk program which calls a module I have written, containing
> some Inline'd wrappers to the libtiff library.
>
> All works fine under Linux. Now I am trying to port in to Win32. Things go
> pretty well, until the _second_ time I call a function containing the
> following code (it seems that this is the offending bit, based on some
> debugging I've been doing). The second time I call the xsub containing this
> code, the program bombs with "Perl.exe has generated errors and will be
> closed by Windows...an error log will be created". (One problem is I can't
> find the resulting log). Because of the fact that it works the first time,
> I am led to believe I am mismanaging the reference counts or something along
> those lines and that Perl is dying during garbage collection. I have tried
> every possible permutation I could think of as far as incrementing or
> mortalizing variables. Note that r, g, and b are mortalized SV*'s (but not
> s, since I return the value pointed to). Can someone spot the error? (BTW,
> I know I should be checking the return value of av_fetch before
> dereferencing...but again, it works under Linux).
>
> Here's the snippet:
>
> printf("Ok\n"); // I get here the second time around
> for(y = 0; y < h; y++)
> {
> strcpy(pixels, "");
> for (x = 0; x < w; x++)
> {
> r = *av_fetch(avImage, ((y * w) + x) * 3, 0);
> g = *av_fetch(avImage, ((y * w) + x) * 3 + 1, 0);
> b = *av_fetch(avImage, ((y * w) + x) * 3 + 2, 0);
> sprintf(pixel, "#%02X%02X%02X ", SvIV(r), SvIV(g), SvIV(b));
> strcat(pixels, pixel);
> }
> s = newSVpv(pixels, 0);
> av_push(avCanvas, s);
> }
> free(pixel);
> free(pixels);
> printf("Ok\n"); // but not here.
> return newRV_noinc((SV*)(avCanvas));
> }
What would like to see more of, though, it a complete script. I don't know
what this is. I don't know what function this is inside of, I don't know
what it returns, what comes from Perl, what comes from C, or anything like
that. What's avImage? avCanvas? Where did they come from? Who created
them?
If you could send the same snippet inside a script that demonstrates the
problem, someone might notice something. Right now, I have no idea looking
at your code what could be wrong.
Later,
Neil