Bug 15836 – [REG 2.071-b1] memory error when a class is not implicitly destructed and constructed with new

Status
RESOLVED
Resolution
INVALID
Severity
regression
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-03-27T02:46:00Z
Last change time
2016-04-01T10:21:54Z
Assigned to
nobody
Creator
b2.temp

Attachments

IDFilenameSummaryContent-TypeSize
1592bug.zipsource + dub description to reproduce the issueapplication/zip1034

Comments

Comment #0 by b2.temp — 2016-03-27T02:46:13Z
Created attachment 1592 source + dub description to reproduce the issue - download the attachement - unzip, cd to the dir - try the dub package from the attachement with - dub --config=strange - dub --config=ok1 - dub --config=ok2 - dub --config=ok3 without explicit destruction (strange config) the following error appears, at the end of the run-time: > core.exception.InvalidMemoryOperationError@src/core/exception.d(693): Invalid memory operation This error never appeared before and the class exists since 20 monthes, which leads me to think that there's a regression, maybe related to the GC or at least in druntime.
Comment #1 by b2.temp — 2016-03-30T22:54:02Z
still present in 2.071-b2
Comment #2 by r.sagitario — 2016-03-31T07:12:06Z
The trouble is that the destructor of MemoryStream is calling GC.addrOf in the finalization stage of a collection, and there is a new check that explicitly disallows this. At the sweep stage, the GC is in an intermediate state that might not yield sensible results for GC.addrOf and friends. I think using this as an indicator whether a block of memory is allocated by the GC depends on its exact implementation (block immediately "freed" after finalization?), and it might restrict the inner workings of the GC too much if we make this a requirement.
Comment #3 by b2.temp — 2016-03-31T08:19:31Z
Ok I close. The problem can be solved without using AddrOf.
Comment #4 by code — 2016-04-01T10:21:54Z
Please post reduced test cases as inline code here, rather than providing zip projects with build files. With 2.071.0 calls to GC.free from a finalizer http://dlang.org/changelog/2.071.0.html are allowed (they will be ignored), so you can use that to replace the usage of addrOf.