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

[Caused by buggy software Nahimic] Memory access violation when resizing viewports (opengl3, docking) #4542

Closed
jeremykleve opened this issue Sep 14, 2021 · 12 comments

Comments

@jeremykleve
Copy link

jeremykleve commented Sep 14, 2021

video.mp4

Version: v1.85 WIP
Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_opengl3.cpp + imgui_impl_glfw.cpp
GPU: RTX 2080 Ti
GPU driver version: 30.0.14.7196

Operating System: Windows 10 Pro version: 21H1 build: 19043.1202

My Issue/Question:

Resizing a viewport from its corner handle causes a memory access violation during its call to glfwSwapBuffers()
More specifically the error occurs when moving diagonally up and to the right if dragging from the bottom right corner (see video)
I discovered this in my own application when trying to implement my own window resize functionality (ive removed the the windows decoration) and I further tested this with the opengl3 example and can confirm it occurs there for me as well.

The issue does not surface when using the win32 version of directx11, I did not test other backends.

image

@dougbinks
Copy link
Contributor

I'm commenting on this as the question first appeared on the GLFW forum which I help manage: https://discourse.glfw.org/t/glfwsetwindowsize-causes-read-violation/1915/5

I've been unsuccessful in replicating the issue, and from the debug call stack and error this doesn't appear to be a Dear ImGui issue.

@jeremykleve - can you use the Visual Studio debugger to check the values of vd and vd->Window are sensible, and not the location 0x0EC33000 which is being dereferenced.

I would also turn on symbol loading: this is under Debug->Options->Symbols then ensure "Symbol file (.pdb) locations:" Microsoft Symbol Servers is on, and at the bottom Load all modules is on. This should help find the location of the error (callstack symbol resolution).

It might also be worth doing a system virus check and ensuring there is nothing on the system which hooks into OpenGL/Graphics processes (not running FRAPs, OBS Studio, streaming, some kind of overlay etc.).

@ocornut
Copy link
Owner

ocornut commented Sep 15, 2021

There are other reports of same issue (it would be good to consolidate reports there instead of opening new ones).
#3321 #3204 #4534
glfw/glfw#1682

  • Callstack with symbols would be good.
  • If you have Nahimic or weird audio software installed, they are buggy.
  • Please specify GPU and driver version and try to update drivers.

@jeremykleve
Copy link
Author

jeremykleve commented Sep 15, 2021

@jeremykleve - can you use the Visual Studio debugger to check the values of vd and vd->Window are sensible, and not the location 0x0EC33000 which is being dereferenced.

image

I would also turn on symbol loading: this is under Debug->Options->Symbols then ensure "Symbol file (.pdb) locations:" Microsoft Symbol Servers is on, and at the bottom Load all modules is on. This should help find the location of the error (callstack symbol resolution).

Ive done this though im not sure if it added anything to the debug output. I still cant access any info at the thrown address but I can confirm that the vd and vd->Window addresses are not the ones that are being pointed at by the exception.

It might also be worth doing a system virus check and ensuring there is nothing on the system which hooks into OpenGL/Graphics processes (not running FRAPs, OBS Studio, streaming, some kind of overlay etc.).

I dont think I have anything that would conflict. Although we did see some issues with our app installer not working properly on machines that updated to the newest optional windows update. If you are unable to reproduce, updating windows might change that?

@jeremykleve
Copy link
Author

jeremykleve commented Sep 15, 2021

There are other reports of same issue (it would be good to consolidate reports there instead of opening new ones).
#3321 #3204 #4534
glfw/glfw#1682

  • Callstack with symbols would be good.
  • If you have Nahimic or weird audio software installed, they are buggy.
  • Please specify GPU and driver version and try to update drivers.

I updated the og post with my GPU and driver details.

When I got the error originally with my project the error thrown showed "frame out of module" saying that the read violation was coming from the nvoglv64.dll thread, which I havnt been able to find symbols for as it is closed source from Nvidia.

I also dont mind consolidating everything into a singe issue to track. Would you have a preference?

@dougbinks
Copy link
Contributor

See https://developer.nvidia.com/nvidia-driver-symbol-server for how to use the NVIDIA Driver Symbol Server

@jeremykleve
Copy link
Author

jeremykleve commented Sep 15, 2021

See https://developer.nvidia.com/nvidia-driver-symbol-server for how to use the NVIDIA Driver Symbol Server

I tried pointing my debugger to this but either its not showing me anything or I dont know how to use it properly yet

@mmozeiko
Copy link
Contributor

Nivdia driver symbol server won't help. It does NOT provide symbols - it provides ONLY binaries. Which is helpful analyzing dumps from machines with different driver version than yours, but that's about it.

