Bug #2134

sdiff causes stack overflow

Added by pavalos almost 3 years ago. Updated almost 3 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-

Description

Try this:
cd /usr/src
sdiff Makefile.inc1 Makefile_upgrade.inc

Results in:
diff: stack overflow

History

#1 Updated by y0n3t4n1 almost 3 years ago

On Wed, Sep 21, 2011 at 04:25:42AM +0000, Peter Avalos (via DragonFly issue tracker) wrote:
>
> New submission from Peter Avalos <>:
>
> Try this:
> cd /usr/src
> sdiff Makefile.inc1 Makefile_upgrade.inc
>
> Results 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?

#2 Updated by marino almost 3 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.

Also available in: Atom PDF