开发者

Segfault on AIX from large C++ library

开发者 https://www.devze.com 2023-01-14 01:48 出处:网络
I\'m trying to convert a Windows based library that my company produces to run on AIX. We are currently able to run it on Solaris and Linux but AIX is causing some additional issues. I\'mnot sure if t

I'm trying to convert a Windows based library that my company produces to run on AIX. We are currently able to run it on Solaris and Linux but AIX is causing some additional issues. I'm not sure if this is an OS setup issue or a coding issue but I'm trying the coding approa开发者_如何学编程ch first. The library exports some function using a C style convention from various modules. My test application can happily call some of the functions from some modules. There is one particular module, however, where every function segfaults. I've put a cout log message at the top of the function and this does not get hit. Looking at the coredump with dbx shows only that the fault is an illegal opcode 0x0. I've tried writing a test app that exports a function from a library and consumes it in an app which is fine. I've also tried writing a smaller test app which links in only the module containing the offending functions. In this case I can trigger the cout logging in the function. I have all optimisations switched off and the same compiler flags/versions for the app and the library.

It feels to me like the library is too large/exports too many functions and something is becoming corrupted/overflowing. I have no AIX experience so any pointers on whether this is likely or other avenues to persue for debugging this would be much appreciated.


The segfault is a red herring. The problem was that I had used -G on the linker line in the application. It seems that tells the linker that you're using run time linking and so it ignores undefined functions. When I called an underfined function which I hadn't dynamically linked in it was reasonably crashing. Once I took out the -G flag from the app I had a list of undefined symbols for the functions that were causing me problems. I'm still not completely clear why but trimming back linker flags a bit further seems to have resolved that as well (specifically I've removed the -shared flag I had on the library). I just need to statically link some third party libs in and I'll be all set.

0

精彩评论

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

关注公众号