bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Possible bug in argp


From: Guangxin Yang
Subject: Re: Possible bug in argp
Date: Sat, 07 Aug 2021 18:44:02 +0800
User-agent: Zoho Mail

BTW, I am using argp 1.3 installed via homebrew: 

 /usr/local/Cellar/argp-standalone/1.3/include/argp.h 



I am running macOS 11.4 with gcc -v: 

Configured with: --prefix=/Library/Developer/CommandLineTools/usr 
--with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/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 <yang@along.ai> wrote ----







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 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]