Bug 91039

Summary: [d3d9] D3D9 state tracker crashes due to stack misalignment if Mesa is compiled with -mfpmath=sse
Product: Mesa Reporter: Itzamna <xamaniqinqu>
Component: Gallium/StateTracker/galliumnineAssignee: mesa-dev
Status: RESOLVED MOVED QA Contact: mesa-dev
Severity: normal    
Priority: medium CC: r9ku1q, xamaniqinqu
Version: 10.6   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description Itzamna 2015-06-20 19:06:20 UTC
Description: 
The "Nine" D3D9 state tracker crashes when Wine loads any D3D program if Mesa is compiled with -mfpmath=sse. This is because the Linux ABI assumes a stack alignment to 16 bytes, whereas the Win32 ABI assumes a stack alignment to 4 bytes. This causes a stack misalignment and thus a general protection fault.


Additional information: 
Also see the following external bug reports:

https://bugs.winehq.org/show_bug.cgi?id=22475
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=40838


Specifications:
OS: Gentoo GNU/Linux x86_64
Kernel version: Linux 4.0.4-hardened-r3
Mesa version: 10.6.0


Solution:
The crashes no longer occur when Mesa's stack is realigned to 4 bytes. Therefore, always pass -mstackrealign to CFLAGS if -mfpmath=sse is enabled; this should probably be handled in the configure script.
Comment 1 Itzamna 2015-06-20 19:27:19 UTC
(In reply to Itzamna from comment #0)

> Solution:
> The crashes no longer occur when Mesa's stack is realigned to 4 bytes.
> Therefore, always pass -mstackrealign to CFLAGS if -mfpmath=sse is enabled;
> this should probably be handled in the configure script.

Erratum: -mstackrealign realigns the incoming (4 byte-aligned) stack to 16 bytes, see https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html .
Comment 2 Axel Davy 2018-05-09 06:10:53 UTC
To my knowledge we've been handling function stack realignment in nine for a few years now, and thus I assume this issue is solved. Do you confirm ?
Comment 3 GitLab Migration User 2019-09-18 17:52:49 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/mesa/mesa/issues/122.

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.