Debugging wxPython crash

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Debugging wxPython crash

Ed Leafe-2
I’ve gotten wxPython 4 running on my Mac, but after running a bit it always crashes with output like “Segmentation fallout: 11”. I’ve stepped through my code, and it doesn’t happen at a particular line; it feels more or less random.

Looking in Console.app, I found the crash logs, but I can’t understand them well enough to figure out the problem. Here’s one such log: https://pastebin.com/39GEbdmH

Can anyone shed some light on this?


-- Ed Leafe

P.S. - I sent this exact message via email several hours ago without it showing up in the group, so I'm trying to post directly.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Debugging wxPython crash

Robin Dunn
On Thursday, January 24, 2019 at 11:30:25 AM UTC-8, Ed Leafe wrote:
I’ve gotten wxPython 4 running on my Mac, but after running a bit it always crashes with output like “Segmentation fallout: 11”. I’ve stepped through my code, and it doesn’t happen at a particular line; it feels more or less random.

Looking in Console.app, I found the crash logs, but I can’t understand them well enough to figure out the problem. Here’s one such log: <a href="https://pastebin.com/39GEbdmH" style="font-family:Helvetica;font-size:16px" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fpastebin.com%2F39GEbdmH\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEtjXCOyQiE5H9KttvqAvQHsko4xg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fpastebin.com%2F39GEbdmH\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEtjXCOyQiE5H9KttvqAvQHsko4xg&#39;;return true;">https://pastebin.com/39GEbdmH

Can anyone shed some light on this?


Can you create a small standalone sample that shows the problem? The crash happened in the C++ wxMenuBase::UpdateUI method, so it's likely that it's related to the menus or associated windows in some way. Perhaps something like trying to use pushed event handlers for items that have already been destroyed, or trying to recursively invoke UpdateUI for submenus that are in the process of being deleted, etc. HOpefully you can narrow things down from those hints.

--
Robin

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Debugging wxPython crash

Ed Leafe-2


On Friday, January 25, 2019 at 10:04:07 AM UTC-6, Robin Dunn wrote:
On Thursday, January 24, 2019 at 11:30:25 AM UTC-8, Ed Leafe wrote:
I’ve gotten wxPython 4 running on my Mac, but after running a bit it always crashes with output like “Segmentation fallout: 11”. I’ve stepped through my code, and it doesn’t happen at a particular line; it feels more or less random.

Looking in Console.app, I found the crash logs, but I can’t understand them well enough to figure out the problem. Here’s one such log: <a href="https://pastebin.com/39GEbdmH" style="font-family:Helvetica;font-size:16px" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fpastebin.com%2F39GEbdmH\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEtjXCOyQiE5H9KttvqAvQHsko4xg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fpastebin.com%2F39GEbdmH\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEtjXCOyQiE5H9KttvqAvQHsko4xg&#39;;return true;">https://pastebin.com/39GEbdmH

Can anyone shed some light on this?


Can you create a small standalone sample that shows the problem? The crash happened in the C++ wxMenuBase::UpdateUI method, so it's likely that it's related to the menus or associated windows in some way. Perhaps something like trying to use pushed event handlers for items that have already been destroyed, or trying to recursively invoke UpdateUI for submenus that are in the process of being deleted, etc. HOpefully you can narrow things down from those hints.

--
Robin

I'm one of the authors of Dabo (https://dabodev.com), and after a long hiatus I'm trying to get it running with Python3 and wxPython 4.x. The crash is definitely menu-related, as it happens when I try to click on the View or Help menus. The standard Dabo menubar has the typical "File/Edit/View/Help" menus; File and Edit seem to work fine, but attempting to open up View causes an immediate segfault.

So without installing the experimental Dabo 3 code, it would be hard to post a sample to reproduce. Since Dabo wraps the wx objects, it's very possible that the change from classic wxPython to Phoenix changed the order of creation/destruction, now that the two-phase construction is a thing of the past. I suppose I'll have to revisit the entire process of wrapping menu events.

Here is some additional debug information from Console, in case that helps to understand the error more clearly:

error 10:02:00.379605 -0600 cfprefsd rejecting write of key _DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertEventsNotification:/app/usageActivityDate in { com.apple.contextstored, root, kCFPreferencesAnyHost, no container, managed: 0 } from process 184 because setting preferences outside an application's container requires user-preference-write or file-write-data sandbox access
error 10:02:00.383774 -0600 contextstored Couldn't write value for key _DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertEventsNotification:/app/usageActivityDate in CFPrefsPlistSource<0x7f87c9d06060> (Domain: com.apple.contextstored, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: Yes): setting preferences outside an application's container requires user-preference-write or file-write-data sandbox access
error 10:02:00.386501 -0600 cfprefsd rejecting write of key _DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertLocalEventsNotification:/app/usageActivityDate in { com.apple.contextstored, root, kCFPreferencesAnyHost, no container, managed: 0 } from process 184 because setting preferences outside an application's container requires user-preference-write or file-write-data sandbox access
error 10:02:00.387799 -0600 contextstored Couldn't write value for key _DKThrottledActivityLast_DKKnowledgeStorageLogging_DKKnowledgeStorageDidInsertLocalEventsNotification:/app/usageActivityDate in CFPrefsPlistSource<0x7f87c9d06060> (Domain: com.apple.contextstored, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: Yes): setting preferences outside an application's container requires user-preference-write or file-write-data sandbox access
error 10:02:00.421395 -0600 sandboxd Sandbox: contextstored(184) deny(1) file-write-data /private/var/root/Library/Preferences/com.apple.contextstored.plist
Violation:       deny(1) file-write-data /private/var/root/Library/Preferences/com.apple.contextstored.plist 
Process:         contextstored [184]
Path:            /System/Library/PrivateFrameworks/CoreDuetContext.framework/Versions/A/Resources/contextstored
Load Address:    0x1076b0000
Identifier:      contextstored
Version:         ??? (???)
Code Type:       x86_64 (Native)
Parent Process:  launchd [1]
Responsible:     /System/Library/PrivateFrameworks/CoreDuetContext.framework/Resources/contextstored [184]
User ID:         0

Date/Time:       2019-01-25 10:02:00.399 CST
OS Version:      Mac OS X 10.14.2 (18C54)
Report Version:  8

 -- Ed Leafe

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
bht
Reply | Threaded
Open this post in threaded view
|

Re: Debugging wxPython crash

bht
In reply to this post by Ed Leafe-2
I have seen lots of seg faults from wxpython on the Mac over the years when same code runs fine with other OSes. The cause is usually a callback routine referencing a widget that has been deleted. Debugging can be tough since GUI event handling changes in the debug environment. Sometimes the only thing that works is to pepper my code with print statements so I can find what is actually happening just before the crash. The solution usually ends up changing callbacks to use wx.CallAfter or wx.CallLater to access widgets. Keep in mind that events are not always triggered when you think.

Brian

On Thursday, January 24, 2019 at 1:30:25 PM UTC-6, Ed Leafe wrote:
I’ve gotten wxPython 4 running on my Mac, but after running a bit it always crashes with output like “Segmentation fallout: 11”. I’ve stepped through my code, and it doesn’t happen at a particular line; it feels more or less random.


--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Debugging wxPython crash

Dietmar Schwertberger-2
If a widget is destroyed while there are pending events for it, wx will
crash later on when the event should be handled.
If your code destroys widgets, use DestroyLater which will wait until
there are no more pending events.

Regards,
Dietmar

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Debugging wxPython crash

Robin Dunn
In reply to this post by Ed Leafe-2
On Friday, January 25, 2019 at 8:15:53 AM UTC-8, Ed Leafe wrote:
now that the two-phase construction is a thing of the past.


It's still there. It's just that instead of needing to use `wx.PreFrame()` for the first phase, you can now use `wx.Frame()`.

--
Robin

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Debugging wxPython crash

Ed Leafe-2
On Friday, January 25, 2019 at 2:26:21 PM UTC-6, Robin Dunn wrote:
On Friday, January 25, 2019 at 8:15:53 AM UTC-8, Ed Leafe wrote:
now that the two-phase construction is a thing of the past.


It's still there. It's just that instead of needing to use `wx.PreFrame()` for the first phase, you can now use `wx.Frame()`.

--
Robin

Oh? Just a name change? I must have mis-read the docs. Maybe that's why I'm seeing these issues: I changed how the underlying wxPython object was created.

-- Ed

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Debugging wxPython crash

Robin Dunn
On Friday, January 25, 2019 at 12:52:39 PM UTC-8, Ed Leafe wrote:

Oh? Just a name change? I must have mis-read the docs. Maybe that's why I'm seeing these issues: I changed how the underlying wxPython object was created.

Yep, there's a blurb about it here: https://docs.wxpython.org/MigrationGuide.html#phase-create

--
Robin

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.