nbd-server hangs after fork

Bug #2019852 reported by Marco Antonio Alvarez
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
nbd (Ubuntu)
Fix Released
Undecided
Unassigned
Lunar
Fix Released
High
Graham Inggs
Mantic
Fix Released
Undecided
Unassigned

Bug Description

[Impact]
Glib 2.76.0 reworked the implementation of GThreadPool, which nbd uses, in ways that it now no longer works if the treadpool is initialized before a fork() call, but used afterwards (which nbd used to do). A result of this bug in nbd is that, when run against glib 2.76.0 or above, it will accept() a connection from a client but then just sit there and never reply to any message from the client.

[Test plan]
The build contains a test which calls nbd-tester-client against the newly-built nbd-server. If the bug is still present, the test suite will fail. If the bug is not present, the test suite will complete successfully.

[What could go wrong]
The changes could affect the way things are sent to the client, but the build-time test suite should catch incompatible differences.

At any rate, the current package is completely unusable, so the only way to go is up.

[Original bug description]
After updating to lunar, my nbd-server stopped working (it accepts connections, but the forked nbd-server just hangs and no traffic goes in or out)

I tried building latest nbd (3.25) myself and the problem seems to be solved.

Its changelog says
- nbd-server now works as expected when compiled against glib >= 2.76.

So I suppose an updated version is needed.

Thanks!

Revision history for this message
Wouter Verhelst (wouter-debian) wrote :

Yes, that's exactly correct, and the issue will be fixed with the upload of nbd 3.25 to Debian, which will happen in a few months (after Debian releases). However, that won't fix Lunar.

In order to fix this, cherry-picking commits 3cb679f4a97e1a54a7285ee1f22e2888c9d3b900 and a10d07b43fe5169cd295604632faf6a08c52f75b from git HEAD should suffice.

Revision history for this message
Sergio Durigan Junior (sergiodj) wrote (last edit ):

Thank you for the report.

I can confirm this problem. Here are the steps to reproduce the bug:

$ lxc launch ubuntu:lunar nbd-bug --vm
$ lxc shell nbd-bug
# apt update && apt install -y nbd-server nbd-client
# modprobe nbd
# dd if=/dev/zero of=/srv/test-nbd bs=1024 count=10000
# mke2fs /srv/test-nbd
# chown nbd:nbd /srv/test-nbd
# nbd-server 9000 /srv/test-nbd
# nbd-client 127.0.0.1 9000 /dev/nbd0
# fdisk -l /dev/nbd0

The fdisk command should successfully return, but on Lunar and Mantic it hangs there.

Changed in nbd (Ubuntu Lunar):
status: New → Triaged
Changed in nbd (Ubuntu Mantic):
status: New → Triaged
Changed in nbd (Ubuntu Lunar):
importance: Undecided → High
Revision history for this message
Wouter Verhelst (wouter-debian) wrote :

Here's a debdiff that should work.

NOTE: I have no ubuntu lunar system available, so I couldn't test these packages. The patches have been tested and confirmed upstream, and I am 99% sure that this is sufficient, but please confirm by building locally before uploading ;-)

Revision history for this message
Wouter Verhelst (wouter-debian) wrote :

Previous attachment contained some autoreconf noise, this one should be more readable.

Revision history for this message
Wouter Verhelst (wouter-debian) wrote :

Justification for lunar update:

[Impact]
Glib 2.76.0 reworked the implementation of GThreadPool, which nbd uses, in ways that it now no longer works if the treadpool is initialized before a fork() call, but used afterwards (which nbd used to do). A result of this bug in nbd is that, when run against glib 2.76.0 or above, it will accept() a connection from a client but then just sit there and never reply to any message from the client.

[Test plan]
The build contains a test which calls nbd-tester-client against the newly-built nbd-server. If the bug is still present, the test suite will fail. If the bug is not present, the test suite will complete successfully.

If wanted, the test plan in comment 2 can also be run.

(Note that the NBD build-time test suite will fail if an nbd-server is running)

Steve Langasek (vorlon)
description: updated
Steve Langasek (vorlon)
Changed in nbd (Ubuntu Mantic):
status: Triaged → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package nbd - 1:3.24-1.1ubuntu1

