After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 577727 - assertion failure in GOption parsing with "--string-option --other-option" argv
assertion failure in GOption parsing with "--string-option --other-option" argv
Status: RESOLVED INVALID
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal critical
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2009-04-02 13:58 UTC by Christian Persch
Modified: 2009-04-02 14:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
testcase (1.89 KB, text/plain)
2009-04-02 13:59 UTC, Christian Persch
Details
corrected testcase (1.87 KB, text/plain)
2009-04-02 14:07 UTC, Christian Persch
Details

Description Christian Persch 2009-04-02 13:58:50 UTC
Consider these options:

static GOptionEntry options[] = {
    { "string-required", 's', 0, G_OPTION_ARG_STRING, &string, "String", "[ARG]" },
  };

(full testcase attached).

$ ./testoption --string-required --string-required

GLib:ERROR:goption.c:991:parse_arg: assertion failed: (value || OPTIONAL_ARG (entry) || NO_ARG (entry))

  • #4 g_assertion_message_expr
  • #5 parse_arg
    at goption.c line 991
  • #6 parse_long_option
    at goption.c line 1350
  • #7 g_option_context_parse
    at goption.c line 1644
  • #8 main
    at testoption.c line 54

Comment 1 Christian Persch 2009-04-02 13:59:38 UTC
Created attachment 131913 [details]
testcase
Comment 2 Christian Persch 2009-04-02 14:06:42 UTC
Oops, I made a mistake in comment 0: it happens if you have a G_OPTION_FLAG_OPTIONAL_ARG option. So the correct way to repro is:

$ ./testoption --string --string

Comment 3 Christian Persch 2009-04-02 14:07:33 UTC
Created attachment 131914 [details]
corrected testcase
Comment 4 Christian Persch 2009-04-02 14:20:01 UTC
Hmm. It seems I misread the docs; they say:

G_OPTION_FLAG_OPTIONAL_ARG

For options of the G_OPTION_ARG_CALLBACK kind, this flag indicates that the argument supply is optional. If no argument is given then data of GOptionParseFunc will be set to NULL. Since 2.8

So G_OPTION_FLAG_OPTIONAL_ARG doesn't apply to G_OPTION_ARG_STRING. 

Sorry for the wasted bug.