Bug 39320

Summary: util/u_upload_mgr.c:192:u_upload_alloc: Assertion `offset < upload->buffer->width0' failed.
Product: Mesa Reporter: Michal Suchanek <hramrach>
Component: Drivers/Gallium/r300Assignee: Default DRI bug account <dri-devel>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: git   
Hardware: Other   
OS: All   
URL: http://bugs.winehq.org/show_bug.cgi?id=27823
Whiteboard:
i915 platform: i915 features:
Attachments: print debug info
backtrace of glretrace

Description Michal Suchanek 2011-07-18 00:14:17 UTC
This happens when running d3d application in recent wine with MESA_EXTENSION_OVERRIDE="-GL_ARB_map_buffer_range"
Comment 1 Marek Olšák 2011-07-18 18:18:00 UTC
Could you please attach an apitrace file?

Apitrace can record and replay OpenGL commands. You can get it here:
https://github.com/apitrace/apitrace
Comment 2 Michal Suchanek 2011-07-19 06:09:04 UTC
Can't.

The trace file is 6.7M gzipped and the attachment limit is 3000k.

It is trace from the start of the application to the point where it finishes initialization, tries to render the first scene and triggers the assert.


glretrace complains that the last call is incomplete whatever that means:

warning: incomplete call glDrawElementsBaseVertex
27826 glDrawElementsBaseVertex(mode = GL_TRIANGLE_STRIP, count = 110, type = GL_UNSIGNED_SHORT, indices = blob(220), basevertex = 54)

Tried taking glretrace snapshots with -s. They are all small black squares. With -sb and -s I get errors about GL_BACK being invalid but every other snapshot contains the application loading screen (upside down).
Comment 3 Marek Olšák 2011-09-11 00:55:56 UTC
I couldn't reproduce this with the Wine D3D9 tests.

Can you attach the full backtrace of the crash? Knowing the values of local variables and upload->buffer->width0 would be useful too. Alternatively, you can update your apitrace and give it a try again.
Comment 4 Michal Suchanek 2011-09-11 01:51:02 UTC
I think that the reason apitrace does not finish the trace properly is that Mesa aborts and apitrace runs in the aborted process so there is not much that can be done.

I can't really debug wine because it is i386, not amd64.

I could perhaps try building more recent mesa to see if the issue is gone yet.
Comment 5 Marek Olšák 2011-09-11 01:57:41 UTC
You may set:

export GALLIUM_ABORT_ON_ASSERT=0

to disable abort() on assertions.
Comment 6 Michal Suchanek 2011-09-11 16:10:26 UTC
Hmm, current apitrace can't trace the program, it segfaults.

Also retracing a trace which would lead to the assertion causes glretrace segfault.

This is somewhat different from what I got previously but not exactly helpful except perhaps as a sample trace showing apitrace problems.
Comment 7 Michal Suchanek 2011-09-19 09:39:58 UTC
According to apitrace author the glretrace crash is due to gallium reading more data than is in the buffer.

https://github.com/apitrace/apitrace/issues/39#issuecomment-2134199
Comment 8 Marek Olšák 2011-09-19 12:44:51 UTC
Created attachment 51371 [details] [review]
print debug info

I think it crashes because offset >= upload->buffer->width0.

Could you apply the attached patch and post the output of stderr?
Comment 9 Michal Suchanek 2011-09-19 14:52:19 UTC
I get this extra output:

u_vbuf_upload_buffers
u_vbuf_upload_buffers
u_vbuf_upload_buffers
u_vbuf_upload_buffers
u_vbuf_upload_buffers
u_vbuf_upload_buffers
u_vbuf_upload_buffers
u_upload_alloc:194: min_out_offset = 4294966000, size = 1296, alloc_size = 1296, alloc_offset = 4294966000, upload->offset = 322528, upload->size = 1048576, upload->buffer->width0 = 1048576, offset = 4294966000
util/u_upload_mgr.c:195:u_upload_alloc: Assertion `offset < upload->buffer->width0' failed.
Comment 10 Michal Suchanek 2011-09-19 15:36:08 UTC
Created attachment 51377 [details]
backtrace of glretrace

backtrace of glretrace on older unpatched mesa
Comment 11 Marek Olšák 2011-09-20 01:55:38 UTC
Can you send me the trace file that glretrace crashes with?
Comment 12 Marek Olšák 2011-09-26 09:13:55 UTC
The trace helped me to identify and fix the bug. Mesa master should work now. Could you test it?
Comment 13 Michal Suchanek 2011-09-27 03:40:53 UTC
Yes, with mesa master the crash no longer happens.

Thanks

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.