Jump to page: 1 2
Thread overview
[Issue 17650] [REG v2.075.0 b1-b4] std.getopt range violation
Jul 14, 2017
Jon Degenhardt
Jul 14, 2017
Martin Nowak
Jul 15, 2017
Vladimir Panteleev
Jul 15, 2017
Vladimir Panteleev
Jul 15, 2017
Vladimir Panteleev
Jul 15, 2017
Jon Degenhardt
Jul 15, 2017
ZombineDev
Jul 15, 2017
Jon Degenhardt
Jul 15, 2017
Jon Degenhardt
Jul 15, 2017
Jon Degenhardt
July 14, 2017
https://issues.dlang.org/show_bug.cgi?id=17650

Jon Degenhardt <jrdemail2000-dlang@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|enhancement                 |regression

--
July 14, 2017
https://issues.dlang.org/show_bug.cgi?id=17650

Martin Nowak <code@dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |code@dawg.eu

--- Comment #1 from Martin Nowak <code@dawg.eu> ---
We'll address this with 2.075.1 to not delay the release even further.

--
July 15, 2017
https://issues.dlang.org/show_bug.cgi?id=17650

--- Comment #2 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
Introduced in https://github.com/dlang/phobos/pull/5351

--
July 15, 2017
https://issues.dlang.org/show_bug.cgi?id=17650

--- Comment #3 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
Interesting - looking at the PR, this doesn't really seem like a regression, rather that the addition of the @safe attribute exposed an out-of-bounds array access that was always there. Feel free to reclassify, Jon.

--
July 15, 2017
https://issues.dlang.org/show_bug.cgi?id=17650

--- Comment #4 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
Actually, I believe we do count a breakage as a regression if something breaks for the end-user, regardless of what is going on under the hood. E.g. it's possible that for supported architectures, the range violation was completely benign.

--
July 15, 2017
https://issues.dlang.org/show_bug.cgi?id=17650

--- Comment #5 from Jon Degenhardt <jrdemail2000-dlang@yahoo.com> ---
Wow. So I introduced this, initiated by trying add new unit tests. And my own unit tests caught it, but unfortunately, not the unit tests I added to Phobos. How ironic. Thanks for investigating Vladimir.

--
July 15, 2017
https://issues.dlang.org/show_bug.cgi?id=17650

ZombineDev <petar.p.kirov@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |petar.p.kirov@gmail.com

--- Comment #6 from ZombineDev <petar.p.kirov@gmail.com> ---
The error doesn't make sense to me. @safe adds bounds checks where there are none only when building with -release. I.e. if we're not building with -release, there shouldn't be any change in behavior - bounds checking should already be present (-boundscheck defaults to 'on' in that case). Am I missing something?

--
July 15, 2017
https://issues.dlang.org/show_bug.cgi?id=17650

--- Comment #7 from Jon Degenhardt <jrdemail2000-dlang@yahoo.com> ---
(In reply to ZombineDev from comment #6)
> The error doesn't make sense to me. @safe adds bounds checks where there are none only when building with -release. I.e. if we're not building with -release, there shouldn't be any change in behavior - bounds checking should already be present (-boundscheck defaults to 'on' in that case). Am I missing something?

There was already an existing range violation, one that didn't have a unit test in the std.getopt module. Adding @safe to the function turned on bounds checking in debug mode. I had a unit test in my own code (not std.geopt) that triggered the out-of-bounds case. This unit test didn't get run until I actually ran my own unit tests with the new code.

The out-of-bounds case occurs when there is an command line argument that is a single dash. e.g.

   $ myprogram -x a  # okay
   $ myprogram -x -  # out-of-bounds

In the single dash case there's an attempt to access one character past it. Kind of understandable there wasn't a unit test for this originally. If you want to see the sequence that led to adding @safe read https://github.com/dlang/phobos/pull/5347.

--
July 15, 2017
https://issues.dlang.org/show_bug.cgi?id=17650

--- Comment #8 from Jon Degenhardt <jrdemail2000-dlang@yahoo.com> ---
I'm preparing a PR to fix the underlying issue. A concern for the general release is that a single hyphen is often used to represent standard input in command line args. e.g.

$ cat file.txt | my_d_program --file - > out.txt

This will trigger the bounds check error if my_d_program is compiled in safe mode.

--
July 15, 2017
https://issues.dlang.org/show_bug.cgi?id=17650

--- Comment #9 from Jon Degenhardt <jrdemail2000-dlang@yahoo.com> ---
https://github.com/dlang/phobos/pull/5612

--
« First   ‹ Prev
1 2