Skip to content

fcntl(F_SETLK) for setting byte range locks is broken leading to data corruption #1927

Closed
@ned14

Description

@ned14

My WSL is the Creator's Update 1703. uname -r reports 4.4.0-43-Microsoft

I'm seeing fcntl(F_SETLK) permit multiple exclusive locks on WSL which is bad, it's instant data corruption for anything relying on this to work. This test launches four child processes and uses a shared memory map to check if fcntl(F_SETLK) is working correctly. This test passes on real Linux, fails badly on WSL:

integration/afio/shared_fs_mutex_byte_ranges/exclusives:
Tests that afio::algorithm::shared_fs_mutex::byte_ranges implementation implements exclusive locking
CHECK ((i.results[0] == 'o' && i.results[1] == 'k')) FAILED at /home/ned/windocs/boostish/afio/test/tests/shared_fs_mutex.cpp:283
Child reports Child 0 released exclusive lock to find child 3 had stolen my lock!
CHECK ((i.results[0] == 'o' && i.results[1] == 'k')) FAILED at /home/ned/windocs/boostish/afio/test/tests/shared_fs_mutex.cpp:283
Child reports Child 1 granted exclusive lock when child 2 already has exclusive lock!
CHECK ((i.results[0] == 'o' && i.results[1] == 'k')) FAILED at /home/ned/windocs/boostish/afio/test/tests/shared_fs_mutex.cpp:283
Child reports Child 2 released exclusive lock to find child 1 had stolen my lock!
CHECK ((i.results[0] == 'o' && i.results[1] == 'k')) FAILED at /home/ned/windocs/boostish/afio/test/tests/shared_fs_mutex.cpp:283
Child reports Child 3 granted exclusive lock when child 0 already has exclusive lock!
4 checks passed  4 checks failed  duration 5150 ms

While you're at it, if you could implement the non-insane fcntl(F_OFD_SETLK) locks that would be very useful. The fcntl(F_SETLK) type locks are stupid.

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