Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Hineven opened this issue Apr 19, 2024 · 1 comment
Open

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

Hineven opened this issue Apr 19, 2024 · 1 comment

Comments

@Hineven
Copy link

Hineven commented Apr 19, 2024

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.

@Hineven Hineven changed the title setDebugView(const std::string_view &) fails to accept string views from non-persistent strings. setDebugView(const std::string_view &) malfunctions. Apr 19, 2024
@maoliver-amd
Copy link
Collaborator

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

Hineven added a commit to Hineven/Capsaicin that referenced this issue Jun 18, 2024
Hineven added a commit to Hineven/Capsaicin that referenced this issue Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants