| Thread overview | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
June 08, 2017 DMD [-O flag] vs. [memory allocation in a synchronized class] | ||||
|---|---|---|---|---|
| ||||
Hi,
This code works well with the unoptimized compilation with DMD.
import std.array;
synchronized class Obj{
private int[] arr;
void trigger(){ arr.length += 1; }
}
void main(){
auto k = new shared Obj;
k.trigger;
}
And when I use the -O option, it shows the following error in the trigger() method:
core.exception.InvalidMemoryOperationError@src\core\exception.d(696): Invalid memory operation
Why? o.O
| ||||
June 08, 2017 Re: DMD [-O flag] vs. [memory allocation in a synchronized class] | ||||
|---|---|---|---|---|
| ||||
Posted in reply to realhet | worksforme with -O, and with -O -inline. | |||
June 08, 2017 Re: DMD [-O flag] vs. [memory allocation in a synchronized class] | ||||
|---|---|---|---|---|
| ||||
Posted in reply to ketmar | On Thursday, 8 June 2017 at 10:48:41 UTC, ketmar wrote:
> worksforme with -O, and with -O -inline.
I forgot to mention, that I'm generating win32 output.
DMD32 D Compiler v2.074.0
| |||
June 08, 2017 Re: DMD [-O flag] vs. [memory allocation in a synchronized class] | ||||
|---|---|---|---|---|
| ||||
Posted in reply to realhet | realhet wrote:
> On Thursday, 8 June 2017 at 10:48:41 UTC, ketmar wrote:
>> worksforme with -O, and with -O -inline.
>
> I forgot to mention, that I'm generating win32 output.
> DMD32 D Compiler v2.074.0
mine: GNU/Linux, 32 bit, dmd git HEAD.
| |||
June 08, 2017 Re: DMD [-O flag] vs. [memory allocation in a synchronized class] | ||||
|---|---|---|---|---|
| ||||
Posted in reply to ketmar | I've managed to narrow the problem even more:
//win32 dmd -O
class Obj{
synchronized void trigger(){ new ubyte[1]; }
}
void main(){
auto k = new shared Obj;
k.trigger;
}
This time I got a more sophisticated error message:
object.Error@(0): Access Violation
----------------
0x7272456D in SymInitialize
0x00402667
0x00402A97
0x00402998
0x004022A0
0x76F13744 in BaseThreadInitThunk
0x773B9E54 in RtlSetCurrentTransaction
0x773B9E1F in RtlSetCurrentTransaction
| |||
June 08, 2017 Re: DMD [-O flag] vs. [memory allocation in a synchronized class] | ||||
|---|---|---|---|---|
| ||||
Posted in reply to realhet | On Thursday, 8 June 2017 at 11:41:40 UTC, realhet wrote:
> I've managed to narrow the problem even more:
>
> //win32 dmd -O
>
> class Obj{
> synchronized void trigger(){ new ubyte[1]; }
> }
>
> void main(){
> auto k = new shared Obj;
> k.trigger;
> }
>
> This time I got a more sophisticated error message:
>
> object.Error@(0): Access Violation
> ----------------
> 0x7272456D in SymInitialize
> 0x00402667
> 0x00402A97
> 0x00402998
> 0x004022A0
> 0x76F13744 in BaseThreadInitThunk
> 0x773B9E54 in RtlSetCurrentTransaction
> 0x773B9E1F in RtlSetCurrentTransaction
I can reproduce this under win32, and it breaks somewhere between 2.068.2 and 2.069.0.
The move instructive message with "dmd -O -g":
object.Error@(0): Access Violation
----------------
0x00000065
0x00402C33 in _d_newarrayU
0x004022EB in _d_newarrayT
0x00402A7F in scope void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll()
0x00402980 in _d_run_main
0x00402288 in main at C:\a.d(8)
0x757F336A in BaseThreadInitThunk
0x77409902 in RtlInitializeExceptionChain
0x774098D5 in RtlInitializeExceptionChain
Perhaps a regression should be filed, or searched for, at issues.dlang.org. I can do it, but not right now, and would be glad if someone beats me to it.
Ivan Kazmenko.
| |||
June 08, 2017 Re: DMD [-O flag] vs. [memory allocation in a synchronized class] | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Ivan Kazmenko | On Thursday, 8 June 2017 at 15:35:06 UTC, Ivan Kazmenko wrote: > Perhaps a regression should be filed, or searched for, at issues.dlang.org. I can do it, but not right now, and would be glad if someone beats me to it. Reported: https://issues.dlang.org/show_bug.cgi?id=17481 | |||
June 09, 2017 Re: DMD [-O flag] vs. [memory allocation in a synchronized class] | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Ivan Kazmenko | On Thursday, 8 June 2017 at 17:39:41 UTC, Ivan Kazmenko wrote:
> Reported: https://issues.dlang.org/show_bug.cgi?id=17481
Thank You!
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply