views:

69

answers:

1

I just moved a bunch of code into a separate framework. Nothing has changed in the code since the move and it compiles fine. However, on runtime, It crashes with "misaligned_stack_error". I've been looking around and some people are saying -mstackrealign fixes it, however I have added it to the C flags for both projects in Xcode and it still crashes, exactly the same way.

(Please note the format of the projects: a framework, loaded into a plugin, which installs into some 3rd party software).

I'd greatly appreciate some help to resolve this issue.

A: 

Without seeing either the code or the backtrace at the point of the crash, it is impossible to precisely say what is wrong.

Shooting a rubberband into the dark, I'd guess that something is either incorrectly dynamically generating a bit of code or there is a bit of buggy assembly in the mix somewhere. In either case, something isn't following the ABI of the architecture correctly, leading to the crash.

bbum
The reason I'm having so much trouble understanding this is if I take the exact same code and compile it into the same project instead of a separate framework, it works fine. No errors at all.
MJ
Then look very carefully at the compiler flags on one vs. the other. As well, consider that stack alignment problems may not cause explosions in non-dyld-trampoline contexts or if you never happen to touch libSystem.
bbum