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

Crashes to desktop (no errors) #854

Open
Makhaira opened this issue Jan 5, 2021 · 11 comments
Open

Crashes to desktop (no errors) #854

Makhaira opened this issue Jan 5, 2021 · 11 comments
Labels
awaiting response Further information is requested bug Something isn't working as intended

Comments

@Makhaira
Copy link

Makhaira commented Jan 5, 2021

Version

2.2.54

Operating system type + version

Win10

Behavior

SS will frequently crash immediately on launch - the program appears, freezes for a few seconds, and then exists to desktop with no message.
I am also getting some crashes when switching between printer profiles. This is regardless of whether STLs are already loaded or not.

Is there some sort of crash log I could post to help?

@Kveri
Copy link

Kveri commented Jan 6, 2021

I can confirm, past few weeks I also get random crashes, usually once a day, nothing serious if you use ctrl+s a lot, but still. No error, just straight quit.

@supermerill
Copy link
Owner

supermerill commented Jan 10, 2021

No crash log.
If you can reproduce the crash, tell me how.

@supermerill supermerill added the bug Something isn't working as intended label Jan 10, 2021
@Makhaira
Copy link
Author

Makhaira commented Jan 10, 2021 via email

@Kveri
Copy link

Kveri commented Jan 12, 2021

No crash log.
If you can reproduce the crash, tell me how.

is it possible to somehow enable crashlog or crashdump? I get totally random crashes but only once every two days. I didn't spot any correlation to what I do, which STLs I use, etc.

@supermerill
Copy link
Owner

I fixed many bugs that can crash the slicer, so hopefully the current stable shoudln't crash anymore.

is it possible to somehow enable crashlog or crashdump?

only if built with debug flags. I can give you one.

@supermerill supermerill added the awaiting response Further information is requested label Feb 3, 2022
@LunaRood
Copy link

LunaRood commented Feb 6, 2022

I'm having the same issue (or at least the same symptom), on Linux. The latest official release build crashes immediately upon launch, but not consistently (perhaps about 50% of the time, or a bit more).

I'm not sure if it's the same issue and/or if it's platform specific, but since it's the same symptom, I figured it'd make sense to reply here.

Since the official build seems to conveniently include debug symbols, I was able to generate the backtrace below. I haven't had time to get the master branch building to look into it myself, but I hope this helps with finding the issue.

Backtrace
#0  0x000055555610aa21 in Slic3r::GUI::GLTexture::load_from_svg_files_as_sprites_array(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::vector<std::pair<int, bool>, std::allocator<std::pair<int, bool> > > const&, unsigned int, bool, unsigned int) ()
#1  0x00005555560c8049 in Slic3r::GUI::GLGizmosManager::generate_icons_texture() const ()
#2  0x00005555560c82ed in Slic3r::GUI::GLGizmosManager::render_overlay() const ()
#3  0x00005555560a0a50 in Slic3r::GUI::GLCanvas3D::_render_overlays() const ()
#4  0x00005555560a1eb5 in Slic3r::GUI::GLCanvas3D::render() ()
#5  0x00005555560a3934 in Slic3r::GUI::GLCanvas3D::_refresh_if_shown_on_screen() ()
#6  0x00005555560a3a90 in Slic3r::GUI::GLCanvas3D::on_set_focus(wxFocusEvent&) ()
#7  0x0000555556d07159 in wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const (this=0x555557b62630, handler=0x5555586eba50, functor=warning: RTTI symbol not found for class 'wxEventFunctorMethod<wxEventTypeTag<wxFocusEvent>, Slic3r::GUI::GLCanvas3D, wxFocusEvent, Slic3r::GUI::GLCanvas3D>'
..., event=...)
    at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/common/appbase.cpp:671
#8  0x0000555556da7550 in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) (entry=..., handler=0x5555586eba50, event=...)
    at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/common/event.cpp:1415
