[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#536106: amd64 SEGVs due to dispatcher wrapper issue.



Package: mesa
Severity: important
Tags: patch


It appears that mesa 7.0.3, crashes with some application in amd64 mode.

Weh I traced this into mesa I found the wrapper was only fetching the
dispatch table thru _gl_DispatchTSD - although it had not been setup correctly
- (The magic was 0) . 

I compared this gdb trace to the same application which does not crash on
i386 and found that this _gl_DispatchTSD was also not set up on entry to the
wrapper in i386 mode.

Comparing the i386 code and the dispatch documentation shows that the
wrapper ought to be testing _glapi_Dispatch for NULL before getting the
dispatch table from the TSD info.

The attached patch changes the wrapper generator script to create code
which this extra check - and avoids unnecessary calls to pthread_getspecific()

Obviously this root cause of the segv could be an OpenGL programming
issue but it is confusing that the behaviour changes between architectures.


--- a/src/mesa/glapi/gl_x86-64_asm.py	2009-07-06 20:51:52.000000000 +0100
+++ b/src/mesa/glapi/gl_x86-64_asm.py	2009-07-06 22:17:59.000000000 +0100
@@ -166,7 +166,11 @@
 		print ''
 		print '\t.p2align\t4,,15'
 		print '_x86_64_get_dispatch:'
-		print '\tmovq\t_gl_DispatchTSD(%rip), %rdi'
+		print '\tmovq\t_glapi_Dispatch(%rip), %rax'
+		print '\ttestq\t%rax,%rax'
+		print '\tje\t1f'
+		print '\tret'
+		print '1:\tmovq\t_gl_DispatchTSD(%rip), %rdi'
 		print '\tjmp\tpthread_getspecific@PLT'
 		print ''
 		print '#elif defined(THREADS)'


- System Information:
Debian Release: 5.0.2
  APT prefers proposed-updates
  APT policy: (500, 'proposed-updates'), (500, 'stable'), (120, 'testing'), (20, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.26-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash



Reply to: