Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
July 22, 2016 How do I use the ScopedAllocator? | ||||
---|---|---|---|---|
| ||||
Is it OK to use makeArray with ScopedAllocator to allocate something with a destructor? Because the destructor is not called when ScopedAllocator goes out of scope. And if I manually call dispose, I get a double free error: struct A { int a; ~this() nothrow { } } void test(){ import std.experimental.allocator.mallocator : Mallocator; import std.experimental.allocator.building_blocks.scoped_allocator : ScopedAllocator; import std.experimental.allocator; ScopedAllocator!Mallocator alloc; auto b = alloc.makeArray!A(10, A(1)); auto c = alloc.makeArray!A(2, A(2)); alloc.dispose(b); alloc.dispose(c); } void main() { test(); } |
July 24, 2016 Re: How do I use the ScopedAllocator? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Yuxuan Shui | On Friday, 22 July 2016 at 01:54:28 UTC, Yuxuan Shui wrote:
> auto b = alloc.makeArray!A(10, A(1));
> auto c = alloc.makeArray!A(2, A(2));
I noticed (using dpaste) if you edit the 'b' line to only allocate 5 structs, and it won't crash. 6 or more, crash. Maybe a bug?
|
July 25, 2016 Re: How do I use the ScopedAllocator? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick Treleaven | On Sunday, 24 July 2016 at 20:48:55 UTC, Nick Treleaven wrote:
> On Friday, 22 July 2016 at 01:54:28 UTC, Yuxuan Shui wrote:
>> auto b = alloc.makeArray!A(10, A(1));
>> auto c = alloc.makeArray!A(2, A(2));
>
> I noticed (using dpaste) if you edit the 'b' line to only allocate 5 structs, and it won't crash. 6 or more, crash. Maybe a bug?
Valgrind reports double free anyways. I think it's just the inaccuracy of the glibc double free detection.
|
July 28, 2016 Re: How do I use the ScopedAllocator? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Yuxuan Shui | On Monday, 25 July 2016 at 07:33:25 UTC, Yuxuan Shui wrote: > Valgrind reports double free anyways. I think it's just the inaccuracy of the glibc double free detection. Please file a bug - thanks! https://issues.dlang.org/ I found this, maybe related: https://issues.dlang.org/show_bug.cgi?id=16046 |
August 02, 2016 Re: How do I use the ScopedAllocator? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick Treleaven | On Thursday, 28 July 2016 at 11:48:40 UTC, Nick Treleaven wrote: > On Monday, 25 July 2016 at 07:33:25 UTC, Yuxuan Shui wrote: >> Valgrind reports double free anyways. I think it's just the inaccuracy of the glibc double free detection. > > Please file a bug - thanks! > https://issues.dlang.org/ > > I found this, maybe related: > https://issues.dlang.org/show_bug.cgi?id=16046 Fix: https://github.com/dlang/phobos/pull/4702 |
Copyright © 1999-2021 by the D Language Foundation