I can crash program (core.exception.InvalidMemoryOperationError) by using __FUNCTION__ in a class ctor
Steven Schveighoffer
schveiguy at gmail.com
Fri Jan 18 15:42:55 UTC 2019
On 1/18/19 10:35 AM, Steven Schveighoffer wrote:
>
> https://github.com/blachlylab/dhtslib/blob/master/source/dhtslib/htslib/hts_log.d#L94
>
>
> That is your problem. toStringz is going to attempt to allocate using
> the GC. Allocating during a GC collection causes an
> InvalidMemoryOperationError.
>
> Take that out of your destructor, and you should not cause that error.
>
> Alternatively, fix the logger so it doesn't use the GC.
If I had to guess why __FUNCTION__ causes it and others do not, then I
would say it's because toStringz has particular cases where it DOESN'T
allocate, and that depends completely on the length of the string.
https://github.com/dlang/phobos/blob/master/std/string.d#L364-L365
-Steve
More information about the Digitalmars-d
mailing list