Bug #2134
closedsdiff causes stack overflow
0%
Description
Try this:
cd /usr/src
sdiff Makefile.inc1 Makefile_upgrade.inc
Results in:
diff: stack overflow
Updated by y0n3t4n1 over 13 years ago
On Wed, Sep 21, 2011 at 04:25:42AM +0000, Peter Avalos (via DragonFly issue tracker) wrote:
New submission from Peter Avalos <peter@theshell.com>:
Try this:
cd /usr/src
sdiff Makefile.inc1 Makefile_upgrade.incResults in:
diff: stack overflow
The backtrace looks to me like wcwidth() (in libdiffutils) is making
infinite recursion until the stack exhausts. Simple workaround is
to remove wcwidth.c from ${SRCS} in the Makefile in libdiffutils.
diff --git a/gnu/usr.bin/diff/libdiffutils/Makefile b/gnu/usr.bin/diff/libdiffutils/Makefile
index 00d8580..82b6532 100644
--- a/gnu/usr.bin/diff/libdiffutils/Makefile
+++ b/gnu/usr.bin/diff/libdiffutils/Makefile@ -64,7 +64,6
@ SRCS= c-stack.c \
timegm.c \
uinttostr.c \
umaxtostr.c \
- wcwidth.c \
xmalloc.c \
xstrtol.c \
xstrtol-error.c \
We have similar instance in libgreputils, too. However, the function
definitions of wcwidth in lib{diff,grep}utils look like this:
int
wcwidth (wchar_t wc)
#undef wcwidth
{
:
/* Otherwise, fall back to the system's wcwidth function. */
#if HAVE_WCWIDTH
return wcwidth (wc);
#else
return wc == 0 ? 0 : iswprint (wc) ? 1 : -1;
#endif
}
}
So, maybe we're suppose to define a macro wcwidth() somewhere in one
of the header files to a different name?
Updated by marino about 13 years ago
This commit allows the example of diff /usr/src/Makefile.inc1 /usr/src/
Makefile_upgrade.inc to work:
d76863bd1dbf9c1e4c04a977e3a7271a23cdb718
I decided to preserve the UTF-8 handling rather than remove the wcwidth.c file
from the source file list.