Bug 111083

Summary: Crash happens when drawArrays after calling continuously glTexImage3D many times
Product: Mesa Reporter: xinghua <xinghua.cao>
Component: Drivers/DRI/i965Assignee: Intel 3D Bugs Mailing List <intel-3d-bugs>
Status: RESOLVED DUPLICATE QA Contact: Intel 3D Bugs Mailing List <intel-3d-bugs>
Severity: major    
Priority: medium    
Version: 19.0   
Hardware: x86-64 (AMD64)   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description xinghua 2019-07-08 06:07:59 UTC
The issue did not happen in old mesa version, but happens on Ubuntu 19.04 with mesa 19.0.2. It may be a regression.
Steps:
1. git clone https://chromium.googlesource.com/angle/angle && cd angle
3. python scripts/bootstrap.py
4. gclient sync
5. ./build/install-build-deps.sh
6. gn gen out/Debug
7. ninja -C out/Debug
8. cd out/Debug
9. ./angle_end2end_tests --gtest_filter=Texture3DTestES3.DrawWithLevelsOutsideRangeWithInconsistentDimensions/ES3_OpenGL

The crash cause: angle_end2end_tests: ../src/mesa/drivers/dri/i965/intel_mipmap_tree.c:1939: miptree_layer_range_length: Assertion `start_layer < total_num_layers' failed
start_layer and total_num_layers are all equal to 1 here.
Crash stack:
#0  miptree_layer_range_length (num_layers=1, start_layer=1, level=2, mt=0x5555571dc050) at ../src/mesa/drivers/dri/i965/intel_mipmap_tree.c:1939
#1  intel_miptree_prepare_access (brw=brw@entry=0x5555570e59b0, mt=mt@entry=0x5555571dc050, start_level=<optimized out>, num_levels=<optimized out>, num_levels@entry=1, start_layer=start_layer@entry=1, 
    num_layers=num_layers@entry=1, aux_usage=ISL_AUX_USAGE_CCS_E, fast_clear_supported=true) at ../src/mesa/drivers/dri/i965/intel_mipmap_tree.c:2393
#2  0x00007ffff4000cc3 in brw_blorp_copy_miptrees (brw=brw@entry=0x5555570e59b0, src_mt=src_mt@entry=0x5555571d2be0, src_level=<optimized out>, src_level@entry=2, src_layer=src_layer@entry=1, 
    dst_mt=dst_mt@entry=0x5555571dc050, dst_level=<optimized out>, dst_level@entry=2, dst_layer=<optimized out>, src_x=<optimized out>, src_y=<optimized out>, dst_x=<optimized out>, 
    dst_y=<optimized out>, src_width=<optimized out>, src_height=<optimized out>) at ../src/mesa/drivers/dri/i965/brw_blorp.c:497
#3  0x00007ffff40409d1 in intel_miptree_copy_slice (brw=brw@entry=0x5555570e59b0, src_mt=src_mt@entry=0x5555571d2be0, src_level=src_level@entry=2, src_layer=src_layer@entry=1, 
    dst_mt=dst_mt@entry=0x5555571dc050, dst_level=dst_level@entry=2, dst_layer=1) at ../src/mesa/drivers/dri/i965/intel_mipmap_tree.c:1550
#4  0x00007ffff4040d00 in intel_miptree_copy_teximage (brw=brw@entry=0x5555570e59b0, intelImage=intelImage@entry=0x5555571d4240, dst_mt=0x5555571dc050)
    at ../src/mesa/drivers/dri/i965/intel_mipmap_tree.c:1638
#5  0x00007ffff4049bb0 in intel_finalize_mipmap_tree (brw=brw@entry=0x5555570e59b0, tObj=0x5555571d1e10) at ../src/mesa/drivers/dri/i965/intel_tex_validate.c:155
#6  0x00007ffff4049e34 in brw_validate_textures (brw=brw@entry=0x5555570e59b0) at ../src/mesa/drivers/dri/i965/intel_tex_validate.c:195
#7  0x00007ffff400d4a6 in brw_prepare_drawing (max_index=5, min_index=0, index_bounds_valid=<optimized out>, ib=0x0, ctx=0x5555570e59b0) at ../src/mesa/drivers/dri/i965/brw_draw.c:811
#8  brw_draw_prims (ctx=0x5555570e59b0, prims=0x7fffffffd080, nr_prims=1, ib=0x0, index_bounds_valid=<optimized out>, min_index=<optimized out>, max_index=<optimized out>, gl_xfb_obj=0x0, stream=0, 
    indirect=0x0) at ../src/mesa/drivers/dri/i965/brw_draw.c:1133
#9  0x00007ffff426d8ea in _mesa_draw_arrays (drawID=0, baseInstance=0, numInstances=1, count=6, start=0, mode=4, ctx=0x5555570e59b0) at ../src/mesa/main/draw.c:407
#10 _mesa_draw_arrays (ctx=0x5555570e59b0, mode=4, start=0, count=6, numInstances=1, baseInstance=0, drawID=0) at ../src/mesa/main/draw.c:384
#11 0x00007ffff426d99c in _mesa_DrawArrays (mode=4, start=0, count=6) at ../src/mesa/main/draw.c:564
#12 0x00007ffff62b21da in rx::ContextGL::drawArrays (this=0x55555718e6d0, context=0x5555571b3ac0, mode=gl::PrimitiveMode::Triangles, first=0, count=6) at ../../src/libANGLE/renderer/gl/ContextGL.cpp:277
#13 0x00007ffff5d56fe2 in gl::Context::drawArrays (this=0x5555571b3ac0, mode=gl::PrimitiveMode::Triangles, first=0, count=6) at ../../src/libANGLE/Context.inl.h:100
#14 0x00007ffff5d5233c in gl::DrawArrays (mode=4, first=0, count=6) at ../../src/libGLESv2/entry_points_gles_2_0_autogen.cpp:683
#15 0x0000555556a9852a in ANGLETestBase::drawQuad (this=0x555556cba9d0, program=3, Python Exception <class 'gdb.error'> There is no member named _M_dataplus.: 
positionAttribName=, positionAttribZ=0.5, positionAttribXYScale=1, useVertexBuffer=false, useInstancedDrawCalls=false, 
    numInstances=0) at ../../src/tests/test_utils/ANGLETest.cpp:789
#16 0x0000555556a981e7 in ANGLETestBase::drawQuad (this=0x555556cba9d0, program=3, Python Exception <class 'gdb.error'> There is no member named _M_dataplus.: 
positionAttribName=, positionAttribZ=0.5, positionAttribXYScale=1, useVertexBuffer=false)
    at ../../src/tests/test_utils/ANGLETest.cpp:718
#17 0x0000555556a98189 in ANGLETestBase::drawQuad (this=0x555556cba9d0, program=3, Python Exception <class 'gdb.error'> There is no member named _M_dataplus.: 
positionAttribName=, positionAttribZ=0.5, positionAttribXYScale=1) at ../../src/tests/test_utils/ANGLETest.cpp:709
#18 0x0000555556a98145 in ANGLETestBase::drawQuad (this=0x555556cba9d0, program=3, Python Exception <class 'gdb.error'> There is no member named _M_dataplus.: 
positionAttribName=, positionAttribZ=0.5) at ../../src/tests/test_utils/ANGLETest.cpp:700
#19 0x0000555556870bcc in (anonymous namespace)::Texture3DTestES3_DrawWithLevelsOutsideRangeWithInconsistentDimensions_Test::TestBody (this=0x555556cba9d0)
    at ../../src/tests/gl_tests/TextureTest.cpp:2236
......


The test case code is as below, you could see more details in src/tests/gl_tests/TextureTest.cpp of ANGLE project.
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_3D, mTexture3D);
...
// Two levels that are initially unused.
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE,
             texDataRed.data());
glTexImage3D(GL_TEXTURE_3D, 2, GL_RGBA8, 2, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
             texDataCyan.data());
// One level that is used - only this level should affect completeness.
glTexImage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 2, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
             texDataGreen.data());
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_BASE_LEVEL, 1);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_LEVEL, 1);
drawQuad(mProgram, "position", 0.5f);
Comment 1 Mark Janes 2019-07-08 06:22:53 UTC
Please bisect this.
Comment 2 Paul 2019-07-08 09:13:53 UTC
Hi Xinghua, Mark
I've tried to reproduce the issue on my KBL (Intel® UHD Graphics 620) with ubuntu 18.04 and Kubuntu 19.04 with mesa 19.0.2 and mesa 19.2.0 - the issue isn't actual for both versions.
Could you please provide your version of the kernel, your configure command for the mesa and also would be helpful to know what version of the GPU you have?
Comment 3 Lionel Landwerlin 2019-07-08 09:15:35 UTC
(In reply to Paul from comment #2)
> Hi Xinghua, Mark
> I've tried to reproduce the issue on my KBL (Intel® UHD Graphics 620) with
> ubuntu 18.04 and Kubuntu 19.04 with mesa 19.0.2 and mesa 19.2.0 - the issue
> isn't actual for both versions.
> Could you please provide your version of the kernel, your configure command
> for the mesa and also would be helpful to know what version of the GPU you
> have?

Did drop the skip in the test? :


ANGLE_SKIP_TEST_IF(IsLinux() && IsIntel() && IsDesktopOpenGL());
Comment 4 Paul 2019-07-08 09:31:33 UTC
(In reply to Lionel Landwerlin from comment #3)
> (In reply to Paul from comment #2)
> > Hi Xinghua, Mark
> > I've tried to reproduce the issue on my KBL (Intel® UHD Graphics 620) with
> > ubuntu 18.04 and Kubuntu 19.04 with mesa 19.0.2 and mesa 19.2.0 - the issue
> > isn't actual for both versions.
> > Could you please provide your version of the kernel, your configure command
> > for the mesa and also would be helpful to know what version of the GPU you
> > have?
> 
> Did drop the skip in the test? :
> 
> 
> ANGLE_SKIP_TEST_IF(IsLinux() && IsIntel() && IsDesktopOpenGL());

exactly

1 GPUs:
  0 - Intel device id: 0x5917

Active GPU: 0

Optimus: false
AMD Switchable: false


Skipping tests using configuration ES3_OpenGLES because it is not available.
Skipping tests using configuration ES3_1_OpenGLES because it is not available.
Skipping tests using configuration ES2_OpenGLES because it is not available.
Skipping tests using configuration ES1_OpenGLES because it is not available.
Skipping tests using configuration ES2_OpenGLES_NoFixture because it is not available.
Skipping tests using configuration ES3_OpenGLES_NoFixture because it is not available.
Skipping tests using configuration ES3_1_OpenGLES_NoFixture because it is not available.
Skipping tests using configuration ES2_OpenGLES_NoVirtual because it is not available.
Skipping tests using configuration ES3_OpenGLES_NoVirtual because it is not available.
Note: Google Test filter = Texture3DTestES3.DrawWithLevelsOutsideRangeWithInconsistentDimensions/ES3_OpenGL
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from Texture3DTestES3
[ RUN      ] Texture3DTestES3.DrawWithLevelsOutsideRangeWithInconsistentDimensions/ES3_OpenGL
Test skipped: IsLinux() && IsIntel() && IsDesktopOpenGL().
[       OK ] Texture3DTestES3.DrawWithLevelsOutsideRangeWithInconsistentDimensions/ES3_OpenGL (67 ms)
[----------] 1 test from Texture3DTestES3 (67 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (68 ms total)
[  PASSED  ] 1 test.
Comment 5 Lionel Landwerlin 2019-07-08 10:08:44 UTC
Ok, bisected to :

commit 2b7d5c32178d93695a8a7a9bf6509933ab7c1002
Author: Andrii Simiklit <andrii.simiklit@globallogic.com>
Date:   Tue Oct 2 19:16:01 2018 +0300

    i965: consider a 'base level' when calculating width0, height0, depth0


We didn't backport this to 19.0, I'm opening an MR.
Comment 6 Lionel Landwerlin 2019-07-08 10:14:45 UTC
Marking as duplicate, MR opened : https://gitlab.freedesktop.org/mesa/mesa/merge_requests/1281

It seems we recommended users to switch to 19.1.1 as of 2 weeks ago.
Let's see what Dylan says on doing one more 19.0.x.

*** This bug has been marked as a duplicate of bug 107987 ***
Comment 7 Paul 2019-07-08 11:01:57 UTC
Lionel, just to confirm.
I did not immediately understand what you mean...
Sorry.
When I commented this in sources - ANGLE_SKIP_TEST_IF(IsLinux() && IsIntel() && IsDesktopOpenGL()); - the issue became relevant.
So, the issue is also actual on my side.
Comment 8 xinghua 2019-07-09 01:43:45 UTC
(In reply to Lionel Landwerlin from comment #3)
> (In reply to Paul from comment #2)
> > Hi Xinghua, Mark
> > I've tried to reproduce the issue on my KBL (Intel® UHD Graphics 620) with
> > ubuntu 18.04 and Kubuntu 19.04 with mesa 19.0.2 and mesa 19.2.0 - the issue
> > isn't actual for both versions.
> > Could you please provide your version of the kernel, your configure command
> > for the mesa and also would be helpful to know what version of the GPU you
> > have?
> 
> Did drop the skip in the test? :
> 
> 
> ANGLE_SKIP_TEST_IF(IsLinux() && IsIntel() && IsDesktopOpenGL());

Sorry, I had forgotten to tell you that the case had been currently skipped in project. You should drop this skip in the test.
Comment 9 xinghua 2019-07-09 02:09:12 UTC
(In reply to Lionel Landwerlin from comment #6)
> Marking as duplicate, MR opened :
> https://gitlab.freedesktop.org/mesa/mesa/merge_requests/1281
> 
> It seems we recommended users to switch to 19.1.1 as of 2 weeks ago.
> Let's see what Dylan says on doing one more 19.0.x.
> 
> *** This bug has been marked as a duplicate of bug 107987 ***

Does It mean that 19.0.x is not very stable? I think this bug is very critical, many paths could run to crash situation.
Comment 10 Kenneth Graunke 2019-07-09 06:44:01 UTC
(In reply to xinghua from comment #9)
> Does It mean that 19.0.x is not very stable? I think this bug is very
> critical, many paths could run to crash situation.

One issue in a pathological test case is hardly an indicator of driver quality.  Backporting bug fixes for unit tests isn't critical - fixing bugs hit by actual end user applications is critical.  Unless there's some real application running into trouble here, I wouldn't bother making an extra point release for an EOL'd release series.

We had this bug for probably 10 years and nobody noticed until this new unit test suite came along, so I'm not really convinced that it's critical.  ChromeOS also usually tracks master (and certainly wouldn't be staying on an old 19.0.x release), so it shouldn't matter much for them.

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.