Calibre crashes at startup with AttributeError: 'NoneType' object has no attribute 'cancel'

Bug #1898904 reported by grofaty
444
This bug affects 76 people
Affects Status Importance Assigned to Milestone
calibre (Ubuntu)
Fix Released
Undecided
Unassigned
Focal
Fix Released
Undecided
Unassigned

Bug Description

[Impact]
Calibre crashes on startup with Ubuntu 20.04.

[Test Case]
- install new package
- see if Calibre launches or crashes immediately on startup

[Where problems could occur]
This update contains an upstream commit which corrects the specific error which is happening on Ubuntu 20.04. It simply skips calling cancel() when it is not available. The only regression I can think of is if this patch is incomplete, but it seems to work fine.

Original report:
On Ubuntu 20.04 few months ago I installed Calibre from Ubuntu Store official repository.

I have been using Calibre for months, but today opening it from Ubuntu Launcher and nothing happens, no error.

Executing:
calibre
from terminal and the output is:
============
Traceback (most recent call last):
  File "/usr/bin/calibre", line 20, in <module>
    sys.exit(calibre())
  File "/usr/lib/calibre/calibre/gui_launch.py", line 73, in calibre
    main(args)
  File "/usr/lib/calibre/calibre/gui2/main.py", line 543, in main
    listener = create_listener()
  File "/usr/lib/calibre/calibre/gui2/main.py", line 514, in create_listener
    return Listener(address=gui_socket_address())
  File "/usr/lib/calibre/calibre/utils/ipc/server.py", line 110, in __init__
    self._listener._unlink.cancel()
AttributeError: 'NoneType' object has no attribute 'cancel'
============

Command:
calibre --version
outputs:
calibre (calibre 4.99.4)

I tried:
sudo apt purge calibre
sudo apt autoremove
sudo apt install calibre
but the problem is the same.

ProblemType: Bug
DistroRelease: Ubuntu 20.04
Package: calibre 4.99.4+dfsg+really4.12.0-1build1
ProcVersionSignature: Ubuntu 5.4.0-48.52-generic 5.4.60
Uname: Linux 5.4.0-48-generic x86_64
ApportVersion: 2.20.11-0ubuntu27.9
Architecture: amd64
CasperMD5CheckResult: skip
CurrentDesktop: ubuntu:GNOME
Date: Wed Oct 7 18:07:57 2020
InstallationDate: Installed on 2019-10-23 (350 days ago)
InstallationMedia: Ubuntu 18.04.3 LTS "Bionic Beaver" - Release amd64 (20190805)
PackageArchitecture: all
SourcePackage: calibre
UpgradeStatus: Upgraded to focal on 2020-08-14 (54 days ago)
modified.conffile..etc.default.apport: [modified]
mtime.conffile..etc.default.apport: 2020-04-29T17:08:03.553351

Revision history for this message
grofaty (grofaty) wrote :
grofaty (grofaty)
summary: - Calibre does not start anymore
+ Calibre crashes at startup with "/usr/bin/calibre, line 20" error
Revision history for this message
Launchpad Janitor (janitor) wrote : Re: Calibre crashes at startup with "/usr/bin/calibre, line 20" error

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in calibre (Ubuntu):
status: New → Confirmed
Revision history for this message
Juanjo Benages (juanjo-benages) wrote :
Revision history for this message
Juanjo Benages (juanjo-benages) wrote :

I forgot to upload the patch.

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "7b6416ac6522fc40f24f6baf3ca552b17a8b91d6.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
grofaty (grofaty) wrote :
Revision history for this message
Evan Huus (eapache) wrote :

Per https://bugzilla.redhat.com/show_bug.cgi?id=1840780#c2 this happens on python >= 3.8.3. As Focal ships 3.8.5 we get this bug. Juanjo linked and attached the upstream patch already, which is included in Calibre >= 4.15. Focal ships Calibre version 4.99.4 which I assume is some pre-release version of the Calibre 5 series which didn't yet include this fix. Calibre 5 is now available and presumably would also fix this issue.

summary: - Calibre crashes at startup with "/usr/bin/calibre, line 20" error
+ Calibre crashes at startup with AttributeError: 'NoneType' object has no
+ attribute 'cancel'
Revision history for this message
Evan Huus (eapache) wrote :

As a work-around for those affected, I can confirm that manually applying the upstream patch to `/usr/lib/calibre/calibre/utils/ipc/server.py` does allow Calibre to start up successfully.

Revision history for this message
grofaty (grofaty) wrote :

Evans, great thanks for info how to fix, it works fine.

I have written bash file for the users that are not so technical.

Instructions:
1. Download file patch.sh from my post.
2. Open terminal, default keyboard shortcut is: CTRL+ALT+T
3. Set execution permissions: chown 700 patch.sh
4. Execute commands: ./patch.sh
5. Then you can delete patch.sh file: rm patch.sh

Hope this helps for others too.

P.S. For non-technical users, package maintainer that has packaged original Calibre program in Ubuntu 20.04, please update the package and push it to official Ubuntu repository.

Revision history for this message
grofaty (grofaty) wrote :

Ahhh, sorry bug in instructions above in step 3 should be:
chmod 700 patch.sh

Revision history for this message
Juanjo Benages (juanjo-benages) wrote :

I have uploaded a patched version of calibre to a ppa: https://launchpad.net/~juanjo-benages/+archive/ubuntu/fixes

