Skip to content

stdcall on OS X is broken

1288 is SIGBUSing on OS X 32. The symptom is that task in resumeThread is 3 (the argument we pass). Here's what I think's going on:

On Linux re generate:

0x0804a746 <s1bE_info+30>:      call   0x80839a0 <suspendThread>
0x0804a74b <s1bE_info+35>:      add    $0x4,%esp
0x0804a74e <s1bE_info+38>:      mov    0x40(%esp),%ecx
0x0804a752 <s1bE_info+42>:      push   %ecx
0x0804a753 <s1bE_info+43>:      mov    %eax,0x50(%esp)
0x0804a757 <s1bE_info+47>:      call   0x804a8d0 <test>
0x0804a75c <s1bE_info+52>:      mov    0x4c(%esp),%eax
0x0804a760 <s1bE_info+56>:      push   %eax
0x0804a761 <s1bE_info+57>:      call   0x8083aa4 <resumeThread>

We save %eax to 0x50(%esp), do the call (during which %esp is increased by 4), and then read %eax back from 0x4c(%esp).

And on the Mac:

0x00002282 <s1bi_info+38>:      call   0x240cc4 <suspendThread>
0x00002287 <s1bi_info+43>:      add    $0x10,%esp
0x0000228a <s1bi_info+46>:      sub    $0xc,%esp
0x0000228d <s1bi_info+49>:      mov    0x4c(%esp),%ecx
0x00002291 <s1bi_info+53>:      push   %ecx
0x00002292 <s1bi_info+54>:      mov    %eax,0x5c(%esp)
0x00002296 <s1bi_info+58>:      call   0x242a <test>
0x0000229b <s1bi_info+63>:      sub    $0xc,%esp
0x0000229e <s1bi_info+66>:      mov    0x58(%esp),%eax
0x000022a2 <s1bi_info+70>:      push   %eax
0x000022a3 <s1bi_info+71>:      call   0x240db1 <resumeThread>

We try to do the same thing, but this instruction:

0x0000229b <s1bi_info+63>:      sub    $0xc,%esp

alters %esp in-between us saving and restoring %eax.

Trac metadata
Trac field Value
Version 7.0.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Unknown/Multiple
Architecture Unknown/Multiple
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information