GPUOpen-LibrariesAndSDKs / Capsaicin

AMD ARR team rendering framework
MIT License
363 stars 32 forks source link

setDebugView(const std::string_view &) malfunctions. #19

Open Hineven opened 4 months ago

Hineven commented 4 months ago

at capsaicin_internal.cpp: 665:

bool CapsaicinInternal::setDebugView(std::string_view const &name) noexcept
{
    auto debugView = std::find_if(
        debug_views_.cbegin(), debug_views_.cend(), [this](auto val) { return debug_view_ == val.first; });
    if (debugView == debug_views_.cend())
    {
        GFX_PRINTLN("Error: Requested invalid debug view: %s", name.data());
        return false;
    }
    debug_view_ = name;
    return true;
}

debug_view_ = name; assumes that name is a string view of a string whose lifetime expands across frames. When a string_view of a temporary string object is passed in (and it is "equal" to one of the strings within the vector debug_views), the function silently fails, debug_view sooner become meaningless and ultimately causes random behavior. I'll suggest a fix about changing debug_view_ = name; to debug_view_ = *debugView; Also, auto debugView = std::find_if(debug_views_.cbegin(), debug_views_.cend(), [this](auto val) { return debug_view_ == val.first; }); seems to not be doing correct validation.

maoliver-amd commented 4 months ago

Thanks, yes thats correct and so weve fixed this internally and should be available in the next release version.