mmp / pbrt-v4

Source code to pbrt, the ray tracer described in the forthcoming 4th edition of the "Physically Based Rendering: From Theory to Implementation" book.
https://pbrt.org
Apache License 2.0
2.83k stars 440 forks source link

Potential incorrect mutex usage in ptex cache construction #409

Closed Hyiker closed 8 months ago

Hyiker commented 8 months ago

In src/pbrt/texture.cpp:598, the constructor of PtexTextureBase:

std::mutex mutex;
mutex.lock();
if (!cache) {
    int maxFiles = 100;
    size_t maxMem = 1ull << 32;  // 4GB
    bool premultiply = true;

    cache = Ptex::PtexCache::create(maxFiles, maxMem, premultiply, nullptr,
                                    &errorHandler);
    // TODO? cache->setSearchPath(...);
}
mutex.unlock();

a non-static mutex is constructed to ensure thread safe ptex cache creation, I didn't get it, perhaps it's a mistake?

mmp commented 8 months ago

Wow, yeah, that was a definite mistake! Thanks for reporting that. Fixed now.