gpu-manager: get_alternative_link() NEVER checks for a correct alternative

Bug #1575960 reported by Rafał Cieślak on 2016-04-27
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ubuntu-drivers-common (Ubuntu)
High
Alberto Milone
Xenial
High
Alberto Milone

Bug Description

SRU Request:

[Impact]
The current code will prevent gpu-manager from getting the correct list of alternatives. This breaks the detection system.

[Test Case]
Install the nvidia driver and check that gpu-manager reconfigures the system properly. More specifically, there should be no "Error: no alternative found for nvidia" line in /var/log/gpu-manager.log if the driver was installed correctly.

[Regression Potential]
Low, it is a one line change and a pretty obvious fix.

__________________________________________________________________________

I suppose this is a fairly significant bug, since it renders gpu-manager virtually useless.
I found it in ubuntu-drivers-common 0.4.17 (which is the current version in Ubuntu 16.04), and I do not know whether it is also present in other versions.

-- Symptoms --

For some reason, on my machine I frequently insert and remove my nvidia graphics adapter. My processor has an intel HD graphics adapter as well, so I rely on gpu-manager to detect my hardware configuration during boot, and update alternatives appropriately.

However, since I upgraded to Ubuntu 16.04, reconfiguring my hardware makes me unable to boot to desktop. However, reverting to previous hardware configuration solves the issue.

-- Analysis and proposed solution --

A quick check of symbolic links at /etc/ld.so.conf.d/x86_64-linux-gnu_GL.conf and similar confirms that when I change my hardware configuration, no changes are done to the targets of these links. Reading through gpu-manager.log I can see that it detects my hardware correctly, but it fails to configure alternatives, because:

    Error: no alternative found for nvidia
    Warning: no EGL alternative found for nvidia

Further investigation shows that the problem is with the get_alternative_link() function, as it always returns NULL, regardless of my current hardware configuration, and function arguments.

The get_alternative_link() function works by querying the list of available alternatives by running `update-alternatives` command with `--list` argument. The command is prepared by:

        snprintf(command, sizeof(command),
                 "update-alternatives --list %s_%s_conf",
                 alternative_pattern, arch_path);

For example, when looking for "gl" alternatives for architecture "x86_64-linux-gnu", the resulting command will be:

    update-alternatives --list gl_x86_64-linux-gnu_conf

This command always returns an empty list, and that is correct. The command is clearly malformed, the intention was to run another command, namely:

    update-alternatives --list x86_64-linux-gnu_gl_conf

(note the order of "gl" vs "x86_64_linux_gnu")
Indeed the `snprintf` used to prepare the command has it's arguments swapped. Therefore I propose to substitute the mentioned source code with:

        snprintf(command, sizeof(command),
                 "update-alternatives --list %s_%s_conf",
                 arch_path, alternative_pattern);

Applying the proposed change reliably fixes the bug symptoms I experienced.

-- Additional comment --

For your convenience, I attached to this bug report a patch file that applies the proposed solution; the patch is intended for ubuntu-drivers-common 0.4.17 source.
As far as I can tell, due to these swapped arguments gpu-manager always looks for unexisting alternatives, and therefore there is no scenario in which it would correctly configure alternatives. I suppose in this case gpu-manager always fails to serve its purpose. I find it astonishing that nobody noticed this issue yet.

The attachment "fix_alternative_argument_order.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
Martin Pitt (pitti) on 2016-04-28
Changed in ubuntu-drivers-common (Ubuntu):
assignee: nobody → Alberto Milone (albertomilone)
Alberto Milone (albertomilone) wrote :

Rafał: thank you for spotting the problem. To be honest, I am a little shocked too.

Changed in ubuntu-drivers-common (Ubuntu):
status: New → Triaged
importance: Undecided → Critical
Changed in ubuntu-drivers-common (Ubuntu):
status: Triaged → In Progress
Changed in ubuntu-drivers-common (Ubuntu Xenial):
status: New → In Progress
importance: Undecided → High
Changed in ubuntu-drivers-common (Ubuntu):
importance: Critical → High
Changed in ubuntu-drivers-common (Ubuntu Xenial):
assignee: nobody → Alberto Milone (albertomilone)
description: updated

Hello Rafał, or anyone else affected,

Accepted ubuntu-drivers-common into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/ubuntu-drivers-common/1:0.4.17.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 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 to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

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

Changed in ubuntu-drivers-common (Ubuntu Xenial):
status: In Progress → Fix Committed
tags: added: verification-needed

I confirm that installing 1:0.4.17.1 from -proposed fixes this bug for me.

tags: added: verification-done
removed: verification-needed
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ubuntu-drivers-common - 1:0.4.17.1

---------------
ubuntu-drivers-common (1:0.4.17.1) xenial-proposed; urgency=medium

  * gpu-manager.c:
    - Pass the arguments in the correct order when getting
      the list of alternatives (LP: #1575960).
      Thanks to Rafał Cieślak for the fix.

 -- Alberto Milone <email address hidden> Fri, 29 Apr 2016 12:29:03 +0200

Changed in ubuntu-drivers-common (Ubuntu Xenial):
status: Fix Committed → Fix Released

The verification of the Stable Release Update for ubuntu-drivers-common 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.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ubuntu-drivers-common - 1:0.4.18

---------------
ubuntu-drivers-common (1:0.4.18) yakkety; urgency=medium

  * gpu-manager.c:
    - Pass the arguments in the correct order when getting
      the list of alternatives (LP: #1575960).
      Thanks to Rafał Cieślak for the fix.

 -- Alberto Milone <email address hidden> Fri, 29 Apr 2016 12:29:03 +0200

Changed in ubuntu-drivers-common (Ubuntu):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers