Bug 92749 - seg fault in glTexImage2D
Summary: seg fault in glTexImage2D
Status: RESOLVED INVALID
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/DRI/i965 (show other bugs)
Version: 11.0
Hardware: x86 (IA32) Linux (All)
: medium major
Assignee: Ian Romanick
QA Contact: Intel 3D Bugs Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-30 22:01 UTC by Clive McCarthy
Modified: 2017-02-10 22:38 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
call to glTexImage2D seg faults during trace (16.00 MB, application/x-apitrace)
2015-10-30 22:01 UTC, Clive McCarthy
Details
trace dump (55.74 KB, text/plain)
2015-10-31 00:42 UTC, Clive McCarthy
Details
artefacts when rendering via FBO (1.20 MB, image/jpeg)
2015-10-31 01:11 UTC, Clive McCarthy
Details

Description Clive McCarthy 2015-10-30 22:01:06 UTC
Created attachment 119307 [details]
call to glTexImage2D seg faults during trace

The application is running on an i5-5250U running Linux 3.13.0 with Mesa 11.1.0

The application runs but artefacts appear in the rendered image. No OpenGL error is reported. When run inside apitrace the trace detects a seg fault.

The applications runs fine on Nvidia.
Comment 1 Ian Romanick 2015-10-30 22:50:47 UTC
Was the trace collected on the NVIDIA system or the Intel system?
Comment 2 Clive McCarthy 2015-10-30 22:56:21 UTC
(In reply to Ian Romanick from comment #1)
> Was the trace collected on the NVIDIA system or the Intel system?

The Intel system.
Comment 3 Clive McCarthy 2015-10-30 23:00:12 UTC
At the point of failure the code is sending a sequence of texture tiles to glTexImage2D. It's somewhat of a hangover from image tiling that was necessary with the GM945 and OpenGL 1.4 and the need for POT texture sizes.
Comment 4 Ian Romanick 2015-10-30 23:48:54 UTC
I tried the trace with a very, very old version of apitrace and current master.  I was unable to reproduce the segfault with current Mesa master on Broadwell on either version.  If I'm cross referencing CPUs to GPUs correctly (using https://en.wikipedia.org/wiki/List_of_Intel_graphics_processing_units), we should have about the same GPU.

I do get:

614: message: shader compiler issue 1: FS SIMD8 shader: 5 inst, 0 loops, 0:0 spills:fills, Promoted 0 constants, compacted 80 to 48 bytes.
614: message: shader compiler issue 2: FS SIMD16 shader: 5 inst, 0 loops, 0:0 spills:fills, Promoted 0 constants, compacted 80 to 48 bytes.
614: message: shader compiler issue 3: VS SIMD8 shader: 22 inst, 0 loops, 0:0 spills:fills, Promoted 0 constants, compacted 352 to 288 bytes.
614: message: shader compiler issue 4: FS SIMD16 shader: 2 inst, 0 loops, 0:0 spills:fills, Promoted 0 constants, compacted 32 to 32 bytes.
614: message: shader compiler issue 5: VS SIMD8 shader: 10 inst, 0 loops, 0:0 spills:fills, Promoted 0 constants, compacted 160 to 96 bytes.
error: xlib: GLXBadDrawable
error: xlib: GLXBadDrawable
error: drawable failed to resize: expected 32x32, got 0x0
649: message: shader compiler issue 6: FS SIMD8 shader: 4 inst, 0 loops, 0:0 spills:fills, Promoted 0 constants, compacted 64 to 48 bytes.
649: message: shader compiler issue 7: FS SIMD16 shader: 4 inst, 0 loops, 0:0 spills:fills, Promoted 0 constants, compacted 64 to 48 bytes.
649: message: shader compiler issue 8: VS SIMD8 shader: 10 inst, 0 loops, 0:0 spills:fills, Promoted 0 constants, compacted 160 to 96 bytes.
659: message: shader compiler issue 9: FS SIMD8 shader: 5 inst, 0 loops, 0:0 spills:fills, Promoted 0 constants, compacted 80 to 48 bytes.
659: message: shader compiler issue 10: FS SIMD16 shader: 5 inst, 0 loops, 0:0 spills:fills, Promoted 0 constants, compacted 80 to 48 bytes.
659: message: shader compiler issue 11: VS SIMD8 shader: 18 inst, 0 loops, 0:0 spills:fills, Promoted 0 constants, compacted 288 to 256 bytes.
661: message: shader compiler issue 12: VS SIMD8 shader: 18 inst, 0 loops, 0:0 spills:fills, Promoted 0 constants, compacted 288 to 256 bytes.
error: xlib: GLXBadDrawable
error: xlib: GLXBadDrawable
error: drawable failed to resize: expected 1365x1024, got 0x0
715: message: api performance issue 13: Multi-LOD fast clear - giving up (256x256x8).

After this there a bunch more instances of the Multi-LOD fast clear performance warning.  Through the whole thing I just get a black window.

Can you provide a backtrace from the segfault?
Comment 5 Clive McCarthy 2015-10-31 00:01:41 UTC
The GPU as reported by Mesa is: HD Graphics 6000 (Broadwell GT3)

I built apitrace just this morning (Matt Turner suggested it). The screen is indeed blank because it is loading the initial splash image. There are about 48 calls to glTexImage2D to load the tiles for the splash page. It doesn't crash on the first call.

I'm obviously new to apitrace but I'll try and get a back trace...
Comment 6 Clive McCarthy 2015-10-31 00:42:28 UTC
Created attachment 119309 [details]
trace dump

you can see the sequential calls to dlTexImage2D...
Comment 7 Ian Romanick 2015-10-31 00:54:18 UTC
Sorry... I didn't ask clearly enough.  I just wanted a stack backtrace from GDB from the point of the segfault.  You should just be able to

gdb --args ./glretrace seg_fault_glTexImage2d.trace 

"r", the "bt".

There are a couple weird things in that trace... are you really setting the filter mode and warp modes with glTexParameterf (instead of glTexParameteri)?  It's legal, but a little weird...

I wonder if the segfault (which only occurs for you in apitrace, right?) is due to apitrace doing weird things with GL_UNPACK_* settings you're using... like not having the source buffer set up correctly so that glTexImage reads past the end or something.  Dunno.
Comment 8 Clive McCarthy 2015-10-31 01:11:25 UTC
Created attachment 119310 [details]
artefacts when rendering via FBO
Comment 9 Clive McCarthy 2015-10-31 01:22:59 UTC
It is possible that there are two issues:

[1] 
That there is a long-standing bug in my glTexImage2D code which runs fine on Nvidia and even with the old GM945 !!

[2] 
That there is something up with glTexImage2D that somehow messes up the image only when I use an FBO and is cleverly detected by apitrace.

I don't think I can use GDB because the code doesn't crash when run normally, only with apitrace. It could be a bug in apitrace, maybe...

I'm really just trying to figure out the artefacts since the code "seems" to run reliably for weeks on end.
Comment 10 Clive McCarthy 2015-10-31 01:42:32 UTC
I cleaned these up:

There are a couple weird things in that trace... are you really setting the filter mode and warp modes with glTexParameterf (instead of glTexParameteri)?  It's legal, but a little weird...

No change.
Comment 11 Clive McCarthy 2015-10-31 01:57:59 UTC
1305 glGetTexLevelParameteriv(target = GL_TEXTURE_2D, level = 0, pname = GL_TEXTURE_COMPRESSED, params = &0)

1306 glGenTextures(n = 1, textures = &46)
1307 glBindTexture(target = GL_TEXTURE_2D, texture = 46)
1308 glTexParameterf(target = GL_TEXTURE_2D, pname = GL_TEXTURE_MAG_FILTER, param = GL_LINEAR)
1309 glTexParameteri(target = GL_TEXTURE_2D, pname = GL_TEXTURE_BASE_LEVEL, param = 0)
1310 glTexParameterf(target = GL_TEXTURE_2D, pname = GL_TEXTURE_MIN_FILTER, param = GL_LINEAR_MIPMAP_LINEAR)
1311 glTexParameterf(target = GL_TEXTURE_2D, pname = GL_TEXTURE_WRAP_S, param = GL_CLAMP_TO_EDGE)
1312 glTexParameterf(target = GL_TEXTURE_2D, pname = GL_TEXTURE_WRAP_T, param = GL_CLAMP_TO_EDGE)
1313 glPixelStorei(pname = GL_UNPACK_ROW_LENGTH, param = 2048)
1314 glPixelStorei(pname = GL_UNPACK_SKIP_PIXELS, param = 768)
1315 glPixelStorei(pname = GL_UNPACK_SKIP_ROWS, param = 1280)
1316 glTexParameteri(target = GL_TEXTURE_2D, pname = GL_GENERATE_MIPMAP, param = 1)
1317 glTexImage2D(target = GL_TEXTURE_2D, level = 0, internalformat = GL_RGB, width = 256, height = 256, border = 0, format = GL_RGBA, type = GL_UNSIGNED_BYTE, pixels = blob(12585984))
1319 glGetTexLevelParameteriv(target = GL_TEXTURE_2D, level = 0, pname = GL_TEXTURE_COMPRESSED, params = &0)

1320 glGenTextures(n = 1, textures = &47)
1321 glBindTexture(target = GL_TEXTURE_2D, texture = 47)
1322 glTexParameterf(target = GL_TEXTURE_2D, pname = GL_TEXTURE_MAG_FILTER, param = GL_LINEAR)
1323 glTexParameteri(target = GL_TEXTURE_2D, pname = GL_TEXTURE_BASE_LEVEL, param = 0)
1324 glTexParameterf(target = GL_TEXTURE_2D, pname = GL_TEXTURE_MIN_FILTER, param = GL_LINEAR_MIPMAP_LINEAR)
1325 glTexParameterf(target = GL_TEXTURE_2D, pname = GL_TEXTURE_WRAP_S, param = GL_CLAMP_TO_EDGE)
1326 glTexParameterf(target = GL_TEXTURE_2D, pname = GL_TEXTURE_WRAP_T, param = GL_CLAMP_TO_EDGE)
1327 glPixelStorei(pname = GL_UNPACK_ROW_LENGTH, param = 2048)
1328 glPixelStorei(pname = GL_UNPACK_SKIP_PIXELS, param = 1024)
1329 glPixelStorei(pname = GL_UNPACK_SKIP_ROWS, param = 1280)
1330 glTexParameteri(target = GL_TEXTURE_2D, pname = GL_GENERATE_MIPMAP, param = 1)

and then a seg fault
Comment 12 Ian Romanick 2015-11-02 16:11:53 UTC
(In reply to Clive McCarthy from comment #9)
> I don't think I can use GDB because the code doesn't crash when run
> normally, only with apitrace. It could be a bug in apitrace, maybe...

You can run apitrace in GDB. :)  I gave the command line that I used in comment #7.  Does that (or something similar) work for you?

My gut tells me that the rendering problem and the apitrace crash are separate issues.  If we can sort out what's going wrong with apitrace, I should be able to use the trace you provided to debug the rendering problem.
Comment 13 Clive McCarthy 2015-11-02 16:14:30 UTC
I agree. I'll run GDB as you suggest. Damn -- have to solve an ancillary problem to get to the real one.
Comment 14 Clive McCarthy 2015-11-05 20:23:17 UTC
I installed the development version of Mesa 11.1 dated November 4th. The artefacts experienced when blitting to and rendering via an FBO from Mesa 11.1 dated October 26th, that were the start of this report, have gone.

I think you can close this bug out.
Comment 15 Annie 2017-02-10 22:38:42 UTC
Dear Reporter,

This Mesa bug has been in the "NEEDINFO" status for over 60 days. I am closing this bug based on lack of response but feel free to reopen if resolution is still needed. Please ensure you're supplying the correct information as requested.

Thank you.


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.