[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Possible bug in argp
From: |
Guangxin Yang |
Subject: |
Possible bug in argp |
Date: |
Sat, 07 Aug 2021 18:29:22 +0800 |
User-agent: |
Zoho Mail |
Hello there,
There may be a bug on macOS when calling arpg_help() with options having a
non-NULL arg value in the argp_option.
For the example
https://www.gnu.org/software/libc/manual/html_node/Argp-Example-3.html, I added
a case like this:
case ARGP_KEY_NO_ARGS:
argp_help(state->root_argp,
stderr,
ARGP_HELP_BUG_ADDR | ARGP_HELP_DOC | ARGP_HELP_USAGE | ARGP_HELP_LONG,
state->name);
exit(1);
Compile and run without providing any arguments, I got a Segmentation fault.
The output looks like this:
Usage: t [-qsv?V] [-o FILE] [--output=FILE] [--quiet] [--silent] [--verbose]
[--help] [--usage] [--version] ARG1 ARG2
Argp example #3 -- a program with options and arguments using argp
-o, --output=FILE Output to FILE instead of standard output
-q, -s, --quiet, --silent Don't produce any output
-v, --verbose Produce verbose output
-?, --help Give this help list
--usage Give a short usage message
-V, Segmentation fault: 11
If I comment out these two lines:
21 {"output", 'o', "FILE", 0,
22 "Output to FILE instead of standard output" },
Things work perfectly.
On Redhat it is all ok.
I attached the modified example FYI.
Thanks for creating this wonderful piece. :-0
Regards
Guangxin
t.c
Description: Binary data
- Possible bug in argp,
Guangxin Yang <=