question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: Segfaults appearing with "QObject::setParent: Cannot set parent, new parent is in a different thread"

See original GitHub issue

šŸ› Bug

In the last couple days, I’ve seen this segfault a couple times on main. I’m not quite sure what’s causing it yet, but it tends to happen with mouse movements, perhaps on the canvas, maybe on sliders, not sure… but it crashes napari out to the console

WARNING: QObject::setParent: Cannot set parent, new parent is in a different thread
10:19:54 WARNING QObject::setParent: Cannot set parent, new parent is in a different thread
WARNING: QObject::setParent: Cannot set parent, new parent is in a different thread
10:19:54 WARNING QObject::setParent: Cannot set parent, new parent is in a different thread
WARNING: QObject::setParent: Cannot set parent, new parent is in a different thread
10:19:54 WARNING QObject::setParent: Cannot set parent, new parent is in a different thread
[1]    19897 segmentation fault  napari

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:20 (18 by maintainers)

github_iconTop GitHub Comments

3reactions
andy-sweetcommented, Dec 13, 2022

Hey, I’m facing this issue now and was wondering if there has been any update already. I see #5195 was working on it. I’m also trying to update a layer outside the main thread.

I don’t think exact issue ever made into an official release as it should have been fixed between the release of v0.4.16 and v0.4.17 (first in https://github.com/napari/napari/pull/4983 then in https://github.com/napari/napari/pull/4985).

The goal of https://github.com/napari/napari/pull/5195 was to add some tooling to better detect when this happens, but it’s only available on main (i.e. not on v0.4.17). If you’re developing against main, then you can set NAPARI_ENSURE_PLUGIN_MAIN_THREAD=1 to get more info about where this is happening in your code.

Generally, napari is not thread safe, so I would only update a layer on the main thread unless some napari documentation says otherwise. If you can directly depend on superqt (the full napari viewer does), then you can use the ensure_main_thread decorator to ensure that a particular function/callback executes on the qt main thread.

If you still have problems, you might want to create a separate issue with the details.

1reaction
tlambert03commented, Aug 25, 2022

yeah, that seems like a good plan to me. ā€œupdate status barā€ is a strictly gui related thing, so that should probably have been on the _qt side of things all along

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot set parent, new parent is in a different thread in Python ...
I am facing a problem with the GUI I developed using PyQt5 . The app tries to update the value of a progress...
Read more >
QObject::setParent: Cannot set parent, new parent is in a ...
SOLVED QObject::setParent: Cannot set parent, new parent is in a different thread Segmentation fault ... i am working on new project with combinesĀ ......
Read more >
setParent: Cannot set parent, new parent is in a different thread
Hi, everyone. I've created this plugin to sync calibre library and Skoob (a book social network, similar to GoodReads).
Read more >
QObject::setParent across threads. - Qt Centre Forum
Cannot send events to objects owned by a different thread. ... Furthermore objects can't have a parent that lives in a diffrent thread...
Read more >
Debugging Segmentation Faults and Pointer Problems
For new programmers, debugging errors associated with pointers can be a nightmare. "Segmentation Fault (core dumped)" is a pretty vague error message,Ā ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found