Re: Possible bug in argp
Guangxin Yang <[email protected]> Sat, 07 Aug 2021 18:44:02 +0800
| Newsgroups | gmane.comp.gnu.utils.bugs |
|---|---|
| Message-ID | <[email protected]> |
BTW, I am using argp 1.3 installed via homebrew:=C2=A0 =C2=A0/usr/local/Cellar/argp-standalone/1.3/include/argp.h=C2=A0 I am running macOS 11.4 with gcc -v:=C2=A0 Configured with: --prefix=3D/Library/Developer/CommandLineTools/usr --with-= gxx-include-dir=3D/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/i= nclude/c++/4.2.1 Apple clang version 12.0.5 (clang-1205.0.22.9) Target: x86_64-apple-darwin20.5.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin ---- On Sat, 07 Aug 2021 18:29:22 +0800 Guangxin Yang <[email protected]> wrote= ---- Hello there,=C2=A0 There may be a bug on macOS when calling arpg_help() with options having a = non-NULL arg value in the argp_option.=C2=A0 For the example=C2=A0https://www.gnu.org/software/libc/manual/html_node/Arg= p-Example-3.html, I added a case like this:=C2=A0 =C2=A0 =C2=A0 case ARGP_KEY_NO_ARGS: =C2=A0 =C2=A0 =C2=A0 argp_help(state->root_argp, =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 stderr, =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ARGP_HELP_BUG_ADDR | ARGP_HELP_DOC | ARG= P_HELP_USAGE | ARGP_HELP_LONG, =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 state->name); =C2=A0 =C2=A0 =C2=A0 exit(1); Compile and run without providing any arguments, I got a Segmentation fault= .=C2=A0 The output looks like this:=C2=A0 Usage: t [-qsv?V] [-o FILE] [--output=3DFILE] [--quiet] [--silent] [--verbo= se] =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [--help] [--usage] [--version] AR= G1 ARG2 Argp example #3 -- a program with options and arguments using argp =C2=A0 -o, --output=3DFILE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Output to FILE= instead of standard output =C2=A0 -q, -s, --quiet, --silent=C2=A0 Don't produce any output =C2=A0 -v, --verbose=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Produc= e verbose output =C2=A0 -?, --help =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 G= ive this help list =C2=A0 =C2=A0 =C2=A0 --usage=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 Give a short usage message =C2=A0 -V, Segmentation fault: 11 If I comment out these two lines:=C2=A0 21 =C2=A0 {"output", =C2=A0 'o', "FILE", 0, 22=C2=A0 =C2=A0 "Output to FILE instead of standard output" }, Things work perfectly.=C2=A0 On Redhat it is all ok.=C2=A0 I attached the modified example FYI.=C2=A0 Thanks for creating this wonderful piece.=C2=A0 :-0 Regards Guangxin=C2=A0