-
-
Notifications
You must be signed in to change notification settings - Fork 474
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
[tkinter_.py] [Mac] Crashes with message "Segmentation fault: 11" #309
Comments
Fix tkinter error on Mac "unrecognized selector sent to instance" (Issue #306"). CEF must be initialized after Tk. Fix error with winfo_id() returning a negative value (Issue #308). This was resolved by obtaining NSView pointer using PyObjC package. There is yet another error "Segmentation fault: 11" which crashes app often, however it's hard to debug it (Issue #309).
I am walking through this under Wing IDE. It fails consistently on my system. The crash happens after the call to
Upon
(which I think is a red herring). Upon the
then the window appears and the segfault happens. By setting a lot of breakpoints I have verified that everything works fine up until entry to
I can't debug-step into this (actually I can, but the debugger next surfaces in re.py). |
When you remove the window_info parameter then you stop embedding browser inside tkinter window, so it stops being a tkinter example and thus it doesn't crash, because CEF creates the root window itself, just like in the hello world example. A blank window might appear when your Python does not support GUI applications, see this explanation on KB page: https://github.com/cztomczak/cefpython/blob/master/docs/Knowledge-Base.md#a-blank-window-on-maclinux |
Thanks for trying to debug this. The only idea I have for this moment would be to play with various tkinter options - global options or window options. Maybe changing some property of the window or some other option would get rid of the error. |
Or maybe the code that fetches window handle is not right - see Issue #308. You could try hardcoding the window handle value in the script - but first you would have to obtain such handle. On Linux you can do this using "xdotool" program, for Mac you would need to google that. |
My motive in this is to replace QWebEngine in an app based on Python 3.5, PyQt and Qt5.9. The app already works on MacOS, Ubuntu and Windows 7, but the use of QWebEngine prevents bunding it with PyInstaller. The local Python 3.5 is standard, located in /Library/Frameworks/Python.Framework, as normal when installed from the python.org download. The Mac system Python is at 2.7, located in /System/Library/Frameworks but is not involved in any way. I haven't touched tkinter in years so hesitate to get into that aspect but will keep poking at this in hopes of learning something useful. |
Your issue with a blank window is off-topic here (not a segmentation fault and not a tkinter issue). Please report it on the Forum and I can give you hints how to debug this. |
The issue with a blank window is a separate issue that needs be resolved as well. However this is not strictly a tkinter issue because as you said it is also reproducible in other examples. In most cases a blank window is an issue with broken Python and can be easily confirmed by running hello_world.py example using system Python. However like I said that's a separate issue that should be discussed elsewhere. |
Right, staying on topic of tkinter_.py. This is a pastebin of the full crash log and the following are the most relevant lines:
That appears to be the stack from the call of CreateBrowserSync in the Python code, and it dies in libobjc. Google "libobjc sendMsg crash" and you get some hits, mostly talking about sending a message to an object that has already been released. Further info: self.window_width is 0x320 Do you think that the get_window_handle() method is not returning something useful in MacOS? |
Some other important info from the full logs:
So now we know for sure it fails during embedding browser when adding subview. Regarding:
It might be. However why would then embedding browser work 50% of the times as reported originally. |
Looks like googling for "addSubview" "KERN_INVALID_ADDRESS" might give some relevant results. This answer makes some sense:
Ref: https://stackoverflow.com/a/7134555/623622 So that would explain why it sometimes work and sometimes not. Maybe the window handle returned is "lazy loading" meaning the handle is available, but the view wasn't really yet created? What if we delayed calling embed_browser() by for example 1 second to let tkinter complete loading its view? Can you try that? |
Some other search result mentions "autorelease". There were some fixes in upstream in regards to incorrect use of autorelease pools by CEF [1]. This is supposed to be fixed in CEF v59+, so worth trying running tkinter example using latest version of CEF. [1] https://bitbucket.org/chromiumembedded/cef/issues/2160/incorrect-use-of-autorelease-pools-in-3071 |
Hi there, Thank you creating this amazing python library. I tried to run the tkinter example with the latest CEF framework (60) downloaded from http://opensource.spotify.com/cefbuilds/index.html. It doesn't crash with segmentation fault anymore but I get this error:
|
@rafaelthca Your post is off-topic here. Report problems on the Forum. |
Is it? You mentioned that CEF v59+ could be the solution to fix the segmentation fault, I tested with v60 to see if it works |
It doesn't work and it's a different error, so this doesn't really say much. By off-topic I mean that that new error is off-topic here and if you want to debug it further we should discuss it elsewhere. |
Hi, I tested the tkinter_.py example as well and it ends in segmentation fault: 11 as well. python ./src/010-image-crawler/tk_demo.py
[tk_demo.py] CEF Python 66.0
[tk_demo.py] Python 3.7.3 64bit
[tk_demo.py] Tk 8.5.9
DevTools listening on ws://127.0.0.1:54075/devtools/browser/d5e4397c-1c55-4d11-8f59-e3876bcc98e8
GVA info: Successfully connected to the Intel plugin, offline Gen9
Segmentation fault: 11 Any idea how to fixit? The main reason why I what to use tkinter is, that I'm unable to bring the main window to front |
@freegroup Can you post a meaningful stack trace? Is it the same as in this comment #309 (comment) ? |
how to get the stacktrace? |
Did anyone test tkinter example on Mac with Tk 8.6? That newer version of Tk seems to be more stable with CEF, at least on Windows. |
I kept getting segmentation fault 11 every time i opened up a second instance of tk. wtf? well turns out you can only have one instance of tk even though i had destroyed and quit it in the previous module. i avoided this cryptic error by using toplevel instead of creating new root instances each time.. just in case someone had this issue |
tkinter example never worked for me on Mac at all. Did you get it working somehow? What version of Tk, python and Mac OS version? |
Actually no.. sorry man I hope u get it [x.py] CEF Python 66.0 DevTools listening on ws://127.0.0.1:64947/devtools/browser/ |
2 years! No solution |
This still haven't been debugged properly. We need a meaningful stack trace to understand the problem. @tallforasmurf You've provided stack trace, but the Chromium's part of stack trace does not contain meaningful symbols. You can download CEF symbols from here: http://opensource.spotify.com/cefbuilds/cef_binary_3.3359.1774.gd49d25f_macosx64_release_symbols.tar.bz2 |
Python 3.7.7 no improvement |
I was trying to symbolicate the stack trace provided by @tallforasmurf using your .dSYM file.
Does anybody know whether I am doing this wrong?
without an address outputs loads and loads of stuff. Using an address from that output works with the above command. |
Does anyone have a solution to this issue??? |
Here is the code that crashes: CefBrowserHostView* browser_view = [[CefBrowserHostView alloc] initWithFrame:contentRect];
browser_view.browser = browser_;
[parentView addSubview:browser_view];
!! CRASH --> [browser_view setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
[browser_view setNeedsDisplay:YES];
[browser_view release];
Apple docs for NSView autoresizingMask: Below is a meaningful stack trace for the crash:
|
It often crashes with this message. With system Python it crashes about 50% of the time, with Homebrew Python it crashes 100% of the time.
This error occurs randomly during initial app loading. This issue occurs only on Mac. Below logs:
There are some issues with Tk <> CEF initializations, they are conflicting each other. Tk must be initialized before CEF otherwise there was an another error described in Issue #306.
I've tried debugging it using gdb/lldb instructions from KB however I couldn't get a meaningful stack trace. On Linux gdb can show Python stack trace with "py-bt", but I have no idea how to debug this on Mac.
The text was updated successfully, but these errors were encountered: