0

I created a single file executable of my GUI app with PyInstaller. Everything looks fine, the executable is created and starts. First, the login page is correctly shown, but after inserting username and password the program crashes. I tried to debug with gdb, and this is what I get:

Program received signal SIGSEGV, Segmentation fault.
raise (sig=<optimized out>) at ../sysdeps/unix/sysv/linux/raise.c:50
50  ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  raise (sig=<optimized out>) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x000055555555a213 in ?? ()
#2  0x000055555555815d in ?? ()
#3  0x00007ffff7da10b3 in __libc_start_main (main=0x5555555564d0, argc=1, 
    argv=0x7fffffffdec8, init=<optimized out>, fini=<optimized out>, 
    rtld_fini=<optimized out>, stack_end=0x7fffffffdeb8)
    at ../csu/libc-start.c:308
#4  0x000055555555650a in ?? ()

Can someone explain what does it mean and how to solve?

Login page code:

import json
import wx
from pubsub import pub


class LoginPage(wx.Dialog):
    def __init__(self):
        """Constructor"""
        wx.Dialog.__init__(self, None, title="Login", size=(750, 750), style=wx.DEFAULT_DIALOG_STYLE)
        self.password_shown = False

        # username
        username_sizer = wx.BoxSizer(wx.HORIZONTAL)

        username_lbl = wx.StaticText(self, label="Username:")
        username_sizer.Add(username_lbl, 1, wx.ALL | wx.CENTER, 5)
        self.username_txt = wx.TextCtrl(self)
        username_sizer.Add(self.username_txt, 3, wx.ALL | wx.EXPAND, 5)

        # pass info
        pass_sizer = wx.BoxSizer(wx.HORIZONTAL)

        p_lbl = wx.StaticText(self, label="Password:")
        pass_sizer.Add(p_lbl, 1, wx.ALL | wx.CENTER, 5)
        self.pass_txt = wx.TextCtrl(self, style=wx.TE_PASSWORD | wx.TE_PROCESS_ENTER)
        pass_sizer.Add(self.pass_txt, 3, wx.ALL | wx.EXPAND, 5)
        self.text_no_password = wx.TextCtrl(self)
        self.text_no_password.Hide()
        pass_sizer.Add(self.text_no_password, 3, wx.ALL, 5)
        self.show_pwd_cb = wx.CheckBox(self, -1, "Show password")
        pass_sizer.Add(self.show_pwd_cb, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
        self.show_pwd_cb.Bind(wx.EVT_CHECKBOX, self.onShow)

        main_sizer = wx.BoxSizer(wx.VERTICAL)
        main_sizer.Add(username_sizer, 0, wx.ALL, 5)
        main_sizer.Add(pass_sizer, 0, wx.ALL, 5)

        btn = wx.Button(self, label="Login")
        btn.Bind(wx.EVT_BUTTON, self.onLogin)
        main_sizer.Add(btn, 0, wx.ALL | wx.CENTER, 5)

        self.SetSizer(main_sizer)

    def onLogin(self, event):
        """
        Check credentials and login
        """
        user = str(self.username_txt.GetValue())
        pwd = str(self.pass_txt.GetValue()) if not self.password_shown else str(self.text_no_password.GetValue())

        with open("UIcomponents/login.js", "r") as f:
            credentials = json.load(f)
        if user != credentials["User"] or pwd != credentials["Pwd"]:
            wx.LogError("Username or password are not correct. Please, try again")
            return
        with open("UIcomponents/login.js", "w") as f:
            json.dump(credentials, f)

        pub.sendMessage("loginListener", message="logged in")
        self.Destroy()

    def onShow(self, event):
        self.pass_txt.Show(self.password_shown)
        self.text_no_password.Show(not self.password_shown)
        if not self.password_shown:
            self.text_no_password.SetValue(self.pass_txt.GetValue())
            self.text_no_password.SetFocus()
        else:
            self.pass_txt.SetValue(self.text_no_password.GetValue())
            self.pass_txt.SetFocus()
        self.pass_txt.GetParent().Layout()
        self.password_shown = not self.password_shown

EDIT

After following instructions at this link GDB complaining about missing raise.c (as suggested by @AliIrani), the message I get changed:

Program received signal SIGSEGV, Segmentation fault.
raise (sig=<optimized out>) at ../sysdeps/unix/sysv/linux/raise.c:50
50    return ret;
Deffo
  • 191
  • 1
  • 8
  • 21

2 Answers2

0

Can someone explain what does it mean and how to solve?

It means that the python executable has encountered some kind of fatal error and has called abort(). Usually this happens on assertion violation, and is accompanied with an error message on stderr.

Unfortunately your installer application is fully stripped (which prevents GDB from telling you where the crash is happening), or is packed with UPX.

According to this PyInstaller doc, you will want to use --noupx flag (and remove -s or --strip if you are using them).

If the application still crashes, it should be easier to tell where that crash happens.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
0

Looks like the problem was caused by the library darkdetect. The error occured only at runtime, because after

    pub.sendMessage("loginListener", message="logged in")
    self.Destroy()

a new window is created, and the background colour depends on the system theme chosen by the user (and maybe my code is not authorized to access such information).

Deffo
  • 191
  • 1
  • 8
  • 21