#9  0x0000555556da8219 in wxEvtHandler::SearchDynamicEventTable(wxEvent&) (this=0x5555586eba50, event=...) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/common/event.cpp:1887
#10 0x0000555556da7996 in wxEvtHandler::TryHereOnly(wxEvent&) (this=0x5555586eba50, event=...) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/common/event.cpp:1608
#11 0x0000555556da8db7 in wxEvtHandler::TryBeforeAndHere(wxEvent&) (this=0x5555586eba50, event=...) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/include/wx/event.h:3912
#12 0x0000555556da77e5 in wxEvtHandler::ProcessEventLocally(wxEvent&) (this=0x5555586eba50, event=...) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/common/event.cpp:1545
#13 0x0000555556da777c in wxEvtHandler::ProcessEvent(wxEvent&) (this=0x5555586eba50, event=...) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/common/event.cpp:1518
#14 0x0000555556da7a91 in wxEvtHandler::SafelyProcessEvent(wxEvent&) (this=0x5555586eba50, event=...) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/common/event.cpp:1636
#15 0x0000555556badb52 in wxWindowBase::HandleWindowEvent(wxEvent&) const (this=0x5555586eba50, event=...) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/common/wincmn.cpp:1555
#16 0x0000555556c3f79b in wxWindow::GTKProcessEvent(wxEvent&) const (this=0x5555586eba50, event=...) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/gtk/window.cpp:1536
#17 0x0000555556c47ea3 in wxWindow::GTKHandleFocusIn() (this=0x5555586eba50) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/gtk/window.cpp:4444
#18 0x0000555556c40efb in gtk_window_focus_in_callback(GtkWidget*, GdkEventFocus*, wxWindow*) (win=0x5555586eba50) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/gtk/window.cpp:2048
#19 0x00007ffff7418f38 in  () at /usr/lib/libgtk-3.so.0
#20 0x00007ffff6eb6d8f in g_closure_invoke () at /usr/lib/libgobject-2.0.so.0
#21 0x00007ffff6ed2718 in  () at /usr/lib/libgobject-2.0.so.0
#22 0x00007ffff6ed340b in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0
#23 0x00007ffff6ed4330 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#24 0x00007ffff76cfc45 in  () at /usr/lib/libgtk-3.so.0
#25 0x00007ffff76cba47 in gtk_widget_send_focus_change () at /usr/lib/libgtk-3.so.0
#26 0x00007ffff76de8d7 in  () at /usr/lib/libgtk-3.so.0
#27 0x00007ffff76def2a in  () at /usr/lib/libgtk-3.so.0
#28 0x00007ffff6eb57eb in g_cclosure_marshal_VOID__OBJECTv () at /usr/lib/libgobject-2.0.so.0
#29 0x00007ffff6ed41c0 in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0
#30 0x00007ffff6ed4330 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#31 0x00007ffff6ed41c0 in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0
#32 0x00007ffff6ed4330 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#33 0x00007ffff76bd3ac in gtk_widget_grab_focus () at /usr/lib/libgtk-3.so.0
#34 0x0000555556c4827c in wxWindow::SetFocus() (this=0x5555586eba50) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/gtk/window.cpp:4580
#35 0x0000555555dbf9ac in Slic3r::GUI::Plater::on_activate() ()
#36 0x0000555555d9f02e in wxEventFunctorFunctor<wxEventTypeTag<wxActivateEvent>, Slic3r::GUI::MainFrame::MainFrame()::{lambda(wxActivateEvent&)#2}>::operator()(wxEvtHandler*, wxEvent&) ()
#37 0x0000555556d07159 in wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const (this=0x555557b62630, handler=0x55555865c8c0, functor=warning: RTTI symbol not found for class 'wxEventFunctorFunctor<wxEventTypeTag<wxActivateEvent>, Slic3r::GUI::MainFrame::MainFrame()::{lambda(wxActivateEvent&)#2}>'
..., event=...)
    at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/common/appbase.cpp:671
#38 0x0000555556da7550 in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) (entry=..., handler=0x55555865c8c0, event=...)
    at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/common/event.cpp:1415
#39 0x0000555556da8219 in wxEvtHandler::SearchDynamicEventTable(wxEvent&) (this=0x55555865c8c0, event=...) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/common/event.cpp:1887
#40 0x0000555556da7996 in wxEvtHandler::TryHereOnly(wxEvent&) (this=0x55555865c8c0, event=...) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/common/event.cpp:1608
#41 0x0000555556da8db7 in wxEvtHandler::TryBeforeAndHere(wxEvent&) (this=0x55555865c8c0, event=...) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/include/wx/event.h:3912
#42 0x0000555556da77e5 in wxEvtHandler::ProcessEventLocally(wxEvent&) (this=0x55555865c8c0, event=...) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/common/event.cpp:1545
#43 0x0000555556da777c in wxEvtHandler::ProcessEvent(wxEvent&) (this=0x55555865c8c0, event=...) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/common/event.cpp:1518
#44 0x0000555556da7a91 in wxEvtHandler::SafelyProcessEvent(wxEvent&) (this=0x55555865c8c0, event=...) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/common/event.cpp:1636
#45 0x0000555556badb52 in wxWindowBase::HandleWindowEvent(wxEvent&) const (this=0x55555865c8c0, event=...) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/common/wincmn.cpp:1555
#46 0x0000555556c361a7 in gtk_frame_focus_in_callback(GtkWidget*, GdkEvent*, wxTopLevelWindowGTK*) (widget=0x55555808e7d0, win=0x55555865c8c0)
    at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/gtk/toplevel.cpp:168
