Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS-X Linker warning when building with -DEXIV2_TEAM_USE_SANITIZERS=On #591

Closed
clanmills opened this issue Dec 10, 2018 · 5 comments
Closed
Assignees
Milestone

Comments

@clanmills
Copy link
Collaborator

In dealing with ASAN issues on MacOS-X, I see there are warning from the linker. I don't understand them. They were present in RC2. I have not searched further back. They might be benign.

[ 94%] Linking CXX shared library ../lib/libexiv2.dylib
ld: warning: direct access in function 'Exiv2::XmpProperties::printProperty(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Exiv2::Value const&)' from file 'CMakeFiles/exiv2lib.dir/properties.cpp.o' to global weak symbol 'typeinfo for std::__1::basic_ostream<char, std::__1::char_traits<char> >& (std::__1::basic_ostream<char, std::__1::char_traits<char> >&, Exiv2::Value const&, Exiv2::ExifData const*)' from file 'CMakeFiles/exiv2lib.dir/exif.cpp.o' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'Exiv2::Internal::CanonMakerNote::printCsLensType(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, Exiv2::Value const&, Exiv2::ExifData const*)' from file 'CMakeFiles/exiv2lib_int.dir/canonmn_int.cpp.o' to global weak symbol 'typeinfo for std::__1::basic_ostream<char, std::__1::char_traits<char> >& (std::__1::basic_ostream<char, std::__1::char_traits<char> >&, Exiv2::Value const&, Exiv2::ExifData const*)' from file 'CMakeFiles/exiv2lib.dir/exif.cpp.o' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'Exiv2::Internal::printMinoltaSonyLensID(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, Exiv2::Value const&, Exiv2::ExifData const*)' from file 'CMakeFiles/exiv2lib_int.dir/minoltamn_int.cpp.o' to global weak symbol 'typeinfo for std::__1::basic_ostream<char, std::__1::char_traits<char> >& (std::__1::basic_ostream<char, std::__1::char_traits<char> >&, Exiv2::Value const&, Exiv2::ExifData const*)' from file 'CMakeFiles/exiv2lib.dir/exif.cpp.o' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'Exiv2::Internal::printLensType(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, Exiv2::Value const&, Exiv2::ExifData const*)' from file 'CMakeFiles/exiv2lib_int.dir/pentaxmn_int.cpp.o' to global weak symbol 'typeinfo for std::__1::basic_ostream<char, std::__1::char_traits<char> >& (std::__1::basic_ostream<char, std::__1::char_traits<char> >&, Exiv2::Value const&, Exiv2::ExifData const*)' from file 'CMakeFiles/exiv2lib.dir/exif.cpp.o' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
[ 94%] Built target exiv2lib
Scanning dependencies of target exiv2
[ 95%] Building CXX object src/CMakeFiles/exiv2.dir/exiv2.cpp.o
[ 96%] Building CXX object src/CMakeFiles/exiv2.dir/actions.cpp.o
[ 97%] Building CXX object src/CMakeFiles/exiv2.dir/getopt.cpp.o
[ 98%] Building CXX object src/CMakeFiles/exiv2.dir/utils.cpp.o
[100%] Linking CXX executable ../bin/exiv2
[100%] Built target exiv2
686 rmills@rmillsmm:~/Downloads/foo/build $ cmake .. -DEXIV2_TEAM_USE_SANITIZERS=1 -DEXIV2_BUILD_SAMPLES=0 ; make 

I've tried to make sense of the first of the 4 errors and it becomes:

ld: warning: direct access in function 'Exiv2::XmpProperties::printProperty(basic_ostream, const&, Exiv2::Value const&)'
from file 'CMakeFiles/exiv2lib.dir/properties.cpp.o'
to global weak symbol
'typeinfo for std::__1::basic_ostream&, Exiv2::Value const&, Exiv2::ExifData const*)'
from file 'CMakeFiles/exiv2lib.dir/exif.cpp.o' means the weak means the weak symbol
cannot be overridden at runtime.

This was likely caused by different translation units being compiled with different visibility settings.

I don't know that this means. What I can see is that in properties.cpp, we have:

    std::ostream& XmpProperties::printProperty(std::ostream& os,
                                               const std::string& key,
                                               const Value& value)
    {
        PrintFct fct = printValue;
        if (value.count() != 0) {
            const XmpPrintInfo* info = find(xmpPrintInfo, key);
            if (info) fct = info->printFct_;
        }
        return fct(os, value, 0);
    }

I think he's complaining about fct (no pun intended).

@clanmills clanmills added this to the v0.27 milestone Dec 10, 2018
@clanmills clanmills self-assigned this Dec 10, 2018
@D4N
Copy link
Member

D4N commented Dec 10, 2018

I think the issue is related to visibility settings, as the linker notes itself:

This was likely caused by different translation units being compiled with different visibility settings.

You might want to check whether -fvisibility=hidden(not sure if that's the exact flag) is added to all translation units.

@clanmills
Copy link
Collaborator Author

Thanks, Dan. I'll look into that. I know @piponazo changed something concerning visibility a few months ago and said it was very interesting. I didn't believe him!

I expect you saw that our friend @cool-tomato reported 6 ASAN issues this morning. Crap. I'll deal with them and publish RC4 later in the week. For sure, I want to keep changes to the minimum possible, so a global change to visibility makes me nervous. I'll investigate visibility after I've deal with #590.

@clanmills
Copy link
Collaborator Author

I went searching for visibility in CMake. Guess what? @piponazo is the expert and answered a question on Stackoverflow about this several years ago. I don't see anything in CMakeLists.txt files about visibility.

https://stackoverflow.com/questions/17080869/what-is-the-cmake-equivalent-to-gcc-fvisibility-hidden-when-controlling-the-e

@piponazo
Copy link
Collaborator

The CMake configuration related to these visibility settings can be found in the file cmake/mainSetup.cmake:

set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)

I would not care too much about this at this moment. I have experienced these kind of warnings in different projects and none of them caused issues.

I could try to investigate it when I have some spare time, but I do not think we should worry about this on 0.27.

@clanmills
Copy link
Collaborator Author

I forgot to look in the cmake/*.cmake files for Visibility settings.

I think we do nothing about this. It's ugly, however there's no evidence that it's harmful. It's good to have this logged so we know where to restart the conversation. I saw it this morning and took a while to understand that it involves MacOS-X /Sanitizers and behaved like this in RC2 and RC3.

I'm going to close this.

Thanks to you and Dan for saying something about this.

You'll see that @cool-tomato dropped 6 poc's on RC3 this morning. I hope to close them by Wednesday and publish RC4 before the end of the week. If he (or other security folks) produce more POCs so late in the release, I will ask them about delaying the fixing for v0.27.1. No schedule for that yet - probably about 2019-03-31.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants