URL: <https://savannah.gnu.org/bugs/?68152>
Summary: [gxditview] SEGVs when invoked with no arguments
Group: GNU roff
Submitter: gbranden
Submitted: Sun 15 Mar 2026 06:05:55 PM UTC
Category: Driver - others/general
Severity: 4 - Important
Item Group: Crash/Unresponsive
Status: Confirmed
Privacy: Public
Assigned to: gbranden
Open/Closed: Open
Discussion Lock: Unlocked
Planned Release: None
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Sun 15 Mar 2026 06:05:55 PM UTC By: G. Branden Robinson <gbranden>
Regression from _groff_ 1.23.0.
Not having smoke tests for executables kinda sucks. A smoke test for _this_
one would require a virtual X server.
$ ~/groff-1.24.1/bin/gxditview
Segmentation fault (core dumped) ~/groff-1.24.1/bin/gxditview
$ ~/groff-1.24.0/bin/gxditview
Segmentation fault (core dumped) ~/groff-1.24.0/bin/gxditview
$ ~/groff-1.23.0/bin/gxditview
X connection to :0 broken (explicit kill or server shutdown).
$ ~/groff-1.24.0/bin/gxditview ""
X connection to :0 broken (explicit kill or server shutdown).
While embarrassing, this problem doesn't make _gxditview_ unusable. Simply
call it with arguments.
Without bisecting (yet?), I'm virtually certain that the problem arose in this
commit, almost 18 months ago:
commit a386043f030120d50c5fb2ec4d2e26bfe8284ae0
Author: G. Branden Robinson <[email protected]>
Date: Fri Sep 20 21:04:02 2024 -0500
[gxditview]: Accept groff(1)'s `-v` option.
* src/devices/xditview/xditview.c (Syntax): Report `-v` as an accepted
synonym of `-version` and `--version` in usage message.
(main): Refactor argument processing. Accept `-v`. Handle early-exit
options (`--help`, `--version` and their synonyms) _before_ checking
for an excess argument count, another error condition.
* src/devices/xditview/gxditview.1.man (Synopsis): Document `-v` option.
Now "groff -vX" works. Don't say I never did nothin' for ya, Alameda.
...
diff --git a/src/devices/xditview/xditview.c
b/src/devices/xditview/xditview.c
index 1f56940b2..2be55230b 100644
--- a/src/devices/xditview/xditview.c
+++ b/src/devices/xditview/xditview.c
@@ -138,8 +138,8 @@ Syntax(const char *progname, bool had_error)
" [-printCommand command]"
" [-resolution resolution]"
" [file]\n", progname);
- (void) fprintf (stream, "usage: %s {-version | --version}\n",
- progname);
+ (void) fprintf (stream, "usage: %s {-v | -version | --version}"
+ "\n", progname);
(void) fprintf (stream, "usage: %s {-help | --help}\n",
progname);
if (had_error)
@@ -221,19 +221,22 @@ int main(int argc, char **argv)
toplevel = XtAppInitialize(&xtcontext, "GXditview",
options, XtNumber (options),
- &argc, argv, fallback_resources, NULL, 0);
+ &argc, argv, fallback_resources, NULL, 0);
+ /*
+ * XXX: This is not as flexible as GNU getopt, but good enough to
+ * work when called by groff.
+ */
+ if ((strcmp(argv[1], "-help") == 0)
+ || (strcmp(argv[1], "--help") == 0))
+ Syntax(argv[0], false /* did not have error */);
+ else if ((strcmp(argv[1], "-v") == 0)
+ || (strcmp(argv[1], "-version") == 0)
+ || (strcmp(argv[1], "--version") == 0)) {
+ (void) printf("GNU gxditview (groff) version %s\n",
+ Version_string);
+ exit(EXIT_SUCCESS);
if (argc > 2)
Syntax(argv[0], true /* had error */);
- else if (argc == 2) {
- if ((strcmp(argv[1], "-help") == 0)
- || (strcmp(argv[1], "--help") == 0))
- Syntax(argv[0], false /* did not have error */);
- else if ((strcmp(argv[1], "-version") == 0)
- || (strcmp(argv[1], "--version") == 0)) {
- (void) printf("GNU gxditview (groff) version %s\n",
- Version_string);
- exit(EXIT_SUCCESS);
- }
}
XtGetApplicationResources(toplevel, (XtPointer)&app_resources,
I still need to be checking the value of _argc_ before dereferencing the
_argv_ array.
Fix this on the master branch. It can be cherry-picked onto the 1.24.x branch
for inclusion in a 1.24.2 release if we do one.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?68152>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
Description: PGP signature