#47 0x00007ffff7418f38 in  () at /usr/lib/libgtk-3.so.0
#48 0x00007ffff6eb6d8f in g_closure_invoke () at /usr/lib/libgobject-2.0.so.0
#49 0x00007ffff6ed290b in  () at /usr/lib/libgobject-2.0.so.0
#50 0x00007ffff6ed340b in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0
#51 0x00007ffff6ed4330 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#52 0x00007ffff76cfc45 in  () at /usr/lib/libgtk-3.so.0
#53 0x00007ffff757144a in gtk_main_do_event () at /usr/lib/libgtk-3.so.0
#54 0x00007ffff72d8643 in  () at /usr/lib/libgdk-3.so.0
#55 0x00007ffff7324ca4 in  () at /usr/lib/libgdk-3.so.0
#56 0x00007ffff6dc252c in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#57 0x00007ffff6e167b9 in  () at /usr/lib/libglib-2.0.so.0
#58 0x00007ffff6dc1ab3 in g_main_loop_run () at /usr/lib/libglib-2.0.so.0
#59 0x00007ffff756793f in gtk_main () at /usr/lib/libgtk-3.so.0
#60 0x0000555556c2ab35 in wxGUIEventLoop::DoRun() (this=0x5555593132e0) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/gtk/evtloop.cpp:64
#61 0x0000555556d2fcaf in wxEventLoopBase::Run() (this=0x5555593132e0) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/common/evtloopcmn.cpp:90
#62 0x0000555556d0671c in wxAppConsoleBase::MainLoop() (this=0x555557b62630) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/common/appbase.cpp:380
#63 0x0000555556d064b3 in wxAppConsoleBase::OnRun() (this=0x555557b62630) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/common/appbase.cpp:301
#64 0x0000555556ae53e7 in wxAppBase::OnRun() (this=0x555557b62630) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/common/appcmn.cpp:335
#65 0x0000555556d588cf in wxEntry(int&, wchar_t**) (argc=@0x55555799b8b0: 1, argv=0x555557b6fc80) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/common/init.cpp:507
#66 0x0000555556d589a5 in wxEntry(int&, char**) (argc=@0x7fffffff6600: 1, argv=0x7fffffffe228) at /home/runner/work/SuperSlicer/SuperSlicer/deps/build/dep_wxWidgets-prefix/src/dep_wxWidgets/src/common/init.cpp:519
#67 0x0000555555d7c342 in Slic3r::GUI::GUI_Run(Slic3r::GUI::GUI_InitParams&) ()
#68 0x0000555555751953 in Slic3r::CLI::run(int, char**) ()
#69 0x000055555572bb7a in main ()

@LunaRood
Copy link

Had some time to make a build and look a bit further into the issue, so I have a bit of additional info.

My crash is ultimately an out of bounds access at:

float alpha = (float)output_data.data()[offset + 3] * inv_255;

However, the actual cause happens much earlier. The issue is that the icon scale is set to a negative value, which ends up causing an underflow (and later a subsequent overflow) of the unsigned sprite size (in the function referenced above).

