summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartosz Tomczyk <[email protected]>2017-04-03 21:12:54 +0200
committerTimothy Arceri <[email protected]>2017-04-04 09:39:03 +1000
commit95720851e21acf531d2e6a90c95f5eede95b8372 (patch)
tree0262d74b00eb74e4bfe63dbc5920c6be9769eadd
parentbcb63ee63e0a8bec837ee3712e1d306409455a4a (diff)
mesa/glthread: fix misaligned address access
Address sanitizer reports lot of misaligned access: SUMMARY: AddressSanitizer: undefined-behavior main/marshal.c:276:31 in main/marshal.c:276:31: runtime error: load of misaligned address 0x631000104866 for type 'const GLuint' (aka 'const unsigned int'), which requires 4 byte alignment 0x631000104866: note: pointer points here 92 88 00 00 00 00 00 00 4a 03 0c 00 93 88 00 00 00 00 00 00 02 01 0c 00 40 8d 00 00 00 00 00 00 ^ SUMMARY: AddressSanitizer: undefined-behavior main/marshal_generated.c:28725:12 in main/marshal_generated.c:28726:12: runtime error: member access within misaligned address 0x6310003fc874 for type 'struct marshal_cmd_VertexAttribPointer', which requires 8 byte alignment 0x6310003fc874: note: pointer points here 01 00 00 00 7a 02 20 00 00 00 00 00 be be be be be be be be be be be be be be be be be be be be ^ SUMMARY: AddressSanitizer: undefined-behavior main/marshal_generated.c:28726:12 in main/marshal_generated.c:28726:12: runtime error: store to misaligned address 0x6310003fc87c for type 'GLint' (aka 'int'), which requires 8 byte alignment 0x6310003fc87c: note: pointer points here 00 00 00 00 be be be be be be be be be be be be be be be be be be be be be be be be be be be be Reviewed-by: Timothy Arceri <[email protected]>
-rw-r--r--src/mesa/main/marshal.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/mesa/main/marshal.h b/src/mesa/main/marshal.h
index 2f1509b2d55..4842d27eebf 100644
--- a/src/mesa/main/marshal.h
+++ b/src/mesa/main/marshal.h
@@ -32,6 +32,7 @@
#include "main/glthread.h"
#include "main/context.h"
+#include "main/macros.h"
struct marshal_cmd_base
{
@@ -55,15 +56,16 @@ _mesa_glthread_allocate_command(struct gl_context *ctx,
{
struct glthread_state *glthread = ctx->GLThread;
struct marshal_cmd_base *cmd_base;
+ const size_t aligned_size = ALIGN(size, 8);
if (unlikely(glthread->batch->used + size > MARSHAL_MAX_CMD_SIZE))
_mesa_glthread_flush_batch(ctx);
cmd_base = (struct marshal_cmd_base *)
&glthread->batch->buffer[glthread->batch->used];
- glthread->batch->used += size;
+ glthread->batch->used += aligned_size;
cmd_base->cmd_id = cmd_id;
- cmd_base->cmd_size = size;
+ cmd_base->cmd_size = aligned_size;
return cmd_base;
}