wkjarosz / hdrview

A simple research-oriented image viewer with an emphasis on examining and comparing high-dynamic range (HDR) images, and including minimalistic editing and tonemapping capabilities.
Other
279 stars 11 forks source link

1.7.0 crash on windows #102

Closed MrLixm closed 1 year ago

MrLixm commented 1 year ago

Hello, had a quick look at the last update 1.7.0 on my windows machine. Unfortunately seems I cannot launch it, the terminal opens and then close briefly after. There's no error message whatsoever.

Context

Logs

I tried to launch the app with a debug level but don't got anything more.

Here is the log from Git Bash that specifies that there is a seg fault. Also tried from the regular cmd.exe and got the same issue of course.

$ F:\softwares\apps\hdrview\builds\1.7.0\HDRView.exe --verbosity 0
[info] Reading configuration from file C:\Users\lcoll\AppData\Roaming/HDRView/settings.json
[info] Welcome to HDRView!
[info] Verbosity threshold set to level 0.
[info] Setting intensity scale to 1.000000
[info] Using sRGB response curve.
[info] Dithering
[info] Launching GUI with 8 bit color and LDR display support.
[info] Reading configuration from file C:\Users\lcoll\AppData\Roaming/HDRView/settings.json
[trace] setting Hand tool active: false.
[trace] setting Rectangular Marquee active: false.
Segmentation fault

Tests

I also tried to delete the local preferences C:\Users\lcoll\AppData\Roaming/HDRView/settings.json but it didn't changed anything.


Sorry I cannot provide any more info. Hope you can still find what's going on. Liam.

wkjarosz commented 1 year ago

Thanks for reporting this. This might be tricky for me to debug since I don't have a windows machine.

Is this with the prebuilt binaries provided on github, or did you compile from source?

Could you try earlier binary releases to if the issue is specific to 1.7.0, or already appeared earlier?

Thanks

MrLixm commented 1 year ago

Hey, yes it's the pre-built from GitHub. This is a new bug as I have 1.6.1 working fine.

wkjarosz commented 1 year ago

Ah, I see you already specified that in your original comment - sorry for overlooking that.

Any chance you could build from source and run in a debugger to track down where the crash is coming from?

Thanks

MrLixm commented 1 year ago

I wish I knew but that is not in my skill range unfortunately 😕

wkjarosz commented 1 year ago

Ok, thanks for reporting anyway. Hopefully I can find someone to help me debug so windows users can get the UI improvements :-)

MrLixm commented 1 year ago

Alright, good luck finding that bug !

jparr721 commented 1 year ago

Hey @wkjarosz,

Platform

Distributor ID: Ubuntu Description: Ubuntu 22.04.1 LTS Release: 22.04 Codename: jammy

I am not using windows, but I am experiencing a similar issue with version 1.7.0 when building from source. I have tracked this down to the following line within hdrviewscreen.cpp. It appears that when the marked line is commented out, there is no issue and the viewer launches. When present, however, the system segfaults. When digging deeper into the debugger I see that when i == 0 in the set_active method, the tool object has no data in it when calling set_pushed, so m_pushed seems to just die.

void HDRViewScreen::set_tool(ETool t)
{
    auto set_active = [this](int i, bool b)
    {
        auto tool = m_tools[i];
        spdlog::trace("setting {} active: {}.", tool->name(), b);
        if (tool->toolbutton())
            tool->toolbutton()->set_pushed(b);
        else
            spdlog::error("Button for {} never created.", tool->name());

// ERROR STARTS HERE
        if (tool->menuitem())
            tool->menuitem()->set_pushed(b);
        else
            spdlog::error("Menu item for {} never created.", tool->name());
// ERROR ENDS HERE
        if (tool->options_bar())
        {
            tool->options_bar()->set_visible(b);
            request_layout_update();
        }
        else
            spdlog::error("Options widget for {} never created.", tool->name());
    };

    m_tool = t;
    for (int i = 0; i < (int)Tool_Num_Tools; ++i) set_active(i, false);

    set_active(t, true);
}

Logs

When the line is not commented I get similar errors as above.

[info] Reading configuration from file /home/jp2844/.config/HDRView/settings.json
[info] Welcome to HDRView!
[info] Verbosity threshold set to level 2.
[info] Setting intensity scale to 1.000000
[info] Using sRGB response curve.
[info] Dithering
[info] Launching GUI with 8 bit color and LDR display support.
GLFW error 65545: GLX: Failed to find a suitable GLXFBConfig
Could not allocate floating point framebuffer, retrying without..
[info] Reading configuration from file /home/jp2844/.config/HDRView/settings.json
[warning] Error while reading settings file: Cannot open settings file: "/home/jp2844/.config/HDRView/settings.json".
[info] Using default settings.
[1]    1384135 segmentation fault (core dumped)  ./HDRView

Let me know if I can provide more information.

jparr721 commented 1 year ago

Following up. 1.6.1 builds and runs no problem on ubuntu with no code modifications.

wkjarosz commented 1 year ago

@jparr721 thank you. This is really helpful. I hope to look more deeply into it soon.

pgrit commented 1 year ago

On Windows, the crash is because m_menuitem is uninitialized. And the undef. content happens to never be zero, which triggers this if here: https://github.com/wkjarosz/hdrview/blob/0f82210797959cd70332e7879455a7fe757eb0b1/src/tool.cpp#L90 resulting in the menu item never being properly created. I guess this works on mac because the undef. content of this field happened to be zero always.

Initializing m_menuitem(nullptr) in the constructor resolves the problem.

syoyo commented 1 year ago

@pgrit :pray: FYI, we can also repro the issue on Linux with ASAN build(-DUSE_SANITIZER=Address)

=================================================================
==13739==ERROR: AddressSanitizer: SEGV on unknown address (pc 0x556ecd7af77f bp 0x7ffd54497710 sp 0x7ffd544976f0 T0)
==13739==The signal is caused by a READ memory access.
==13739==Hint: this fault was caused by a dereference of a high value address (see register values below).  Disassemble the provided pc to learn which register was used.
    #0 0x556ecd7af77f in nanogui::Button::set_pushed(bool) /home/syoyo/work/hdrview/build/_deps/nanogui-src/include/nanogui/button.h:92:45
    #1 0x556ecde3085c in HDRViewScreen::set_tool(ETool)::$_63::operator()(int, bool) const /home/syoyo/work/hdrview/src/hdrviewscreen.cpp:992:31
    #2 0x556ecde2ac88 in HDRViewScreen::set_tool(ETool) /home/syoyo/work/hdrview/src/hdrviewscreen.cpp:1006:51
    #3 0x556ecde20f5e in HDRViewScreen::HDRViewScreen(float, float, bool, bool, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >) /home/syoyo/work/hdrview/src/hdrviewscreen.cpp:829:5
    #4 0x556ecdc9cdbf in main /home/syoyo/work/hdrview/src/hdrview.cpp:228:28
    #5 0x7f42b0283d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #6 0x7f42b0283e3f in __libc_start_main csu/../csu/libc-start.c:392:3
    #7 0x556ecd487e94 in _start (/home/syoyo/work/hdrview/build/HDRView+0x163e94) (BuildId: 494b39362a76543f52ec62306e7c372191678c4c)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/syoyo/work/hdrview/build/_deps/nanogui-src/include/nanogui/button.h:92:45 in nanogui::Button::set_pushed(bool)
==13739==ABORTING
MrLixm commented 1 year ago

Confirming the crash is fixed in 1.7.1 on my side. Thanks !