I've traced the negative value back to auto_toolbar_size, which seems to be set to -20 somewhere, though I haven't yet investigated further, to find where that value comes from (in my config it's set to 100).

This value gets factored into the icon scale at:

const std::string& auto_val = app_config->get("auto_toolbar_size");


As a side note, from my investigation, I'm a bit suspicious of the retina display handling. The code decides whether to set the icon scale (to a value other than the default of 1.0), based on the ENABLE_RETINA_GL define. This is set both for apple and for GTK3 (note the comment):

// Support for Retina OpenGL on Mac OS.
// wxGTK3 seems to simulate OSX behavior in regard to HiDPI scaling support, enable it as well.
#define ENABLE_RETINA_GL (__APPLE__ || __WXGTK3__)

#if ENABLE_RETINA_GL
// m_gizmos.set_overlay_scale(m_retina_helper->get_scale_factor());
const float scale = m_retina_helper->get_scale_factor()*wxGetApp().toolbar_icon_scale();
m_gizmos.set_overlay_scale(scale); //! #ys_FIXME_experiment
#else
// m_gizmos.set_overlay_scale(m_canvas->GetContentScaleFactor());
// m_gizmos.set_overlay_scale(wxGetApp().em_unit()*0.1f);
const float size = int(GLGizmosManager::Default_Icons_Size*wxGetApp().toolbar_icon_scale());
m_gizmos.set_overlay_icon_size(size); //! #ys_FIXME_experiment
#endif /* __WXMSW__ */

Meanwhile, in several places where retina related values are calculated, the __APPLE__ define is used instead. For instance in the function that calculates the scaling:

float GUI_App::toolbar_icon_scale(const bool is_limited/* = false*/) const
{
#ifdef __APPLE__
const float icon_sc = 1.0f; // for Retina display will be used its own scale
#else
const float icon_sc = m_em_unit*0.1f;
#endif // __APPLE__

This might be intentional, if it's dealing with some discrepancies between OSX and wxGTK, but it might also be a mistake in that part of the code, assuming that only Apple has HiDPI. I was suspicious of this, particularly because of the comment claiming that wxGTK3 simulates OSX HiDPI handling.

In any case, whether or not my suspicions turn out to be warranted, this is not the cause of the crash (that'd be the negative auto_toolbar_size). However, I just thought I'd mention, as I suspect there might be some other bugs hiding in the HiDPI implementation. In any case, this is probably not even SuperSlicer-specific, as this code seems to come from upstream.

@supermerill
Copy link
Owner

supermerill commented Feb 10, 2022

Thank you very much for your debugging investigation.

For the fix, I propose to change for (adding the last if)

    const std::string& use_val  = app_config->get("use_custom_toolbar_size");
    const std::string& val      = app_config->get("custom_toolbar_size");
    const std::string& auto_val = app_config->get("auto_toolbar_size");

    if (val.empty() || auto_val.empty() || use_val.empty())
        return icon_sc;

    int int_val = use_val == "0" ? 100 : atoi(val.c_str());
    // correct value in respect to auto_toolbar_size
    int_val = std::min(atoi(auto_val.c_str()), int_val);

    if (is_limited && int_val < 50)
        int_val = 50;
    else if (int_val < 1) {
        int_val = std::max(1, std::min(100, int_val)); //buggy code? issue supermerill/superslicer#854
        assert(false);
    }

auto_toolbar_size doesn't seem to be set by anything and isn't used anywhere else... Maybe prusa needs it for something (it was added in may 2020) but forgot about it?

For the ENABLE_RETINA_GL vs __APPLE__ These kinds of GUI things are extremely time-consuming. I let prusa investigate & fix them. If you can test gtk3 with & without and find the diff, you may be able to fix it for them.

@LunaRood
Copy link

While I agree that your proposed code mitigates the issue, I wonder if this is a wise decision, as it just hides the actual issue that is further up. I feel like other unexpected issues could easily crop up from this. For instance, if this setting happens to be used anywhere else, the values won't match. And besides, if this setting is somehow being changed somewhere, it is also plausible to imagine that the bug might affect other settings as well.

Of course, it's not up to me, and I'm very new to this codebase, but I'd advise against this sort of band-aid. Though I do admit that it's good to have a safeguard (such as what you wrote), in case users set the setting itself to an implausible value. But in this case, it'd be good to also find where the actual issue is coming from.

As for the retina handling, yeah, I figured it's mostly a job for upstream, as it is indeed a lot of very dense code, but I figured I'd bring it up just in case. But it's not really important.

@supermerill
Copy link
Owner

That's why I added the assert, so it can trigger if it's on debug mode.
Let's be real, I can't replicate the issue., and I won't spend days hunting it. So until someone (or prusa) comes with a better solution... it's better than nothing.
Does it work on your computer if you compile with the fix?

supermerill pushed a commit that referenced this issue Feb 12, 2022
LunaRood added a commit to LunaRood/SuperSlicer that referenced this issue Feb 13, 2022
Icons can get scaled even if the window is not yet fully initialised, in
which case they ended up with a negative scale.

Potentially related to supermerill#854
@LunaRood
Copy link

Had some time to debug further, and come up with a proper fix (though, to answer your question, yes, your change did stop the crash from happening). I've submitted the fix at #2368, which addresses the source of the negative value.

This problem seems to be caused by the canvas not being fully initialised when icon scaling starts being applied. Though I tested on another system and didn't hit the crash, so it seems to be dependent on which WM is used.

With any luck this is the same crash as in the original report, though at this point it's looking unlikely. If this crash affected Windows, I'd expect it to crash for everyone on Windows (as it's actually config independent), and since that's not the case, it's probably another issue.

supermerill pushed a commit that referenced this issue Feb 13, 2022
Icons can get scaled even if the window is not yet fully initialised, in
which case they ended up with a negative scale.

Potentially related to #854

Revert "Add a linux startup crash fix."
This reverts commit 34ff5c0.
DzzD pushed a commit to DzzD/SuperSlicer that referenced this issue Apr 17, 2022
DzzD pushed a commit to DzzD/SuperSlicer that referenced this issue Apr 17, 2022
Icons can get scaled even if the window is not yet fully initialised, in
which case they ended up with a negative scale.

Potentially related to supermerill#854

Revert "Add a linux startup crash fix."
This reverts commit 34ff5c0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response Further information is requested bug Something isn't working as intended
Projects
None yet
Development

No branches or pull requests

4 participants