Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#9839 closed bug (fixed)

RTS options parser silently accepts invalid flags

Reported by: adamgundry Owned by: nkartashov
Priority: highest Milestone: 8.0.1
Component: Runtime System Version: 7.8.3
Keywords: newcomer Cc: simonmar, MikolajKonarski
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect result at runtime Test Case:
Blocked By: Blocking:
Related Tickets: #4243 Differential Rev(s): Phab:D748, Phab:D1039
Wiki Page:

Description

RTS options that do not take arguments (such as -T) silently ignore anything that comes afterwards. For example, +RTS -T,-s or +RTS -T-s turns on collection of GC statistics (-T) but does not print out a summary (-s). Instead, this should produce an error message. Otherwise, users may mistakenly think that options have been applied.

(This has just bitten us in a production system.)

Change History (13)

comment:1 Changed 3 years ago by MikolajKonarski

Cc: MikolajKonarski added

comment:2 Changed 3 years ago by thomie

Keywords: newcomer added
Owner: simonmar deleted

The file to change is: rts/RtsFlags.c. Not difficult.

comment:3 Changed 3 years ago by carlostome

Owner: set to carlostome

comment:4 Changed 3 years ago by carlostome

Differential Rev(s): Phab:D748
Status: newpatch

comment:5 Changed 3 years ago by Thomas Miedema <thomasmiedema@…>

In a20cc3d00c4ca0753fcdcb16199f173b3af44fe4/ghc:

rts: check arguments to flags that don't have any

There were some flags of the RTS that when given an argument (which they
don't have) were not firing an error.
e.g -Targument when the flag -T has no argument.
Now this is an error and affects the following flags:
-B -w -T -Z -P -Pa -c -t

Signed-off-by: Carlos Tomé <carlostome1990@gmail.com>

Reviewed By: austin, thomie, hvr

Differential Revision: https://phabricator.haskell.org/D748

GHC Trac Issues: #9839

comment:6 Changed 3 years ago by thomie

Resolution: fixed
Status: patchclosed

Thanks Carlos!

The only thing not handled by this patch is checking that arguments that are supposed to be numeric, are actually numeric. Currently atof is called on them, which accepts pretty much anything. Maybe a fix for this can be part of #4243.

comment:7 Changed 2 years ago by thomie

Milestone: 7.12.1
Owner: carlostome deleted
Priority: normalhigh
Resolution: fixed
Status: closednew

This patch broke +RTS -xc, and probably also +RTS -xt. Running make TEST=cgrun057 with a profiling compiler results in: "flag -x given an argument when none was expected: -xc"

Carlos: could you try fixing it?

comment:8 Changed 2 years ago by simonmar

Priority: highhighest

Must fix before 7.12.1

comment:9 Changed 2 years ago by nkartashov

Owner: set to nkartashov

comment:10 Changed 2 years ago by nkartashov

Differential Rev(s): Phab:D748Phab:D1039

comment:11 Changed 2 years ago by Thomas Miedema <thomasmiedema@…>

In 75de6131efc780dbdba30fa3fc48c16231ab66a9/ghc:

rts: fix incorrect checking start for -x arguments (#9839)

After previous fix, flag combinations such as -xt and -xc
resulted in an error due to the fact that the checking started from
index 2, which was always 'x' in that case.
Now they are correctly processed.

Differential Revision: https://phabricator.haskell.org/D1039

comment:12 Changed 2 years ago by thomie

Differential Rev(s): Phab:D1039Phab:D748, Phab:D1039
Resolution: fixed
Status: newclosed

comment:13 Changed 2 years ago by thoughtpolice

Milestone: 7.12.18.0.1

Milestone renamed

Note: See TracTickets for help on using tickets.