Log in to reply

Stack trace for C++ exceptions?


    My Manual Transmission mod suffers from crashes for people with specific hardware and software (ScriptHookVDotNet and a Logitech G920) and I wanna know what's going wrong. Hasn't been very fruitful though, and I'm basically out of options and my search for finding what causes it just makes me more depressed.


    • A nice stack trace for non-C++ exceptions, like dereferencing a null pointer or going out of an arrays bounds
    std::_Debug_message (17)
    std::array<bool,8>::operator[] (152)
    WheelDirectInput::IsButtonJustPressed (206)
    configHPattern (1321)
    update_wheelmenu (540)
    • Nothing for C++-style exceptions.
    [03:43:14.669] Crash: Your program has crashed.
    [03:43:14.670] CRASH: Init shutdown 

    Or at least, it was when I did a std::throw std::runtime_error("bla").

    Now I want to be able to catch that too or at least know where it's thrown from, but by the gods I can't find a library or something that can do this. There's something mentioned about _set_se_translator(...) but I'm failing to find an implementation for this.

    It's not like I'm throwing the real exception or error myself either, it's probably DirectInput. Basically I just want to know what causes my script to cock up and I really really don't want to be bothered with anything else, like clean exits. GTAV.exe can crash and burn.

    Is there a way to just have print where the entire thing explodes and nuke everything and exit after that?

    Also it's got to not depend on the running system to have specific libs that I can't just redistribute in a zip but that's a second step.

    The original StackOverflow answer where I got Dump.h from mentions something:

    // if you use C++ exception handling: install a translator function
    // with set_se_translator(). In the context of that function (but *not*
    // afterwards), you can either do your stack dump, or save the CONTEXT
    // record as a local copy. Note that you must do the stack dump at the
    // earliest opportunity, to avoid the interesting stack-frames being gone
    // by the time you do the dump.

    I have no idea how to use this information, but it sounds like it could magically work if set_se_translator() is used.

  • From the stack trace and your source code, a cause of the error seems to be the array(s) povButtonCurr and/or povButtonPrev.

     const int POVDIRECTIONS = 8;
     std::unordered_map<GUID, std::array<bool, POVDIRECTIONS>> povButtonCurr{};
     std::unordered_map<GUID, std::array<bool, POVDIRECTIONS>> povButtonPrev{};
     > std::array<bool,8>::operator[] (152)

    bool WheelDirectInput::IsButtonJustPressed(int buttonType, GUID device) {
      if (buttonType > MAX_RGBBUTTONS) { // POV
        int povIndex = povDirectionToIndex(buttonType);
        if (povIndex == -1) return false;
        povButtonCurr[device][povIndex] = IsButtonPressed(buttonType,device);
        // raising edge
        if (povButtonCurr[device][povIndex] && !povButtonPrev[device][povIndex]) {
          return true;
        return false;
      rgbButtonCurr[device][buttonType] = IsButtonPressed(buttonType,device);
      // raising edge
      if (rgbButtonCurr[device][buttonType] && !rgbButtonPrev[device][buttonType]) {
        return true;
      return false;


    Yeah, the exceptions are thrown by Windows (SEH?) in this case which has enough info to do a stack trace that you see there. That's not the problem.

    Luckily the other exception wasn't a C++ exception either, but I don't know what is precisely is as the stack dump just don't be.

    A bunch of prints did show it was caused by a second call to GetCapabilities (only when on a G920 and ScriptHookVDotNet is active though...) and CreateEffect (Any call, also G920 + SHVDN). Still don't know how to fix it as these get valid pointers and data, and should give return values instead of crash and burn. Other devs seem to have worked out that this is caused by crappy Logitech drivers though, so there's not much I can do. Don't have a G920 so I can't validate the "fix" though.

    I guess the original question doesn't really apply for the problem itself anymore, and from whatever straight answers I could get from StackOverflow, this is simply impossible. Back to spamming the log it is, then.

Log in to reply

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.