[Issue 23158] New: synchronized class data is not locked in free function in same module

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jun 4 17:01:49 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=23158

          Issue ID: 23158
           Summary: synchronized class data is not locked in free function
                    in same module
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: nick at geany.org

synchronized class C {
        private int i;
}

public void foo(C c) {
        c.i++;
}

$ dmd -vasm -c old/syncclass.d
_D9syncclass3fooFCQq1CZv:
0000:   FF 40 08                 inc       dword ptr 8[EAX]
0003:   C3                       ret

foo just incremented `c.i` without locking `c`. Field access should probably be
an error outside a `synchronized (c)` statement, unless `c` is `shared`.

--


More information about the Digitalmars-d-bugs mailing list