Bug 675532 - X11 crashes if Xv is not enabled/supported and v4l driver is loaded (noticed with Intel driver) [@ xf86XVQueryOffscreenImages]
X11 crashes if Xv is not enabled/supported and v4l driver is loaded (noticed ...
Status: CLOSED EOL
Product: Fedora
Classification: Fedora
Component: xorg-x11-drv-v4l (Show other bugs)
19
Unspecified Unspecified
unspecified Severity medium
: ---
: ---
Assigned To: Adam Jackson
Fedora Extras Quality Assurance
[cat:crash]
: Patch, Triaged
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-02-06 06:21 EST by Mauro Carvalho Chehab
Modified: 2015-02-17 08:37 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-02-17 08:37:16 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Don't let the Xorg server crash if XV is not initialized (1.53 KB, patch)
2011-02-06 06:27 EST, Mauro Carvalho Chehab
no flags Details | Diff
Don't let the Xorg server crash if XV is not initialized v2 (1.55 KB, patch)
2011-02-06 21:22 EST, Mauro Carvalho Chehab
no flags Details | Diff

  None (edit)
Description Mauro Carvalho Chehab 2011-02-06 06:21:01 EST
Description of problem:

X11 crash during start if a V4L board that supports overlay mode is connected and the v4l driver is used.

Version-Release number of selected component (if applicable):

Noticed on Rawhide. Probably other versions are affected.

How reproducible:

It happens all the times.

Steps to Reproduce:
1. Plug a bttv or saa7134 pci board on the machine;
2. Use: Load "v4l" at xorg.conf (or xorg.conf.d);
3. start X with a driver with Xv disabled. On my tests, the crashes happened
   with the default configuration of the Intel driver, on a machine with 
   i915 chipset.
  
Actual results:

X crashes with the following message:

X: ../../../include/privates.h:115: dixGetPrivateAddr: Assertion `key->initialized' failed.

Expected results:

X shouldn't crash.

Additional info:

The v4l driver calls xf86XVQueryOffscreenImages() during its init, if it
founds a V4L device. However, this causes a crash, if the video adapter
didn't register XV support.

The reason is that this function calls dixGetPrivate in order to
locate the map. However, at include/privates.h, it is declared
as:

static inline void *
dixGetPrivateAddr(PrivatePtr *privates, const DevPrivateKey key)
{
    assert(key->initialized);
    return (char *) (*privates) + key->offset;
}

As nobody registered it, key->initialized is FALSE, and assert will
complain.

The fix is just return 0 if key is not initialized. A small change
is required at the v4l driver to not initialize it if Xv is not
supported.
Comment 1 Mauro Carvalho Chehab 2011-02-06 06:27:12 EST
Created attachment 477289 [details]
Don't let the Xorg server crash if XV is not initialized

This patch adds a check to avoid the crashes if XV is not initialized.
After the patch X11 server loads properly:

[ 21670.571] (==) intel(0): Intel XvMC decoder disabled
[ 21671.225] (II) v4l: /dev/video0 open ok
[ 21671.225] (II) v4l: /dev/video0 device supports overlay mode.
[ 21671.225] (II) VIDIOCSPICT / VIDIOC_S_FMT: 22
[ 21671.225] (II) VIDIOCSPICT / VIDIOC_S_FBUF: 22
[ 21671.225] (II) VIDIOCSPICT / VIDIOC_S_FMT: 22
[ 21671.225] (II) VIDIOCSPICT / VIDIOC_S_FBUF: 22
[ 21671.225] (II) v4l: add attr XV_ENCODING
[ 21671.225] (II) v4l: add attr XV_BRIGHTNESS
[ 21671.225] (II) v4l: add attr XV_CONTRAST
[ 21671.225] (II) v4l: add attr XV_SATURATION
[ 21671.225] (II) v4l: add attr XV_HUE
[ 21671.225] (II) VIDIOCGAUDIO / VIDIOC_G_AUDIO: 9
[ 21671.225] (II) v4l: add attr XV_FREQ
[ 21671.225] (II) v4l: saving config into driver data
[ 21671.225] (II) v4l: /dev/video0 init finished.
[ 21671.257] (II) v4l: init done, 1 device(s) found

The above messages are with the debug messages enabled. The last message indicates that v4l driver loaded properly.
Comment 2 Mauro Carvalho Chehab 2011-02-06 07:48:57 EST
I added a small patch at the Intel driver, as it should be supporting Xv:

diff -r 9a863fcd4479 src/intel_video.c
--- a/src/intel_video.c	Sun Feb 06 15:38:05 2011 -0500
+++ b/src/intel_video.c	Sun Feb 06 15:39:08 2011 -0500
@@ -398,6 +398,8 @@
 		adaptors[num_adaptors++] = overlayAdaptor;
 
 	if (num_adaptors) {
+		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+			   "Xv enabled with %d adaptors.\n", num_adaptors);
 		xf86XVScreenInit(screen, adaptors, num_adaptors);
 	} else {
 		xf86DrvMsg(scrn->scrnIndex, X_WARNING,

And a log at v4l driver to show when it detects that Xv is not supported. The result logs are:

[ 27315.881] (EE) v4l: video screen doesn't have Xv extension.
[ 27315.881] (WW) intel(0): Xv enabled with 2 adaptors.

What's happening here is that the v4l driver was loaded just before the Intel register for Xv. Due to that, it was failing.

Some change is needed to make sure that v4l driver will be loaded only after having all adapters registered.
Comment 3 Mauro Carvalho Chehab 2011-02-06 21:22:07 EST
Created attachment 477367 [details]
Don't let the Xorg server crash if XV is not initialized v2

Version 2: return NULL instead of 0 and sets num = 0
Comment 4 Mauro Carvalho Chehab 2011-02-08 05:18:14 EST
(In reply to comment #2)
> I added a small patch at the Intel driver, as it should be supporting Xv:
> 
> diff -r 9a863fcd4479 src/intel_video.c
> --- a/src/intel_video.c Sun Feb 06 15:38:05 2011 -0500
> +++ b/src/intel_video.c Sun Feb 06 15:39:08 2011 -0500
> @@ -398,6 +398,8 @@
>    adaptors[num_adaptors++] = overlayAdaptor;
> 
>   if (num_adaptors) {
> +  xf86DrvMsg(scrn->scrnIndex, X_WARNING,
> +      "Xv enabled with %d adaptors.\n", num_adaptors);
>    xf86XVScreenInit(screen, adaptors, num_adaptors);
>   } else {
>    xf86DrvMsg(scrn->scrnIndex, X_WARNING,
> 
> And a log at v4l driver to show when it detects that Xv is not supported. The
> result logs are:
> 
> [ 27315.881] (EE) v4l: video screen doesn't have Xv extension.
> [ 27315.881] (WW) intel(0): Xv enabled with 2 adaptors.
> 
> What's happening here is that the v4l driver was loaded just before the Intel
> register for Xv. Due to that, it was failing.
> 
> Some change is needed to make sure that v4l driver will be loaded only after
> having all adapters registered.

I've patched the driver to only talk with Xv during device open and this didn't solve at all.

What happens is that the Intel driver registers only textured video. I tested with nouveau driver and got similar results. So, the issue is not related to the
initialization order.

Yet, the fix at attachment 477367 [details] is needed, otherwise trying to load v4l driver will cause a crash during X start, if a video board with overlay support is connected and its driver is loaded.
Comment 5 Fedora End Of Life 2013-04-03 09:32:14 EDT
This bug appears to have been reported against 'rawhide' during the Fedora 19 development cycle.
Changing version to '19'.

(As we did not run this process for some time, it could affect also pre-Fedora 19 development
cycle bugs. We are very sorry. It will help us with cleanup during Fedora 19 End Of Life. Thank you.)

More information and reason for this action is here:
https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora19
Comment 7 Fedora End Of Life 2015-01-09 11:33:15 EST
This message is a notice that Fedora 19 is now at end of life. Fedora 
has stopped maintaining and issuing updates for Fedora 19. It is 
Fedora's policy to close all bug reports from releases that are no 
longer maintained. Approximately 4 (four) weeks from now this bug will
be closed as EOL if it remains open with a Fedora 'version' of '19'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 19 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.
Comment 8 Fedora End Of Life 2015-02-17 08:37:16 EST
Fedora 19 changed to end-of-life (EOL) status on 2015-01-06. Fedora 19 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Note You need to log in before you can comment on or make changes to this bug.