Skip to content

Potential data race on acceccing m_direntLookup #945

@mgautierfr

Description

@mgautierfr

Investigating cache configuration, it seems that we have a potential data race about accessing/initializing m_direntLookup.

This data race is in FileImpl::direntLookup() method : https://github.com/openzim/libzim/blob/main/src/fileimpl.cpp#L277-L293

The field m_direntLookup (std::unique_ptr) is accessed from different threads and std::unique_ptr is not thread safe. (https://learn.microsoft.com/en-us/cpp/standard-library/thread-safety-in-the-cpp-standard-library?view=msvc-170)
The lock we have only avoid us to create the dirent lookup twice but it doesn't prevent us to read and write m_direntLookup in the same time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions