public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/14024] New: argp: mis-formatted --help output
@ 2012-04-26 17:12 mark-sourceware at glines dot org
2012-04-26 17:14 ` [Bug libc/14024] " mark-sourceware at glines dot org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: mark-sourceware at glines dot org @ 2012-04-26 17:12 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=14024
Bug #: 14024
Summary: argp: mis-formatted --help output
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: unassigned@sourceware.org
ReportedBy: mark-sourceware@glines.org
CC: drepper.fsp@gmail.com
Classification: Unclassified
Apologies if this is logged against the wrong component, please reassign as
needed.
The argp feature can sometimes generate mis-formatted --help output. I've
reproduced this in glibc 2.3.4 (RHEL), libc6 2.13-20 (Ubuntu), and in the git
master branch (as of 2012-04-26). A combination of conditions seem to be
needed to trigger the problem:
* Manual line wrapping must occur due to the option description containing a
newline
* Automatic line wrapping of an option description must occur due to the
remaining text going past the right margin
* The argp_fmtstream_t buffer must be too small (or have too much preceding
text in it) for the new prefix whitespace to fit
I will attach a test program that triggers the issue. I will also provide more
details of how it goes wrong - I've done some analysis of the problem but not
enough to know the best way to fix it.
The mis-formatted output looks like:
$ ./test
Usage: test [OPTION...]
tttttttttttttttttt
--a bbbbbbbbbbbbbbbbb
--cc =d eeeeeeeeeeeeeeeee
-f, --g hhhhhhhhhhhhhhhhhhhh
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
-?, --help Give this help list
--usage Give a short usage message
The expected output should be:
$ ./test
Usage: test [OPTION...]
tttttttttttttttttt
--a bbbbbbbbbbbbbbbbb
--cc=d eeeeeeeeeeeeeeeee
-f, --g hhhhhhhhhhhhhhhhhhhh
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
-?, --help Give this help list
--usage Give a short usage message
When the problem occurs, the prefix whitespace for the "i" line has been moved
to appear between "--cc" and "=d". Shortening any of the text strings causes
the correct output to be emitted.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/14024] argp: mis-formatted --help output
2012-04-26 17:12 [Bug libc/14024] New: argp: mis-formatted --help output mark-sourceware at glines dot org
@ 2012-04-26 17:14 ` mark-sourceware at glines dot org
2012-04-26 17:17 ` mark-sourceware at glines dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: mark-sourceware at glines dot org @ 2012-04-26 17:14 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=14024
--- Comment #1 from Mark Glines <mark-sourceware at glines dot org> 2012-04-26 17:13:48 UTC ---
Created attachment 6369
--> http://sourceware.org/bugzilla/attachment.cgi?id=6369
14024.c
Here is the reproducer.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/14024] argp: mis-formatted --help output
2012-04-26 17:12 [Bug libc/14024] New: argp: mis-formatted --help output mark-sourceware at glines dot org
2012-04-26 17:14 ` [Bug libc/14024] " mark-sourceware at glines dot org
@ 2012-04-26 17:17 ` mark-sourceware at glines dot org
2012-04-26 17:28 ` mark-sourceware at glines dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: mark-sourceware at glines dot org @ 2012-04-26 17:17 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=14024
Mark Glines <mark-sourceware at glines dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #6369|0 |1
is obsolete| |
--- Comment #2 from Mark Glines <mark-sourceware at glines dot org> 2012-04-26 17:16:48 UTC ---
Created attachment 6370
--> http://sourceware.org/bugzilla/attachment.cgi?id=6370
14024.c
Sorry, here's the reproducer. The previous program had one fewer "b"
character, and thus, didn't reproduce the problem.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/14024] argp: mis-formatted --help output
2012-04-26 17:12 [Bug libc/14024] New: argp: mis-formatted --help output mark-sourceware at glines dot org
2012-04-26 17:14 ` [Bug libc/14024] " mark-sourceware at glines dot org
2012-04-26 17:17 ` mark-sourceware at glines dot org
@ 2012-04-26 17:28 ` mark-sourceware at glines dot org
2014-06-25 11:11 ` fweimer at redhat dot com
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: mark-sourceware at glines dot org @ 2012-04-26 17:28 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=14024
--- Comment #3 from Mark Glines <mark-sourceware at glines dot org> 2012-04-26 17:28:13 UTC ---
I've done some preliminary analysis of this issue. It appears that
__argp_fmtstream_update attempts to insert leading whitespace to indent the
remainder of an option's description (argp/argp-fmtstream.c:131). However,
when the buffer does not have enough space for the additional whitespace, the
whitespace is instead printed directly to the output stream
(argp/argp-fmtstream.c:144).
When the buffer contained previous data that had not been written to the output
stream yet, this results in the output being printed out of order, appearing
mis-formatted to the user.
It's not immediately clear how to solve this. The issue seems to be that
__argp_fmtstream_update can insert data into the buffer, but has no means to
grow the buffer if necessary. The normal means of growing the buffer
(__argp_fmtstream_ensure) is a caller of __argp_fmtstream_update.
One option to fix this would be to flush the formatted output from the buffer
(if any), and then try again.
A second option would be to allocate a larger buffer, either duplicating the
buffer-expansion code in __argp_fmtstream_ensure, or splitting it out into a
third function which both can use.
A third option would be to change __argp_fmtstream_update to return an int
(currently it returns void), and have it return the amount of formatted text in
this case, so that __argp_fmtstream_ensure can only write the formatted subset
of the data in the buffer. This option seems like it would have a higher
impact, as __argp_fmtstream_update has multiple callers.
File names and line numbers in the above text are referring to the argp code as
it was in today's git, revision 0ac229c819afd15ba323838ba72d0a409f16acc4.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/14024] argp: mis-formatted --help output
2012-04-26 17:12 [Bug libc/14024] New: argp: mis-formatted --help output mark-sourceware at glines dot org
` (2 preceding siblings ...)
2012-04-26 17:28 ` mark-sourceware at glines dot org
@ 2014-06-25 11:11 ` fweimer at redhat dot com
2014-08-01 13:46 ` beaux_monde at tut dot by
2014-08-01 20:53 ` beaux_monde at tut dot by
5 siblings, 0 replies; 7+ messages in thread
From: fweimer at redhat dot com @ 2014-06-25 11:11 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=14024
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Flags| |security-
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/14024] argp: mis-formatted --help output
2012-04-26 17:12 [Bug libc/14024] New: argp: mis-formatted --help output mark-sourceware at glines dot org
` (3 preceding siblings ...)
2014-06-25 11:11 ` fweimer at redhat dot com
@ 2014-08-01 13:46 ` beaux_monde at tut dot by
2014-08-01 20:53 ` beaux_monde at tut dot by
5 siblings, 0 replies; 7+ messages in thread
From: beaux_monde at tut dot by @ 2014-08-01 13:46 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=14024
Serge Roussak <beaux_monde at tut dot by> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |beaux_monde at tut dot by
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/14024] argp: mis-formatted --help output
2012-04-26 17:12 [Bug libc/14024] New: argp: mis-formatted --help output mark-sourceware at glines dot org
` (4 preceding siblings ...)
2014-08-01 13:46 ` beaux_monde at tut dot by
@ 2014-08-01 20:53 ` beaux_monde at tut dot by
5 siblings, 0 replies; 7+ messages in thread
From: beaux_monde at tut dot by @ 2014-08-01 20:53 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=14024
--- Comment #4 from Serge Roussak <beaux_monde at tut dot by> ---
Confirm this issue.
I found that it appeared if the doc field of the argp_option structure has some
"critical" length. But if some chars more or less than it all is OK again.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-08-01 20:53 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-26 17:12 [Bug libc/14024] New: argp: mis-formatted --help output mark-sourceware at glines dot org
2012-04-26 17:14 ` [Bug libc/14024] " mark-sourceware at glines dot org
2012-04-26 17:17 ` mark-sourceware at glines dot org
2012-04-26 17:28 ` mark-sourceware at glines dot org
2014-06-25 11:11 ` fweimer at redhat dot com
2014-08-01 13:46 ` beaux_monde at tut dot by
2014-08-01 20:53 ` beaux_monde at tut dot by
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).