The best you can do is right click External Code in call stack and choose "Show External Code" to at least show addresses.

@jeremykleve Can you check what modules you have loaded in process? Debug -> Windows -> Modules That may give help see if there's some 3rd party service has injected some random dll's.

@jeremykleve
Copy link
Author

Nivdia driver symbol server won't help. It does NOT provide symbols - it provides ONLY binaries. Which is helpful analyzing dumps from machines with different driver version than yours, but that's about it.

The best you can do is right click External Code in call stack and choose "Show External Code" to at least show addresses.

@jeremykleve Can you check what modules you have loaded in process? Debug -> Windows -> Modules That may give help see if there's some 3rd party service has injected some random dll's.

Thank you for that advice. When I opened up the modules window I saw some NahimicOSD.dll thing and apparently it gets installed automatically by dell-alienware preinstalled apps like Alienware Command Center. Anyway, uninstalled these and it seems to have fixed the issue. I am now wondering why some extraneous 3rd party application could mess with my application

@PathogenDavid
Copy link
Contributor

I am now wondering why some extraneous 3rd party application could mess with my application

In the case of Nahimic, it's probably to power their "Sound Tracker" feature. It's meant to add an overlay that shows where sounds are coming from. Unfortunately things which inject code into other apps are notoriously buggy, Chrome started blocking them in 2018 due to how many bogus crash reports they caused.

@ocornut
Copy link
Owner

ocornut commented Jul 1, 2022

@jeremykleve Does it still happens with the imgui_impl_opengl3.cpp backend from 1.88 ? I think it was fixed, would be good to confirm. Disregard message, mixed things up.

@ocornut
Copy link
Owner

ocornut commented Sep 14, 2022

Closing this, should have closed earlier but somehow got mixed up with other issues (this is a Nahimic issue)

@ocornut ocornut closed this as completed Sep 14, 2022
@ocornut ocornut changed the title Memory access violation when resizing viewports (opengl3, docking) [caused by Nahimic] Memory access violation when resizing viewports (opengl3, docking) Sep 14, 2022
@ocornut ocornut changed the title [caused by Nahimic] Memory access violation when resizing viewports (opengl3, docking) [Caused by buggy software Nahimic] Memory access violation when resizing viewports (opengl3, docking) Sep 14, 2022
@vertexi
Copy link

vertexi commented Nov 30, 2023

I found the hisptoot 's solution (bambulab/BambuStudio#1132 (comment)). I tested it on my Dell laptop, and it works, crash no more.

For those who want to block NahimicOSD.dll injection, copy the code below and call BlockNahimicOSDInject(). detours library is required. I use vcpkg to install this library as https://github.com/Microsoft/Detours/blob/master/samples/README.TXT says.

#ifdef _WIN32
#include <Windows.h>
#include <string>
#include "detours/detours.h"

typedef struct _UNICODE_STRING {
    USHORT Length;
    USHORT MaximumLength;
    PWSTR  Buffer;
} UNICODE_STRING, * PUNICODE_STRING;

typedef void(WINAPI* LdrLoadDllFunc) (
    IN PWCHAR               PathToFile OPTIONAL,
    IN PULONG                Flags OPTIONAL,
    IN PUNICODE_STRING      ModuleFileName,
    OUT HMODULE* ModuleHandle);

static LdrLoadDllFunc RealLdrLoadDll = NULL;
static void WINAPI LdrLoadDllHook(
    IN PWCHAR               PathToFile OPTIONAL,
    IN PULONG               Flags OPTIONAL,
    IN PUNICODE_STRING      ModuleFileName,
    OUT HMODULE* ModuleHandle)
{
    if (ModuleFileName->Buffer != NULL)
    {
        std::wstring fileName(ModuleFileName->Buffer, ModuleFileName->Length / sizeof(WCHAR));
        if (std::wstring::npos != fileName.find(L"NahimicOSD"))
        {
            return;
        }
    }

    if (RealLdrLoadDll != NULL)
    {
        RealLdrLoadDll(PathToFile, Flags, ModuleFileName, ModuleHandle);
    }
}

static void BlockNahimicOSDInject(void)
{
    LdrLoadDllFunc baseLdrLoadDll = (LdrLoadDllFunc)GetProcAddress(LoadLibraryA("ntdll.dll"), "LdrLoadDll");
    if (baseLdrLoadDll == NULL)
    {
        return;
    }

    DetourTransactionBegin();

    RealLdrLoadDll = baseLdrLoadDll;
    DetourAttach(&(PVOID&)RealLdrLoadDll, LdrLoadDllHook);

    DetourTransactionCommit();
}

// Call BlockNahimicOSDInject() to block NahimicOSD.dll injection
#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants