NickvisionApps / Denaro

Manage your personal finances
https://flathub.org/apps/details/org.nickvision.money
MIT License
584 stars 38 forks source link

Handle segfaults on startup #806

Closed JoseBritto closed 6 months ago

JoseBritto commented 6 months ago

Things handled:

Let me know if there are other things I missed, but these were mostly the problems I faced and having no logs made it harder to debug.

nlogozzo commented 6 months ago

Segfault when locale not setup on system (im not entirely sure how to handle this, working on it atm)

You might have to take a look at libnick repository, as that is where all the localization happens. But it already handles if no local exists and defaults to en-us.

JoseBritto commented 6 months ago

Segfault when locale not setup on system (im not entirely sure how to handle this, working on it atm)

You might have to take a look at libnick repository, as that is where all the localization happens. But it already handles if no local exists and defaults to en-us.

Oh. For me if I unset the locale, Denaro crashes. Basically std::locale("") throws runtime error causing a crash. How would I handle this?

JoseBritto commented 6 months ago

In denaro there are two places that directly call std::locale. In the CurrencyHelpers::getSystemCurrency() method and the MainWindowController::getDebugInformation() method, I tried setting std::locale::global(std::locale("C")) but that doesn't seem to affect anything. I'm kinda lost here. Gtk by default falls back to this and produces an error:

(org.nickvision.money.gnome:27160): Gtk-WARNING **: 23:32:48.436: Locale not supported by C library.
    Using the fallback 'C' locale.

Is the correct way to have a small helper method/class that proxies all the calls to get the current locale and handle it there? Or is it better to handle the exception where ever we use std::locale directly?

JoseBritto commented 6 months ago

In denaro there are two places that directly call std::locale. In the CurrencyHelpers::getSystemCurrency() method and the MainWindowController::getDebugInformation() method, I tried setting std::locale::global(std::locale("C")) but that doesn't seem to affect anything. I'm kinda lost here. Gtk by default falls back to this and produces an error:

(org.nickvision.money.gnome:27160): Gtk-WARNING **: 23:32:48.436: Locale not supported by C library.
  Using the fallback 'C' locale.

Is the correct way to have a small helper method/class that proxies all the calls to get the current locale and handle it there? Or is it better to handle the exception where ever we use std::locale directly?

Handled both separately.

JoseBritto commented 6 months ago

Please let me know if I used the & and * or none at all for variables properly. I still get confused sometimes 😅 Everything worked when I tested.

JoseBritto commented 6 months ago

All done

JoseBritto commented 6 months ago

e777bf7 Added some more logs when opening and removing accounts. Let me know if I went a little overboard there.

nlogozzo commented 6 months ago

e777bf7 Added some more logs when opening and removing accounts. Let me know if I went a little overboard there.

All is fine. Just only removed the Account removed one that had the account name, because i'd like to keep as little personal information as possible from the logs (at most file paths).