Issue 14993 - Allocating in a destructor segfaults instead of throwing InvalidMemoryOperationError
Summary: Allocating in a destructor segfaults instead of throwing InvalidMemoryOperati...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2015-09-01 11:18 UTC by Vladimir Panteleev
Modified: 2015-10-14 14:36 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Vladimir Panteleev 2015-09-01 11:18:27 UTC
/////// test.d ///////
struct S
{
    ~this()
    {
        new int;
    }
}

void main()
{
    foreach (n; 0..10)
    {
        new S[10];
    }
}
//////////////////////

Introduced in https://github.com/D-Programming-Language/druntime/pull/1325
Comment 1 Martin Nowak 2015-09-06 04:22:09 UTC
This broke b/c of an ugly hack in druntime which excluded throwing typeinfo(Ex).init.ptr style exceptions from stacktraces.
https://github.com/D-Programming-Language/druntime/blob/46fdff3c82d917c94a79f355274770147bf8bdae/src/rt/deh.d#L22

The underlying issue is the same as issue 14119, stacktraces should be @nogc.
Comment 3 github-bugzilla 2015-10-14 10:34:33 UTC
Commits pushed to stable at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/ee306cc93e7feb894f8fb618b4aae340878c0d54
fix Issue 14993 - segfault for InvalidMemoryOperationError

- creating a stacktrace currently uses the GC (thus might recurse
  infinetely when the GC throws an exception itself)
- suppress stack traces for OutOfMemoryError,
  InvalidMemoryOperationError, and FinalizeError

https://github.com/D-Programming-Language/druntime/commit/d3dad79e43a703800ae4407b3d33812f869e3fcc
Merge pull request #1406 from MartinNowak/fix14993

fix Issue 14993 - segfault for InvalidMemoryOperationError