Skip to content

exp/inotify: data race #3713

@dvyukov

Description

@dvyukov
ThreadSanitizer says:
WARNING: Possible data race during read of size 1 at 0xf840046440: {{{
   T3 (L{}):
    #0  exp/inotify..readEvents /usr/local/google/home/dvyukov/gorace/go/src/pkg/exp/inotify/inotify_linux.go:190
    #1  runtime.goexit /usr/local/google/home/dvyukov/gorace/go/src/pkg/runtime/proc.c:273
  Concurrent write(s) happened at (OR AFTER) these points:
   T2 (L{}):
    #0  exp/inotify..AddWatch /usr/local/google/home/dvyukov/gorace/go/src/pkg/exp/inotify/inotify_linux.go:119
    #1  exp/inotify..Watch /usr/local/google/home/dvyukov/gorace/go/src/pkg/exp/inotify/inotify_linux.go:126
    #2  exp/inotify.TestInotifyEvents /usr/local/google/home/dvyukov/gorace/go/src/pkg/exp/inotify/inotify_linux_test.go:30
    #3  testing.tRunner /usr/local/google/home/dvyukov/gorace/go/src/pkg/testing/testing.go:273
    #4  runtime.goexit /usr/local/google/home/dvyukov/gorace/go/src/pkg/runtime/proc.c:273
  Location 0xf840046440 is 0 bytes inside a block starting at 0xf840046440 of size 32 allocated by T2 from heap:
    #0   
    #1  exp/inotify.TestInotifyEvents /usr/local/google/home/dvyukov/gorace/go/src/pkg/exp/inotify/inotify_linux_test.go:18
    #2  testing.tRunner /usr/local/google/home/dvyukov/gorace/go/src/pkg/testing/testing.go:273
    #3  runtime.goexit /usr/local/google/home/dvyukov/gorace/go/src/pkg/runtime/proc.c:273
}}}

It seems that paths map is used concurrently w/o synchronization:
                w.paths[wd] = path
                event.Name = w.paths[int(raw.Wd)]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions