开发者

Solaris 64 bit function pointer problem

Environment: OS: Sun Solaris 10 Processor: AMD 64 bit

I have an applicati开发者_StackOverflow中文版on which uses net-snmp library. The application is portable (code level) to various OS and processor. In net-snmp, you can register a logging callback (a function pointer) which gets called when something is to be logged.

The problem is that when I run the application, it seg faults when net-snmp tries to call the callback function I have registered. The callback address that gets registered is 0xffe30b90 but net-snmp tries to call 0xffffffff ffe30b90.

While investigating, I wrote another function in the same application and registered it. That function gets called properly but it's address shows as 0x52e060 (no leading ff).

I am not able to figure out what the problem here is. It seems to be something related to byte alignment or some pointer overflow problem.

Any pointers for further investigation will be appreciated. Thanks,

-Farooque


Sounds like somewhere the address is being passed through as a signed 32-bit int, which gets sign-extended when converting back to 64-bit, adding the extra 0xFFFF... bits. Make sure your code doesn't assume that int is the same size as a pointer anywhere, since the Solaris 64-bit ABI uses the “LP64” conventions, where int is 32-bits, while long and pointers are 64-bit.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