Thread overview
'scope' finds stack corruption bug in druntime
Apr 04, 2017
Walter Bright
Apr 04, 2017
Walter Bright
April 04, 2017
https://github.com/dlang/druntime/pull/1799

In complex code, it is impractical to check for this stuff manually. I'm happy that 'scope' is proving its worth.
April 04, 2017
On Tuesday, 4 April 2017 at 08:32:33 UTC, Walter Bright wrote:
> https://github.com/dlang/druntime/pull/1799
>
> In complex code, it is impractical to check for this stuff manually. I'm happy that 'scope' is proving its worth.

Not a bug. Exception is allocated in the outer function and is always caught in the outer function. How can it escape?

-Steve
April 04, 2017
On 4/4/2017 2:22 AM, Steven Schveighoffer wrote:
> On Tuesday, 4 April 2017 at 08:32:33 UTC, Walter Bright wrote:
>> https://github.com/dlang/druntime/pull/1799
>>
>> In complex code, it is impractical to check for this stuff manually. I'm happy
>> that 'scope' is proving its worth.
>
> Not a bug. Exception is allocated in the outer function and is always caught in
> the outer function. How can it escape?

You are correct, it is a false positive. I updated the PR with another method, as doing the flow analysis to detect the false positive isn't simple.

April 04, 2017
On 4/4/17 6:19 AM, Walter Bright wrote:
> On 4/4/2017 2:22 AM, Steven Schveighoffer wrote:
>> On Tuesday, 4 April 2017 at 08:32:33 UTC, Walter Bright wrote:
>>> https://github.com/dlang/druntime/pull/1799
>>>
>>> In complex code, it is impractical to check for this stuff manually.
>>> I'm happy
>>> that 'scope' is proving its worth.
>>
>> Not a bug. Exception is allocated in the outer function and is always
>> caught in
>> the outer function. How can it escape?
>
> You are correct, it is a false positive. I updated the PR with another
> method, as doing the flow analysis to detect the false positive isn't
> simple.
>

One thing to keep in mind, I'm probably not the only one to consider a pre-allocated scope exception for flow control on a very recursive algorithm using inner functions. If the scope changes are catching a false positive here, they will catch one in others' code as well. Especially people who want to write @nogc code.

The updates you have implemented are IMO much more complex than an "escape hatch" throwing of an exception to unwind the stack. Not horrific, but definitely more error prone and less intuitive.

-Steve