---------------
nbd (1:3.24-1.1ubuntu1) mantic; urgency=medium

  * cherry-pick patches 3cb679f4a97e1a54a7285ee1f22e2888c9d3b900 and
    a10d07b43fe5169cd295604632faf6a08c52f75b from upstream git HEAD to
    fix operation with glib >= 2.76.0. LP: #2019852.

 -- Wouter Verhelst <email address hidden> Fri, 19 May 2023 10:38:13 +0200

Changed in nbd (Ubuntu Mantic):
status: Fix Committed → Fix Released
description: updated
Graham Inggs (ginggs)
Changed in nbd (Ubuntu Lunar):
assignee: nobody → Graham Inggs (ginggs)
status: Triaged → In Progress
description: updated
Revision history for this message
Timo Aaltonen (tjaalton) wrote : Please test proposed package

Hello Marco, or anyone else affected,

Accepted nbd into lunar-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/nbd/1:3.24-1.1ubuntu0.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, what testing has been performed on the package and change the tag from verification-needed-lunar to verification-done-lunar. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-lunar. 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 nbd (Ubuntu Lunar):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-lunar
Graham Inggs (ginggs)
tags: added: ftbfs
Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Performing the verification for Lunar.

First, checking that the issue can be reproduced.

# apt policy nbd-server nbd-client
nbd-server:
  Installed: 1:3.24-1.1
  Candidate: 1:3.24-1.1
  Version table:
 *** 1:3.24-1.1 500
        500 http://archive.ubuntu.com/ubuntu lunar/main amd64 Packages
        100 /var/lib/dpkg/status
nbd-client:
  Installed: 1:3.24-1.1
  Candidate: 1:3.24-1.1
  Version table:
 *** 1:3.24-1.1 500
        500 http://archive.ubuntu.com/ubuntu lunar/universe amd64 Packages
        100 /var/lib/dpkg/status
# fdisk -l /dev/nbd0
<hangs>

As expected, fdisk hangs with the problematic nbd. Now, upgrading the package and making sure that the new version fixes the issue.

# apt policy nbd-server nbd-client
nbd-server:
  Installed: 1:3.24-1.1ubuntu0.1
  Candidate: 1:3.24-1.1ubuntu0.1
  Version table:
 *** 1:3.24-1.1ubuntu0.1 100
        100 http://archive.ubuntu.com/ubuntu lunar-proposed/main amd64 Packages
        100 /var/lib/dpkg/status
     1:3.24-1.1 500
        500 http://archive.ubuntu.com/ubuntu lunar/main amd64 Packages
nbd-client:
  Installed: 1:3.24-1.1ubuntu0.1
  Candidate: 1:3.24-1.1ubuntu0.1
  Version table:
 *** 1:3.24-1.1ubuntu0.1 100
        100 http://archive.ubuntu.com/ubuntu lunar-proposed/universe amd64 Packages
        100 /var/lib/dpkg/status
     1:3.24-1.1 500
        500 http://archive.ubuntu.com/ubuntu lunar/universe amd64 Packages
# fdisk -l /dev/nbd0
Disk /dev/nbd0: 9.77 MiB, 10240000 bytes, 20000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

As can be seen, fdisk worked correctly after upgrading nbd.

This concludes the verification for Lunar.

tags: added: verification-done verification-done-lunar
removed: verification-needed verification-needed-lunar
Revision history for this message
Marco Antonio Alvarez (surakin) wrote :

Can confirm this fixed my original issue.
Great work :)

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

This bug was fixed in the package nbd - 1:3.24-1.1ubuntu0.1

---------------
nbd (1:3.24-1.1ubuntu0.1) lunar; urgency=medium

  * cherry-pick patches 3cb679f4a97e1a54a7285ee1f22e2888c9d3b900 and
    a10d07b43fe5169cd295604632faf6a08c52f75b from upstream git HEAD to
    fix operation with glib >= 2.76.0. LP: #2019852.

 -- Wouter Verhelst <email address hidden> Fri, 19 May 2023 10:38:13 +0200

Changed in nbd (Ubuntu Lunar):
status: Fix Committed → Fix Released
Revision history for this message
Robie Basak (racb) wrote : Update Released

The verification of the Stable Release Update for nbd 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

Remote bug watches

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