“Illegal instruction: 4” shows up in OS X Lion

风流意气都作罢 提交于 2019-12-03 12:10:42

I encountered this issue when building a product on Mountain Lion (10.8,) and then running on Lion. (10.7). The cause was that I made some changes to my build environment.

(I'm using mkbundle to ship a product that uses Mono.)

The fix was very simple, I had to tell clang that generated binaries need to work on OSX 10.6. I added the following argument to clang:

-mmacosx-version-min=10.6

Problem solved!

In OS X Lion (but also 10.5) the stack size hard limit is 65532 kbytes (just under 64 MiB). This can be seen with:

bswift$ ulimit -Hs
65532

Even as root, I couldn't increase this value.

The soft limit defaults to only 8 MiB:

bswift$ ulimit -Ss
8192

Try raising the value to this maximum before starting you application:

bswift$ ulimit -Ss unlimited
bswift$ ulimit -Ss
65532

Note: segmentation fault (SIGSEGV) (number 11) you observed is the signal sent to the process when the stack limit is exceeded according to man setrlimit

Note: Since the ulimit command needs to be a shell builtin, you will find it documented in man bash

This could be a permissions issue.

To diagnose further, run your program from the terminal with sudo dtruss prefixed. See which syscall it runs before throwing the error.

Example: sudo dtruss /path/to/application

You can also diagnose it with the Xcode or GDB debuggers.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!