Bug 241714 - diff: --tabsize dies with SIGSEGV
Summary: diff: --tabsize dies with SIGSEGV
Status: Closed DUPLICATE of bug 243974
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 12.1-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: Kubilay Kocak
Keywords: crash
Depends on:
Reported: 2019-11-05 00:23 UTC by rlwestlund
Modified: 2020-03-22 01:03 UTC (History)
3 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description rlwestlund 2019-11-05 00:23:06 UTC
On the three systems I've tried, /usr/bin/diff with --tabsize dies with SIGSEGV, regardless of any other options or arguments.

I'm observing the crash on FreeBSD 12.1-RELEASE.
uname -a: FreeBSD coppermind 12.0-RELEASE-p10 FreeBSD 12.0-RELEASE-p10 GENERIC  amd64
freebsd-version -kur:

Outside of --tabsize, diff works normally.

The synopsis in diff(1) indicates that the option is a standalone. Later in the man page it's shown as '-tabsize' (as opposed to --tabsize), and said to take an argument (which makes sense); however I think the single dash is a typo because when I run diff -tabsize 3 file1 file2, I get "diff: invalid option -- z".

I've also tested this on two 12.0-RELEASE-p10 systems (DO droplets), and seen the crash on them as well. I updated the userland of those systems to 12.0-RELEASE-p11 and the same thing happened. The DO droplets are also amd64 machines with GENERIC kernel.
Comment 1 rlwestlund 2019-11-05 00:36:32 UTC
I'm trying to attach the core dump, but the server is telling me 413 Request Entity Too Large. What should I do about this? I assume the core dump is important.
Comment 2 rlwestlund 2019-11-05 00:40:20 UTC
Sorry to post again, but the uname -a output I posted in the first comment was wrong. It says:

FreeBSD coppermind 12.1-RELEASE FreeBSD 12.1-RELEASE r354233 GENERIC  amd64

The 12.0-RELEASE-p10 output I posted was copy-pasted from having the issue on 12.0-RELEASE-p10 first, which was what prompted me to upgrade to 12.1-RELEASE to see if that fixed it. (I had saved the draft of my post from before then in a text file to reboot, and pasted it back in, and forgot to edit that part).
Comment 3 pprocacci 2019-11-20 06:19:43 UTC
tabsize is set to have an optional argument.
I can't explain why as it seems to me it always require an argument.
This patch here makes tabsize require an argument which also solves the problem
of the SEGfault as line 255 of diff.c is expecting optarg to be something.

--- diff.c.orig 2019-11-20 01:16:41.377456000 -0500
+++ diff.c      2019-11-20 01:16:51.176400000 -0500
@@ -90,7 +90,7 @@
        { "no-ignore-file-name-case",   no_argument,            NULL,   OPT_NO_IGN_FN_CASE },
        { "normal",                     no_argument,            NULL,   OPT_NORMAL },
        { "strip-trailing-cr",          no_argument,            NULL,   OPT_STRIPCR },
-       { "tabsize",                    optional_argument,      NULL,   OPT_TSIZE },
+       { "tabsize",                    required_argument,      NULL,   OPT_TSIZE },
        { "changed-group-format",       required_argument,      NULL,   OPT_CHANGED_GROUP_FORMAT},
        { NULL,                         0,                      0,      '\0'}
Comment 4 rlwestlund 2019-11-20 13:16:52 UTC
Oh, that explains it. I thought it crashed even if I passed it an option because I was trying to pass it with a space. You're right, with --tabisze=3 it doesn't crash.
Comment 5 fehmi noyan isi 2020-02-08 09:46:37 UTC
I created a bug report for the same issue and I am keen to update the argument to --tabsize as required since it does not make much sense to use --tabsize without an argument to set the number of space characters required for a single tab.

Comment 6 Kubilay Kocak freebsd_committer freebsd_triage 2020-03-22 01:03:06 UTC
^Triage: It's normally preferable to close later issue ID's as duplicates of the original (older) ones. In this case, the newer bug has already been referenced by commits, so close this as a duplicate of bug 243974

*** This bug has been marked as a duplicate of bug 243974 ***