Antti-Juhani Kaijanaho wrote:
>
> Hello,
>
> As some of you may remember, I am the maintainer of Debian package
> for Hugs.
>
> I got the following bug report from Havoc Pennington through the Debian
> bug tracking system. To me it looks like a genuine bug, but what do I
> know ;-) Could you please take a look at it?
Thanks for the report. Here's the problem:
hPutStr takes as an argument a Handle.
It was then stomping on the only live copy of this
Handle with a black hole, and during GC, the finalizer
for then handle was being called, deleting the
Handle underlying structures.
It can be fixed with a couple of lines.
The start of primHPutStr in iomonad.c previously said:
< primFun(primHPutStr) { /* print string on handle */
< Int h;
< HandleArg(h,4);
< drop();
< if (handles[h].hmode&(HWRITE|HAPPEND)) {
< ...
It should now read:
> primFun(primHPutStr) { /* print string on handle */
> Int h;
> HandleArg(h,4);
> drop();
> push(primArg(4)); /* duplicate the handle before */
> /* possible GC inside String eval */
> push(primArg(2)); /* and copy the String back onto */
> /* the top of the stack */
> if (handles[h].hmode&(HWRITE|HAPPEND)) {
> ...
Thanks again for the report, and hope this helps.
Andy