Code: ----- class Obj{ synchronized void trigger(){ new ubyte[1]; } } void main(){ auto k = new shared Obj; k.trigger; } ----- When compiled on win32 with just "dmd", it runs fine. When compiled with "dmd -O -g", it gives the following error at runtime: ----- object.Error@(0): Access Violation ---------------- 0x00000065 0x00402C6B in _d_newarrayU 0x004023EF 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:\programs\stuff\dlang\synchronized-memory-bug\a.d(8) 0x76D5336A in BaseThreadInitThunk 0x77369902 in RtlInitializeExceptionChain 0x773698D5 in RtlInitializeExceptionChain ----- Win64 is OK. Win32 with dmd 2.068.2 or earlier is OK. Win32 with dmd 2.069.0 or later gives the error above. Original thread at D.learn: https://forum.dlang.org/post/wdebefxpjvvxyqiollkw@forum.dlang.org
https://github.com/dlang/dmd/pull/6965
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/d728c0f9ba8f762682eced7da06f8123ed4d7f71 fix Issue 17481 - [REG 2.069.0] synchronized: Access Violation with dmd -O on win32 https://github.com/dlang/dmd/commit/5fa367d499fd688d02e53afc9c2ceef31fb67619 Merge pull request #6965 from WalterBright/fix17481 fix Issue 17481 - [REG 2.069.0] synchronized: Access Violation with d⦠merged-on-behalf-of: Martin Nowak <code@dawg.eu>
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/d728c0f9ba8f762682eced7da06f8123ed4d7f71 fix Issue 17481 - [REG 2.069.0] synchronized: Access Violation with dmd -O on win32 https://github.com/dlang/dmd/commit/5fa367d499fd688d02e53afc9c2ceef31fb67619 Merge pull request #6965 from WalterBright/fix17481
Commits pushed to newCTFE at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/d728c0f9ba8f762682eced7da06f8123ed4d7f71 fix Issue 17481 - [REG 2.069.0] synchronized: Access Violation with dmd -O on win32 https://github.com/dlang/dmd/commit/5fa367d499fd688d02e53afc9c2ceef31fb67619 Merge pull request #6965 from WalterBright/fix17481