Error launching host dialog: 'NoneType' object has no attribute '__getitem__'

Bug #1794315 reported by Marius Gedminas
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
virt-manager (Ubuntu)
Fix Released
Undecided
Unassigned
Bionic
Fix Released
Undecided
Christian Ehrhardt 

Bug Description

[Impact]

 * There is a potential race why the async availability of an Object might
   lead to an access of a None object and fail virt-manager.

 * The fix just makes sure this cases is avoided by checking the type
   upfront.

 * Slow remote connections are assumed to increase the window for this
   race, but so far it seems rare and barely reproducible.

[Test Case]

 * This is hard - sorry. While in theory it seems clear what happens
   (self._hostinfo is None) it is hard to provike that. But OTOH people
   have hit it in the field, so we want to fix it.
   Given the very small change I'd ask you to review it on the code level
   instead of testing.

  * If one insists on testing create a bunch of slow conenctions to remote
    ssh libvirtd. And iterate connecting to those remotes. But so far I
    wan't able to trigger it that way (more tests, slower connection, more
    bad luck needed).

[Regression Potential]

 * Just adding an extra sanity check before accessing an (otherwise)
   potentially None Object IMHO poses no extra regression risk.

[Other Info]

 * n/a

---

I launched virt-manager and connected to libvirtd running on a local server via an SSH connection. I got an unexpected error dialog

    Error launching host dialog: 'NoneType' object has no attribute '__getitem__'

I have a screenshot of the last part of the traceback (attached), but unfortunately I didn't think to copy it as text, and I can no longer reproduce the error. I'll retype the last frame a least:

      File "/usr/share/virt-manager/virtManager/connection.py", line 349, in host_memory_size
        return self._hostinfo[1] * 1024
    TypeError: 'NoneType' object has no attribute '__getitem__'

After I dismissed the error dialog, everything seemed to be working just fine -- I could see the VMs and connect to them.

ProblemType: Bug
DistroRelease: Ubuntu 18.04
Package: virt-manager 1:1.5.1-0ubuntu1
ProcVersionSignature: Ubuntu 4.15.0-34.37-generic 4.15.18
Uname: Linux 4.15.0-34-generic x86_64
NonfreeKernelModules: zfs zunicode zavl icp zcommon znvpair
ApportVersion: 2.20.9-0ubuntu7.3
Architecture: amd64
CurrentDesktop: GNOME
Date: Tue Sep 25 18:20:39 2018
InstallationDate: Installed on 2016-09-10 (745 days ago)
InstallationMedia: Ubuntu-GNOME 16.04.1 LTS "Xenial Xerus" - Release amd64 (20160720)
PackageArchitecture: all
SourcePackage: virt-manager
UpgradeStatus: Upgraded to bionic on 2018-04-27 (151 days ago)

Related branches

Revision history for this message
Marius Gedminas (mgedmin) wrote :
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

_hostinfo is initialized as None

connection.py:__init__:236 self._hostinfo = None

The code that fails has a check on backend is open to be sure it is initialized.
And the init of that value is at
connection.py:_tick:1331 self._hostinfo = self._backend.getInfo()

This polls for new objects regularly.
There might be a race of the backend being opened, but no updates yet completed.
That might be more likely for a more remote connection that is slow, but local ssh sounds fast.

A safety check to not be None might be worth to be added just to be sure.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

I submitted a fix upstream for the consideration of the subject matter experts
=> https://github.com/virt-manager/virt-manager/pull/32

Changed in virt-manager (Ubuntu):
status: New → Confirmed
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

MP with the fix added to the packaging available at: https://code.launchpad.net/~paelzer/ubuntu/+source/virt-manager/+git/virt-manager/+merge/356334

But the time to the Final Freeze is close, so it is rather soon or will need to be converted to an SRU later.

Changed in virt-manager (Ubuntu):
status: Confirmed → In Progress
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

I have prepared this to be uploaded, but I have hit an FTBFS in virt-manager that wasn't there last time :-/

I have to analyze and fix it and then cosmic likely is closed for uploads.
So FYI - fixing this will take a bit more time than intended.

Bug for the build issue is bug 1796932

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package virt-manager - 1:1.5.1-0ubuntu2

---------------
virt-manager (1:1.5.1-0ubuntu2) cosmic; urgency=medium

  * d/p/lp-1794315-connection-avoid-failing-on-NoneType.patch: fix a race
    (worse on slow remote connections) that would break connecting to a
    remote (LP: #1794315)
  * d/p/lp-1796932-tests-osdict-fix-ordering-issue-with-new-osinfo.patch:
    fix FTBFS due to self-tests failing with new osinfo (LP: #1796932)

 -- Christian Ehrhardt <email address hidden> Tue, 09 Oct 2018 16:57:42 +0200

Changed in virt-manager (Ubuntu):
status: In Progress → Fix Released
Changed in virt-manager (Ubuntu Bionic):
status: New → Triaged
description: updated
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Added an SRU Template and did a test build in [1]
LGTM, opening up the MP [2] for review towards extra confidence.

[1]: https://launchpad.net/~ci-train-ppa-service/+archive/ubuntu/3478/+packages
[2]: https://code.launchpad.net/~paelzer/ubuntu/+source/virt-manager/+git/virt-manager/+merge/356647

Changed in virt-manager (Ubuntu Bionic):
assignee: nobody →  Christian Ehrhardt  (paelzer)
status: Triaged → In Progress
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

MP approved and made available to the SRU team in Bionic-unapproved.

Changed in virt-manager (Ubuntu Bionic):
status: In Progress → Triaged
Revision history for this message
Brian Murray (brian-murray) wrote : Please test proposed package

Hello Marius, or anyone else affected,

Accepted virt-manager into bionic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/virt-manager/1:1.5.1-0ubuntu1.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-bionic to verification-done-bionic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-bionic. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in virt-manager (Ubuntu Bionic):
status: Triaged → Fix Committed
tags: added: verification-needed verification-needed-bionic
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

As outlined a direct test of the issue is hard to perform.
So I did more a general regression check diving through various options of libvirt pre/post an upgrade to proposed 1:1.5.1-0ubuntu1.1

In addition I ssh connected to a remote host (horsea), but as I said before it didn't trigger the bug (but at least it confrirmed ssh remotes are still working as we touched code there.

Thereby, setting verification done

tags: added: verification-done verification-done-bionic
removed: verification-needed verification-needed-bionic
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package virt-manager - 1:1.5.1-0ubuntu1.1

---------------
virt-manager (1:1.5.1-0ubuntu1.1) bionic; urgency=medium

  * d/p/lp-1794315-connection-avoid-failing-on-NoneType.patch: fix a race
    (worse on slow remote connections) that would break connecting to a
    remote (LP: #1794315)

 -- Christian Ehrhardt <email address hidden> Tue, 09 Oct 2018 16:57:42 +0200

Changed in virt-manager (Ubuntu Bionic):
status: Fix Committed → Fix Released
Revision history for this message
Robie Basak (racb) wrote : Update Released

The verification of the Stable Release Update for virt-manager has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.