[cfe-dev] Weird crash, linkage problems, inconsistent size of llvm::sys::fs::file_status

Nickolas Pohilets pohilets at gmail.com
Wed Mar 28 15:14:32 PDT 2012


Hello,
I'm currently trying to build Deobjectivizer utility by Charles Davis
(http://www.winehq.org/pipermail/wine-devel/2011-April/089657.html).
Its sources are almost a year old, so I had to do lots of minor fixes
in order to update its sources to match latest version of the Clang
and finally I'm able to link and run it, but application crashes on
startup.

My research shows that crash is caused by stack corruption - stack
variable of type llvm::sys::fs::file_status is passed by reference to
the function llvm::sys::fs::directory_entry::status() and then to
llvm::sys::fs::status(), where it is modified.

At caller side
sizeof(llvm::sys::fs::file_status) = 12:
* sizeof(st_dev) = 4
* sizeof(st_ino) = 4
* sizeof(Type) = 4

But inside llvm::sys::fs::status() its size is different -
sizeof(llvm::sys::fs::file_status) = 24:
* sizeof(st_dev) = 4
* 4 bytes - alignment on 8-byte boundary
* sizeof(st_ino) = 8
* sizeof(Type) = 4
* 4 bytes - alignment on 8-byte boundary

So the problem is in size of st_ino field (of type ino_t).

I'm running Mac OS X 10.6.8, 64-bit. I'm building Deobjectivizer from
XCode project using XCode 4.0.2, i686-apple-darwin10-llvm-g++-4.2
(GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.9), with
Mac OS X 10.6 SDK
Clang was build from sources with default configuration and installed
to default locations.

What did I do wrong? How should I reconfigure Clang or the project to
make them compatible?

Nickolas



More information about the cfe-dev mailing list