It works for me. It should work as an interim until there is an updated package in the official Ubuntu repository.

Timo Aaltonen (tjaalton)
Changed in calibre (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in calibre (Ubuntu Focal):
status: New → Confirmed
Revision history for this message
Norbert (nrbrtx) wrote :

Patch applied. Thanks!

Hope the package in the repository will be fixed soon.

Revision history for this message
Bill (franksmcb) (franksmcb) wrote :

Applied patch and can confirm it resolves the issue.

Revision history for this message
The Big Monkey (wipmonkey) wrote :

I also applied patch and can confirm it resolves the issue.

Revision history for this message
Carlos Pita (carlosjosepita) wrote :

When this started to happen? I would be surprised if it was an update to focal (why?), but I have the feeling this was working at the beginning.

Revision history for this message
Carlos Pita (carlosjosepita) wrote :

Maybe a python upgrade to 3.8.5 at some point since the release of focal?

Revision history for this message
Juanjo Benages (juanjo-benages) wrote :

Yes, Ubuntu Focal had Python 3.8.2 at release time, but there was a security update to Python 3.8.5.

Revision history for this message
Carlos Pita (carlosjosepita) wrote :

Here https://lists.ubuntu.com/archives/ubuntu-devel/2020-October/041237.html is a suggestion to sync from Groovy to Focal in order to fix the issue:

> I checked Calibre in Groovy (version 4.99.12+dfsg+really4.23.0-1) and it works fine. As per bug report #1898904 (https://bugs.launchpad.net/ubuntu/+source/calibre/+bug/1898904/comments/7), Calibre >=4.15 has the required patch. So, instead of waiting for 5.2, can we backport current Groovy version of Calibre to Focal?

Revision history for this message
carsten (carsten2) wrote :

Thanks grofaty, I'm a not so technical user and you instructions work fine. I did it!

Only one question: The terminal output ends with:

patching file /usr/lib/calibre/calibre/utils/ipc/server.py
Failed to parse old style options string with error: 'ascii' codec can't decode byte 0xd9 in position 1: ordinal not in range(128)

Is there anything to worry about?

When I download a tecnical file, I never know where to put it. Can you give some advice?
Thanks a lot!

Revision history for this message
Mauro (mauromol) wrote :

When will this fix land to Ubuntu official repository?

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

Attached is a debdiff with the minimal fix for this issue. I've uploaded an updated package for processing by the SRU team also.

Changed in calibre (Ubuntu Focal):
status: Confirmed → In Progress
description: updated
Revision history for this message
Norbert (nrbrtx) wrote :
Revision history for this message
Robie Basak (racb) wrote : Please test proposed package

Hello grofaty, or anyone else affected,

Accepted calibre into focal-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/calibre/4.99.4+dfsg+really4.12.0-1ubuntu1 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, what testing has been performed on the package and change the tag from verification-needed-focal to verification-done-focal. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-focal. 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 calibre (Ubuntu Focal):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-focal
Revision history for this message
Fredda (wiegner) wrote :

Thanks for releasing a fixed package.

BUT, could you consider using a release version of calibre instead of a development
version at a kind of random state. I see, that at the time focal was released there
was no 5.x version available, but meanwhile official 5.x releases are.

For a LTS version it's IMHO not a good idea to go with a development version, where
other bugs might be still in or there might be a good chance calibre plugins are broken
with this version.

In the ubuntu dev list https://lists.ubuntu.com/archives/ubuntu-devel/2020-October/041236.html
the debian caliber maintainer provided a 5.2 version for focal. I'm using it since he released
it and it works fine.

Source and amd64 packages are available there:
  deb http://www.preining.info/debian focal main
  deb-src http://www.preining.info/debian focal main

Could you consider using this (or another 5.x version) instead?

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

Let's fix the immediate problem first, then someone can file a new bug and do the proper procedure to try and get a newer version into focal and groovy.

Revision history for this message
Mauro (mauromol) wrote :

I have installed the calibre 4.99.4+dfsg+really4.12.0-1ubuntu1 package version from the proposed archive in Kubuntu 20.04. Calibre starts successfully. However, please note that I previously had patched the 4.99.4+dfsg+really4.12.0-1build1 version as suggested in #9, so it was starting anyway in my system.
No conflict was given on apt install of the new version though, perhaps the patch being applied is exactly the same as that in #9?

Revision history for this message
Juanjo Benages (juanjo-benages) wrote :

I have installed calibre version 4.99.4+dfsg+really4.12.0-1ubuntu1 from the proposed repository and now it starts successfully.

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

This bug was fixed in the package calibre - 4.99.4+dfsg+really4.12.0-1ubuntu1

---------------
calibre (4.99.4+dfsg+really4.12.0-1ubuntu1) focal; urgency=medium

  * Fix error during startup (LP: #1898904)
    - debian/patches/fix_cancel_attribute.patch: upstream patch to fix
      unknown attribute error in src/calibre/utils/ipc/server.py.

 -- Marc Deslauriers <email address hidden> Wed, 23 Dec 2020 12:53:50 -0500

Changed in calibre (Ubuntu Focal):
status: Fix Committed → Fix Released
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Update Released

The verification of the Stable Release Update for calibre has completed successfully and the package is now being 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

Related questions

Remote bug watches

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