Bug 31544 - bad format in _mesa_format_to_type_and_comps
Summary: bad format in _mesa_format_to_type_and_comps
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Mesa core (show other bugs)
Version: 7.9
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: mesa-dev
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-10 23:47 UTC by Norbert Papke
Modified: 2011-01-11 08:46 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Output from .xsession-errors (8.33 KB, application/octet-stream)
2010-11-10 23:47 UTC, Norbert Papke
Details
emit the format name in the error message (655 bytes, patch)
2010-11-11 06:47 UTC, Brian Paul
Details | Splinter Review
Full backtrace (partial symbols) (14.55 KB, text/plain)
2010-11-11 12:22 UTC, Norbert Papke
Details
additional assertion for radeon driver (535 bytes, patch)
2010-11-11 14:44 UTC, Brian Paul
Details | Splinter Review
set texImage->TexFormat field in radeonSetTexBuffer2() (1.16 KB, patch)
2010-11-11 16:40 UTC, Brian Paul
Details | Splinter Review
set texImage->TexFormat field in r600SetTexBuffer2() (1.66 KB, patch)
2010-11-12 06:25 UTC, Brian Paul
Details | Splinter Review

Description Norbert Papke 2010-11-10 23:47:26 UTC
Created attachment 40198 [details]
Output from .xsession-errors

After upgrading to KDE 4.5.3 of Fedora 14, KWin fails with the following error:

Mesa 7.9 implementation error: bad format in _mesa_format_to_type_and_comps
Please report at bugzilla.freedesktop.org

Addition output (from .xession-errors) attached.
Comment 1 Brian Paul 2010-11-11 06:47:19 UTC
Can you debug this at all?  I don't know what format is causing this failure.  I've updated the code to print the format in the error message (and will attach the patch).
Comment 2 Brian Paul 2010-11-11 06:47:43 UTC
Created attachment 40205 [details] [review]
emit the format name in the error message
Comment 3 Brian Paul 2010-11-11 07:35:12 UTC
By inspection I found a few pixel formats that weren't handled in that function.  I've added them now and committed to git.  If you can test with Mesa from git, that'd be great.
Comment 4 Norbert Papke 2010-11-11 08:33:29 UTC
(In reply to comment #1)
> Can you debug this at all?  I don't know what format is causing this failure. 
> I've updated the code to print the format in the error message (and will attach
> the patch).

With the patch applied to the current Fedora 14 package (mesa-dri-drivers-7.9-2.fc14.x86_64 with Mesa from 2010-10-14), I now get

Mesa 7.9 implementation error: bad format MESA_FORMAT_NONE in _mesa_format_to_type_and_comps

Will try Mesa from git next.
Comment 5 Brian Paul 2010-11-11 08:44:44 UTC
Hmmm, we shouldn't even be in that function if format=MESA_FORMAT_NONE.  Can you run w/ gdb, set a breakpoint on _mesa_problem() and get a stack trace?
Comment 6 Norbert Papke 2010-11-11 09:14:43 UTC
I am having some build problems with the sources from git.  Presumably, to get the stack trace, the current Fedora sources are OK?

I need a few hours to get a debug environment set up and deal with some other unrelated issues.
Comment 7 Brian Paul 2010-11-11 09:22:24 UTC
(In reply to comment #6)
> I am having some build problems with the sources from git.  Presumably, to get
> the stack trace, the current Fedora sources are OK?

Sure.


> I need a few hours to get a debug environment set up and deal with some other
> unrelated issues.

OK, thanks for digging into this!
Comment 8 Norbert Papke 2010-11-11 12:21:05 UTC
Here's the top of the stack.  I'll attach to full-backtrace.  Please let me know if there is any other information I can provide.

#0  _mesa_problem (ctx=0x0, fmtString=
    0x7f5b436a4d95 "bad format %s in _mesa_format_to_type_and_comps")
    at main/imports.c:933
#1  0x00007f5b43562b92 in _mesa_format_to_type_and_comps (
    format=<value optimized out>, datatype=0x7fffcafad76c, comps=
    0x7fffcafad768) at main/formats.c:1336
#2  0x00007f5b43580b14 in _mesa_generate_mipmap (ctx=0x296a720, target=3553,
    texObj=0x331cb50) at main/mipmap.c:1582
#3  0x00007f5b43526ba4 in radeon_generate_mipmap (ctx=0x296a720, target=3553,
    texObj=0x331cb50) at radeon_texture.c:257
