[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: locale-dependent assertion failure in gawk 3.1.5

From: Andrew J. Schorr
Subject: Re: locale-dependent assertion failure in gawk 3.1.5
Date: Tue, 11 Jul 2006 11:03:20 -0400
User-agent: Mutt/

On Mon, Jul 10, 2006 at 09:40:43AM -0400, Andrew J. Schorr wrote:
> One further question on the topic of wstr caching: in eval.c:r_tree_eval()
> in the Node_assign_concat case, the code currently says (in part):
>                 if (l != r && (l->flags & PERM) == 0 && l->stref == 1) {
>                         size_t nlen = l->stlen + r->stlen + 2;
>                         erealloc(l->stptr, char *, nlen, "interpret");
>                         memcpy(l->stptr + l->stlen, r->stptr, r->stlen);
>                         l->stlen += r->stlen;
>                         l->stptr[l->stlen] = '\0';
> #if defined MBS_SUPPORT
>                         if (r->wstptr != NULL)
>                                 free(r->wstptr);
>                         r->wstptr = NULL;
>                         r->wstlen = 0;
>                         r->flags &= ~WSTRCUR;
> #endif /* MBS_SUPPORT */
> I have 2 questions:
> 1. I'm not sure why it is necessary to free r->wstptr; what have we
> done to invalidate r's wstr cache?
> 2. On the other hand, isn't it necessary to free l->wstptr
> (if l->flags & WSTRCUR), since we have just changed l->stptr (l's string
> value) -- doesn't this invalidate any cached value in l->wstptr?

In my tests here, it seems that freeing r->wstptr does not fix the
originally reported bug, but freeing l->wstptr does.  So I think somehow
"r" got substituted for "l" in the original patch.

I am attaching a patch that adds 4 new test cases to gawk that uncover
some of the recently reported problems with /dev/fd and with wide strings.

Running make check with vanilla gawk 3.1.5, we get:

bash-3.00$ make check
./devfd.ok _devfd differ: byte 25, line 2
bash-3.00$ cat test/_devfd 
file on fd 4
file on fd 4

gawk: (FILENAME=/dev/fd/5 FNR=3) fatal: error reading input file `/dev/fd/4': 
Bad file descriptor

And we must set gawklocale to see the other problems:

bash-3.00$ GAWKLOCALE=en_US.UTF-8 make check
./gsubtst5.ok _gsubtst5 differ: byte 1, line 1
make[1]: [gsubtst5] Error 1 (ignored)
./wideidx.ok _wideidx differ: byte 3, line 2
make[1]: [wideidx] Error 1 (ignored)
./widesub.ok _widesub differ: byte 28, line 2
make[1]: [widesub] Error 1 (ignored)
./widesub2.ok _widesub2 differ: byte 31, line 2
make[1]: [widesub2] Error 1 (ignored)
/bin/sh: line 1: 10457 Aborted                 AWKPATH=. 
LC_ALL=${GAWKLOCALE:-C} LANG=${GAWKLOCALE:-C} ../gawk -f widesub3.awk 
<./widesub3.in >_widesub3 2>&1
./widesub3.ok _widesub3 differ: byte 1, line 1
make[1]: [widesub3] Error 1 (ignored)
./devfd.ok _devfd differ: byte 25, line 2
make[1]: [devfd] Error 1 (ignored)

Arnold's previous patch for io.c fixes the devfd test, and the attached
patch seems to fix all the wide string problems except for the gsubtst5

Arnold: I think you may have fixed many, if not all, of these problems in your
source tree.  Is there some way you can make your tree available on a read-only
basis (perhaps by setting up CVS or subversion at sourceforge.net)?  This would
make it much easier for the community to see which bugs are still outstanding
vs. those that have already been fixed (and to grab the appropriate patches).
It would certainly reduce mailing list traffic, since currently the same
bugs get reported repeatedly until the next release...


P.S. Regarding the devfd test, I'm not sure whether this should be in the
Unix tests section, or somewhere else.  Thoughts?

Attachment: gawktests.patch
Description: Text document

Attachment: wstr.patch
Description: Text document

reply via email to

[Prev in Thread] Current Thread [Next in Thread]