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

Segmentation faults #18

Open
ghost opened this issue Oct 18, 2016 · 6 comments
Open

Segmentation faults #18

ghost opened this issue Oct 18, 2016 · 6 comments

Comments

@ghost
Copy link

ghost commented Oct 18, 2016

I have problems about running tests and examples. Some of them ends with a segmentation fault. I think there are some problems about getters of components like window and checkbox. And I think it's about boolean difference between Python and C.

I'm using Ubuntu 16.04
Am I the only person that have problems about tests or anyone can confirm that there is a problem?

@joaoventura
Copy link
Owner

I haven't test it lately, but I've never had any problem running on OSX Mavericks (10.9.5). But I've checked on the libui project, and I think there's some problems on Linux, for instance (andlabs/libui#214) and (andlabs/libui#207).

@superzazu
Copy link
Contributor

superzazu commented Oct 19, 2016

Yes, I encountered a couple of segfaults on quitting (on macOS 10.11/10.12). That happens to me on two occasions:

  1. When a widget has been instanced, but is not "appended" to any box/window. Little example that seg faults for me :
from pylibui.core import App
from pylibui.controls import Button, Window


class MyWindow(Window):

    def onClose(self, data):
        super().onClose(data)
        app.stop()


app = App()

window = MyWindow('mywindow')
button = Button('mybutton')
# window.setChild(button)
window.show()

app.start()
app.close()

If I uncomment the line window.setChild(button), no crashes.

  1. On SearchEntry + PasswordEntry (eg tests/entry.py). Example:
from pylibui.core import App
from pylibui.controls import Window, Entry, SearchEntry, PasswordEntry


class MyWindow(Window):

    def onClose(self, data):
        super().onClose(data)
        app.stop()


app = App()

window = MyWindow('mywindow')
entry = PasswordEntry()
window.setChild(entry)
window.show()

app.start()
app.close()

If I replace entry = PasswordEntry() by entry = Entry(), no crashes.

We may have done something wrong while implementing something... I'll do some tests later.

EDIT: here's the error I got everytime:

2016-10-19 18:29:06.529 Python[29532:4616674] [libui] /Users/nikkos/Documents/libui/darwin/map.m:25:mapDestroy() POSSIBLE IMPLEMENTATION BUG; CONTACT ANDLABS:
attempt to destroy map with items inside
zsh: illegal hardware instruction  python3 test.py

@andlabs
Copy link

andlabs commented Oct 19, 2016

Set a breakpoint on libui's _implbug() and get a stack trace when that message pops ups so we can figure out which internal-to-libui data structure is causing it.

@joaoventura
Copy link
Owner

joaoventura commented Oct 20, 2016

Can someone help with this issue? For those who do not know, @andlabs is the author of the C libui, so he can check things on the C lib if needed..

@superzazu
Copy link
Contributor

Okay, got it.

I focused on the first code example (the one with the button with no parent); as I wasn't really sure about my implementation of Entries.
I rewrote the same code in C, so that I could know which code base introduced the bug. The bug did not appear in C.
That's where I realised that C examples in libui repo did not call uiUninit() (well, except for the "histogram" one, but that's not the latest updated).
When I removed app.close() from my Python code, everything worked without crashing. That also resolved the crash I was having with the Entries.

(sorry, failed to use gdb on mac with python3...)

@andlabs
Copy link

andlabs commented Oct 21, 2016

Okay, then it is what I was thinking of. I'll fix it eventually (it's a chicken and egg problem :/ or at least I think; I thought I fixed this 5 different ways already and don't remember what happened each time).

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

3 participants