#4  radeonGenerateMipmap (ctx=0x296a720, target=3553, texObj=0x331cb50)
    at radeon_texture.c:300
#5  0x00007f5b43561087 in _mesa_GenerateMipmapEXT (target=3553)
    at main/fbobject.c:2126
#6  0x00007f5b57f330c4 in KWin::GLTexture::enableFilter() ()
   from /usr/lib64/libkwineffects.so.1
#7  0x00007f5b5865b881 in ?? () from /usr/lib64/libkdeinit4_kwin.so
#8  0x00007f5b57f32f99 in KWin::GLTexture::setWrapMode(unsigned int) ()
   from /usr/lib64/libkwineffects.so.1
#9  0x00007f5b5865efda in ?? () from /usr/lib64/libkdeinit4_kwin.so
#10 0x00007f5b58661ddc in ?? () from /usr/lib64/libkdeinit4_kwin.so
#11 0x00007f5b5865229f in ?? () from /usr/lib64/libkdeinit4_kwin.so
Comment 9 Norbert Papke 2010-11-11 12:22:36 UTC
Created attachment 40210 [details]
Full backtrace (partial symbols)
Comment 10 Brian Paul 2010-11-11 14:06:47 UTC
Could you go up the stack into _mesa_generate_mipmap() then do:

(gdb) p *texObj
(gdb) p *texObj->Image[0][texObj->BaseLevel]
Comment 11 Norbert Papke 2010-11-11 14:20:43 UTC
(gdb) up
#2  0x00007f7388223b14 in _mesa_generate_mipmap (ctx=0x22f6750, target=3553, 
    texObj=0x2d9f930) at main/mipmap.c:1582
1582       _mesa_format_to_type_and_comps(convertFormat, &datatype, &comps);
(gdb)  p *texObj
$1 = {Mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, 
      __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, 
    __size = '\000' <repeats 39 times>, __align = 0}, RefCount = 3, Name = 23, 
  Target = 3553, Priority = 1, BorderColor = {f = {0, 0, 0, 0}, ui = {0, 0, 0, 
    0}, i = {0, 0, 0, 0}}, WrapS = 10497, WrapT = 10497, WrapR = 10497, 
  MinFilter = 9987, MagFilter = 9729, MinLod = -1000, MaxLod = 1000, LodBias = 
    0, BaseLevel = 0, MaxLevel = 1000, MaxAnisotropy = 1, CompareMode = 0, 
  CompareFunc = 515, CompareFailValue = 0, DepthMode = 6409, _MaxLevel = 0, 
  _MaxLambda = 0, CropRect = {0, 0, 0, 0}, Swizzle = {6403, 6404, 6405, 6406}, 
  _Swizzle = 1672, GenerateMipmap = 0 '\000', _Complete = 0 '\000', 
  _RenderToTexture = 1 '\001', Purgeable = 0 '\000', Image = {{0x2d947d0, 
    0x0 <repeats 12 times>}, {0x0 <repeats 13 times>}, {
    0x0 <repeats 13 times>}, {0x0 <repeats 13 times>}, {
    0x0 <repeats 13 times>}, {0x0 <repeats 13 times>}}, Palette = {
    InternalFormat = 0, _BaseFormat = 0, Size = 0, TableF = 0x0, TableUB = 
    0x0, RedSize = 0 '\000', GreenSize = 0 '\000', BlueSize = 0 '\000', 
    AlphaSize = 0 '\000', LuminanceSize = 0 '\000', IntensitySize = 0 '\000'}, 
  DriverData = 0x0}
(gdb)  p *texObj->Image[0][texObj->BaseLevel]
$2 = {InternalFormat = 4, _BaseFormat = 6408, TexFormat = 0, Border = 0, 
  Width = 1093, Height = 52, Depth = 1, Width2 = 1093, Height2 = 52, Depth2 = 
    1, WidthLog2 = 10, HeightLog2 = 5, DepthLog2 = 0, MaxLog2 = 10, 
  WidthScale = 1093, HeightScale = 52, DepthScale = 1, IsClientData = 
    0 '\000', _IsPowerOfTwo = 0 '\000', TexObject = 0x2d9f930, FetchTexelc = 
    0, FetchTexelf = 0, RowStride = 1152, ImageOffsets = 0x2c4e670, Data = 
    0x0, DriverData = 0x0}
Comment 12 Brian Paul 2010-11-11 14:44:28 UTC
Created attachment 40216 [details] [review]
additional assertion for radeon driver

It should never be the case that a texture image has a non-zero width and height with TexFormat==0.  This assertion might catch the root problem.  Let me know what happens.
Comment 13 Norbert Papke 2010-11-11 15:21:01 UTC
There are significant changes to the radeon_texture.c file between the 7.9 and master branches.  The Fedora package stems from 7.9 as of 2010-10-14.  The patch does not apply against that version.  I will try to resolve my build problems with git master and retest against it.
Comment 14 Norbert Papke 2010-11-11 16:00:55 UTC
I retested against git master with the patch applied.  There is no discernible difference in behavior or gdb output.  The assertion was not triggered.
Comment 15 Brian Paul 2010-11-11 16:40:36 UTC
Created attachment 40217 [details] [review]
set texImage->TexFormat field in radeonSetTexBuffer2()

Here's another patch to try (for 7.9).
Comment 16 Norbert Papke 2010-11-11 22:41:53 UTC
The patch applied cleanly but unfortunately it doesn't seem to have any impact.  

However, I am not sure if I am doing this correctly.  I am testing with a Radeon HD 3650 card using the r600_dri.so driver.  The radeonSetTexBuffer2 symbol does not appear in this driver; it does exist in the radeon_dri.so driver.
Comment 17 Brian Paul 2010-11-12 06:25:08 UTC
Created attachment 40233 [details] [review]
set texImage->TexFormat field in r600SetTexBuffer2()

OK, here's a patch for the r600 driver.  Same idea as previous patch.
Comment 18 Norbert Papke 2010-11-12 08:06:10 UTC
With the r600 patch, kwin aborts when compositing is enabled:

drmRadeonCmdBuffer: -22. Kernel failed to parse or rejected command stream. See dmesg for more info.


From dmesg:

[82568.581911] radeon 0000:01:00.0: r600_cs_track_check:280 mask 0x0000000F | 0x0000000F no cb for 0
[82568.581913] radeon 0000:01:00.0: r600_packet3_check:1108 invalid cmd stream 502
[82568.581915] [drm:radeon_cs_ioctl] *ERROR* Invalid command stream !
Comment 19 Brian Paul 2010-11-12 09:22:07 UTC
Hmmm, I don't know what's going on there.  Maybe one of the r600 developers can take a look.  In the mean time, can you try the r600SetTexBuffer2() patch on Mesa/master from git?
Comment 20 Norbert Papke 2010-11-12 11:24:11 UTC
The command stream error also happens with git master.

Taking a slightly different tack, I have tried to narrow down which desktop effects cause the failure.  Many work just fine, e.g., basic compositing, translucency, thumbnails.  It seems that effects that distort windows such as "wobbly windows" and "magic lamp" trigger the problem.

If I disable those effects, the unpatched Fedora package also works for me.
Comment 21 Brian Paul 2010-11-15 08:14:32 UTC
At this point I think my patch which set's the texImage->TexFormat field in r600SetTexBuffer2() is the right fix but now you're hitting another r600 bug.  One of the r600 developers will probably have to help you with that.

I'll commit the above patches for radeon/r600.
Comment 22 Alex Deucher 2010-11-15 08:21:11 UTC
(In reply to comment #21)
> I'll commit the above patches for radeon/r600.

Please patch r200 and r300 similarly.
Comment 23 Brian Paul 2010-11-15 08:27:45 UTC
(In reply to comment #22)
> (In reply to comment #21)
> > I'll commit the above patches for radeon/r600.
> 
> Please patch r200 and r300 similarly.

Yup, just did.
Comment 24 Ian Romanick 2011-01-10 12:49:48 UTC
Three questions:

1. Can we come up with a test case that would have triggered this bug?

2. Are all of these patches in 7.9 and 7.10?

3. Assuming the answer to #2 is "yes," can this bug be closed?
Comment 25 Brian Paul 2011-01-11 07:44:54 UTC
(In reply to comment #24)
> Three questions:
> 
> 1. Can we come up with a test case that would have triggered this bug?

I think I can add some code in Mesa to check that all cases are handled in the _mesa_format_to_type_and_comps() function.


> 2. Are all of these patches in 7.9 and 7.10?

Yes.  Commit 97805cfedd6fbf344f70f187021c337665135466 in 7.9

> 3. Assuming the answer to #2 is "yes," can this bug be closed?

Yes.  Norbert's last issue should be filed as a new bug, if it's still happening.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.