На главную Наши проекты:
Журнал   ·   Discuz!ML   ·   Wiki   ·   DRKB   ·   Помощь проекту
ПРАВИЛА FAQ Помощь Участники Календарь Избранное RSS
msm.ru
[!] Как относитесь к модерированию на этом форуме? Выскажите свое мнение здесь
Модераторы: Qraizer
  
> Отладка symbol lookup error в рантайме , не было печали....
    Ух и давненько я сюда не заглядывал...

    Столкнулся со следующей проблемой и не пойму, как к ней подступиться.
    У меня есть код, использующий стороннюю библиотеку (OpenBabel). Все работало прекрасно. Тут выходит новая, вроде как backward compatible, версия этой библиотеки (4 года ее не обновляли), да и баги в ней очень противные пофиксили. Надо обновляться. Фигня вопрос. Снес старую (проверил, чтобы остатков не осталось), собрал и установил новую. Утилиты работают, все шикарно. Начинаю собирать свой проект. Собрался молча. Никаких замечаний. Проверяю работоспособность и тут сюрприз: "mmol2mol: symbol lookup error: mmol2mol: undefined symbol: _ZN9OpenBabel12OBConversion11SetInFormatEPNS_8OBFormatE" Как с этим бороться - не представляю.

    Все советы в интеренете говорят позапускать ldd и nm и внимательно посмотреть на вывод. У всех проблема оказывается либо в том, что скачан неправильный бинарник, либо в путях неправильная бибилотека, либо заморочки с распределенными файловыми системами из-за которых читается неправильная библиотека.

    У меня бибилиотека одна, и она правильная, свежесобранная. Старую я удалил. И заголовки от старой версии тоже удалял.

    Что пробовал:
    1. Перезагрузил машину (на всякий случай)
    2. ldd говорит, что все либы есть и более того, они в правильном месте
    ExpandedWrap disabled
      titov [ ~/et-build ]$ ldd bin/mmol2mol
              linux-vdso.so.1 (0x00007fffc8538000)
              libopenbabel.so.4 => /usr/lib/libopenbabel.so.4 (0x00007f9ba811a000)
              libboost_program_options.so.1.57.0 => /usr/lib/libboost_program_options.so.1.57.0 (0x00007f9ba7ea5000)
              libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f9ba7b9b000)
              libm.so.6 => /lib/libm.so.6 (0x00007f9ba7896000)
              libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f9ba7680000)
              libc.so.6 => /lib/libc.so.6 (0x00007f9ba72dd000)
              libdl.so.2 => /lib/libdl.so.2 (0x00007f9ba70d9000)
              libz.so.1 => /lib/libz.so.1 (0x00007f9ba6ebf000)
              librt.so.1 => /lib/librt.so.1 (0x00007f9ba6cb7000)
              libpthread.so.0 => /lib/libpthread.so.0 (0x00007f9ba6a9b000)
              /lib64/ld-linux-x86-64.so.2 (0x00007f9ba858a000)

    3. nm находит кучу неопределеных символов
    Скрытый текст
    ExpandedWrap disabled
      titov [ ~/et-build ]$ nm -D -u -C bin/mmol2mol  
                       U __cxa_allocate_exception
                       U __cxa_atexit
                       U __cxa_begin_catch
                       U __cxa_call_unexpected
                       U __cxa_end_catch
                       U __cxa_free_exception
                       U __cxa_guard_acquire
                       U __cxa_guard_release
                       U __cxa_pure_virtual
                       U __cxa_rethrow
                       U __cxa_throw
                       U free
                       w __gmon_start__
                       U __gxx_personality_v0
                       w _ITM_deregisterTMCloneTable
                       w _ITM_registerTMCloneTable
                       w _Jv_RegisterClasses
                       U __libc_start_main
                       U malloc
                       U memcmp
                       U memcpy
                       U memmove
                       U __powixf2
                       w __pthread_key_create
                       U sqrt
                       U strcmp
                       U strlen
                       U tolower
                       U _Unwind_Resume
                       U operator delete[](void*)
                       U operator delete(void*)
                       U boost::program_options::validators::check_first_occurrence(boost::any const&)
                       U boost::program_options::bool_switch()
                       U boost::program_options::to_internal(std::string const&)
                       U boost::program_options::variables_map::variables_map()
                       U boost::program_options::validation_error::get_template(boost::program_options::validation_error::kind_t)
                       U boost::program_options::options_description::add_options()
                       U boost::program_options::options_description::add(boost::program_options::options_description const&)
                       U boost::program_options::options_description::options_description(unsigned int, unsigned int)
                       U boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)
                       U boost::program_options::invalid_option_value::invalid_option_value(std::string const&)
                       U boost::program_options::error_with_option_name::error_with_option_name(std::string const&, std::string const&, std::string const&, int)
                       U boost::program_options::options_description_easy_init::operator()(char const*, boost::program_options::value_semantic const*, char const*)
                       U boost::program_options::options_description_easy_init::operator()(char const*, char const*)
                       U boost::program_options::positional_options_description::add(char const*, int)
                       U boost::program_options::positional_options_description::positional_options_description()
                       U boost::program_options::store(boost::program_options::basic_parsed_options<char> const&, boost::program_options::variables_map&, bool)
                       U boost::program_options::detail::cmdline::set_positional_options(boost::program_options::positional_options_description const&)
                       U boost::program_options::detail::cmdline::set_options_description(boost::program_options::options_description const&)
                       U boost::program_options::detail::cmdline::get_canonical_option_prefix()
                       U boost::program_options::detail::cmdline::run()
                       U boost::program_options::detail::cmdline::cmdline(std::vector<std::string, std::allocator<std::string> > const&)
                       U boost::program_options::notify(boost::program_options::variables_map&)
                       U boost::program_options::validate(boost::any&, std::vector<std::string, std::allocator<std::string> > const&, std::string*, int)
                       U boost::program_options::operator<<(std::ostream&, boost::program_options::options_description const&)
                       U OpenBabel::OBConversion::SetInFormat(char const*, bool)
                       U OpenBabel::OBConversion::SetInFormat(OpenBabel::OBFormat*, bool)
                       U OpenBabel::OBConversion::SetOutFormat(char const*, bool)
                       U OpenBabel::OBConversion::SetOutFormat(OpenBabel::OBFormat*, bool)
                       U OpenBabel::OBConversion::SetOutStream(std::ostream*, bool)
                       U OpenBabel::OBConversion::FormatFromExt(char const*)
                       U OpenBabel::OBConversion::Read(OpenBabel::OBBase*, std::istream*)
                       U OpenBabel::OBConversion::Write(OpenBabel::OBBase*, std::ostream*)
                       U OpenBabel::OBConversion::OBConversion(std::istream*, std::ostream*)
                       U OpenBabel::OBConversion::~OBConversion()
                       U OpenBabel::OBGenericData::OBGenericData(std::string, unsigned int, OpenBabel::DataOrigin)
                       U OpenBabel::OBMolAtomIter::OBMolAtomIter(OpenBabel::OBMol*)
                       U OpenBabel::OBMolAtomIter::operator++()
                       U OpenBabel::OBMolBondIter::OBMolBondIter(OpenBabel::OBMol&)
                       U OpenBabel::OBMolBondIter::operator++()
                       U OpenBabel::OBElementTable::GetSymbol(int)
                       U OpenBabel::OBSmartsPattern::GetUMapList()
                       U OpenBabel::OBSmartsPattern::Init(std::string const&)
                       U OpenBabel::OBSmartsPattern::Match(OpenBabel::OBMol&, bool)
                       U OpenBabel::OBSmartsPattern::~OBSmartsPattern()
                       U OpenBabel::OBMol::CreateAtom()
                       U OpenBabel::OBMol::CreateBond()
                       U OpenBabel::OBMol::BeginModify()
                       U OpenBabel::OBMol::DestroyAtom(OpenBabel::OBAtom*)
                       U OpenBabel::OBMol::DestroyBond(OpenBabel::OBBond*)
                       U OpenBabel::OBMol::CreateResidue()
                       U OpenBabel::OBMol::DestroyResidue(OpenBabel::OBResidue*)
                       U OpenBabel::OBMol::SetTotalCharge(int)
                       U OpenBabel::OBMol::DoTransformations(std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const*, OpenBabel::OBConversion*)
                       U OpenBabel::OBMol::Clear()
                       U OpenBabel::OBMol::Rotate(double const (*) [3])
                       U OpenBabel::OBMol::Rotate(double const*)
                       U OpenBabel::OBMol::AddBond(int, int, int, int, int)
                       U OpenBabel::OBMol::NewAtom()
                       U OpenBabel::OBMol::NewBond()
                       U OpenBabel::OBMol::SetTitle(char const*)
                       U OpenBabel::OBMol::EndModify(bool)
                       U OpenBabel::OBMol::OBMol()
                       U OpenBabel::OBMol::~OBMol()
                       U OpenBabel::OBAtom::GetPartialCharge()
                       U OpenBabel::OBAtom::GetVector()
                       U OpenBabel::OBAtom::SetVector(OpenBabel::vector3 const&)
                       U OpenBabel::OBBase::DeleteData(std::string const&)
                       U OpenBabel::OBBase::GetData(char const*)
                       U OpenBabel::OBBond::SetBondOrder(int)
                       U OpenBabel::OBBond::IsDouble()
                       U OpenBabel::OBBond::IsSingle()
                       U OpenBabel::OBBond::IsTriple()
                       U boost::program_options::abstract_variables_map::operator[](std::string const&) const
                       U boost::program_options::error_with_option_name::substitute_placeholders(std::string const&) const
                       U boost::program_options::error_with_option_name::what() const
                       U boost::program_options::value_semantic_codecvt_helper<char>::parse(boost::any&, std::vector<std::string, std::allocator<std::string> > const&, bool) const
                       U OpenBabel::OBMol::GetAtom(int) const
                       U OpenBabel::OBMol::GetBond(int) const
                       U OpenBabel::OBMol::GetTitle(bool) const
                       U OpenBabel::OBBond::IsAromatic() const
                       U OpenBabel::vector3::operator[](unsigned int) const
                       U std::string::find_last_of(char const*, unsigned long) const
                       U std::string::find_last_of(char const*, unsigned long, unsigned long) const
                       U std::string::find_first_of(char const*, unsigned long, unsigned long) const
                       U std::string::find_first_not_of(char const*, unsigned long, unsigned long) const
                       U std::string::substr(unsigned long, unsigned long) const
                       U std::string::compare(char const*) const
                       U std::string::compare(std::string const&) const
                       U std::logic_error::what() const
                       U std::runtime_error::what() const
                       U std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::str() const
                       U std::ctype<char>::_M_widen_init() const
                       U std::locale::operator==(std::locale const&) const
                       U std::istream& std::istream::_M_extract<double>(double&)
                       U std::istream& std::istream::_M_extract<unsigned int>(unsigned int&)
                       U std::ostream::put(char)
                       U std::ostream::flush()
                       U std::ostream& std::ostream::_M_insert<double>(double)
                       U std::ostream& std::ostream::_M_insert<unsigned long>(unsigned long)
                       U std::ostream::operator<<(int)
                       U std::string::_M_leak_hard()
                       U std::string::end()
                       U std::string::_Rep::_M_destroy(std::allocator<char> const&)
                       U std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&)
                       U std::string::append(unsigned long, char)
                       U std::string::append(char const*, unsigned long)
                       U std::string::append(std::string const&)
                       U std::string::assign(char const*)
                       U std::string::assign(char const*, unsigned long)
                       U std::string::assign(std::string const&)
                       U std::string::replace(unsigned long, unsigned long, char const*, unsigned long)
                       U std::string::reserve(unsigned long)
                       U std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, unsigned long, std::allocator<char> const&)
                       U std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)
                       U std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)
                       U std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&, unsigned long, unsigned long)
                       U std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()
                       U std::logic_error::logic_error(std::string const&)
                       U std::logic_error::~logic_error()
                       U std::logic_error::~logic_error()
                       U std::__basic_file<char>::~__basic_file()
                       U std::domain_error::domain_error(std::string const&)
                       U std::domain_error::~domain_error()
                       U std::basic_filebuf<char, std::char_traits<char> >::open(char const*, std::_Ios_Openmode)
                       U std::basic_filebuf<char, std::char_traits<char> >::close()
                       U std::basic_filebuf<char, std::char_traits<char> >::basic_filebuf()
                       U std::basic_filebuf<char, std::char_traits<char> >::~basic_filebuf()
                       U std::runtime_error::runtime_error(std::string const&)
                       U std::runtime_error::~runtime_error()
                       U std::basic_ifstream<char, std::char_traits<char> >::close()
                       U std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream(char const*, std::_Ios_Openmode)
                       U std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream()
                       U std::basic_ifstream<char, std::char_traits<char> >::~basic_ifstream()
                       U std::basic_ofstream<char, std::char_traits<char> >::basic_ofstream(char const*, std::_Ios_Openmode)
                       U std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::_M_sync(char*, unsigned long, unsigned long)
                       U std::invalid_argument::invalid_argument(std::string const&)
                       U std::invalid_argument::~invalid_argument()
                       U std::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_istringstream()
                       U std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream(std::_Ios_Openmode)
                       U std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_ostringstream()
                       U std::locale::classic()
                       U std::locale::locale()
                       U std::locale::~locale()
                       U std::bad_cast::~bad_cast()
                       U std::ios_base::Init::Init()
                       U std::ios_base::Init::~Init()
                       U std::ios_base::ios_base()
                       U std::ios_base::~ios_base()
                       U std::bad_alloc::~bad_alloc()
                       U std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >*)
                       U std::basic_ios<char, std::char_traits<char> >::clear(std::_Ios_Iostate)
                       U std::exception::~exception()
                       U operator new(unsigned long)
                       U std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)
                       U std::__throw_bad_cast()
                       U std::__throw_bad_alloc()
                       U std::_Rb_tree_decrement(std::_Rb_tree_node_base*)
                       U std::_Rb_tree_increment(std::_Rb_tree_node_base*)
                       U std::__throw_length_error(char const*)
                       U std::__throw_out_of_range_fmt(char const*, ...)
                       U std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)
                       U std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)
                       U std::basic_istream<char, std::char_traits<char> >& std::getline<char, std::char_traits<char>, std::allocator<char> >(std::basic_istream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, char)
                       U std::numpunct<char> const& std::use_facet<std::numpunct<char> >(std::locale const&)
                       U std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
                       U std::basic_istream<char, std::char_traits<char> >& std::operator>><char, std::char_traits<char> >(std::basic_istream<char, std::char_traits<char> >&, char&)
                       U std::basic_istream<char, std::char_traits<char> >& std::operator>><char, std::char_traits<char>, std::allocator<char> >(std::basic_istream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)

    4. собрал с -Wl,-no-undefined - ничего нового.
    5. Посмотрел на символы в библиотеке - действительно SetInFormat(OpenBabel::OBFormat*) в ней нет.
    ExpandedWrap disabled
      titov [ ~/avogadro-1.2.0/build ]$ nm -C /usr/lib/libopenbabel.so.4 | grep SetInFormat
      00000000001393c0 T OpenBabel::OBConversion::SetInFormat(char const*, bool)
      0000000000139210 T OpenBabel::OBConversion::SetInFormat(OpenBabel::OBFormat*, bool)

    В заголовке либы
    ExpandedWrap disabled
      bool            SetInFormat(const char* inID, bool isgzip=false);
      bool            SetInFormat(OBFormat* pIn, bool isgzip=false);


    Что я упускаю? На что посмотреть? Почему оно так скомпилировалось?
    Сообщение отредактировано: Yakudza -
      Рекомендовал бы не собирать непроверенную сборку на системе.
      Лучше поэксперементировать все в пользовательском каталоге, и только потом ставить от рута в систему.
      Ну а в данной ситуации - проверить бы, а все ли либы легли в системные каталоги, может они так и лежат в каталоге сборки? А если они лежат там - попробовать запускать скриптом, включив каталог сборки в LD_LIBRARY_PATH.

      И второй момент - почистить все кэши и привязки динамических либ утилитой ldconfig.
        Цитата JoeUser @
        Рекомендовал бы не собирать непроверенную сборку на системе.
        Лучше поэксперементировать все в пользовательском каталоге, и только потом ставить от рута в систему.
        Ну а в данной ситуации - проверить бы, а все ли либы легли в системные каталоги, может они так и лежат в каталоге сборки? А если они лежат там - попробовать запускать скриптом, включив каталог сборки в LD_LIBRARY_PATH.

        И второй момент - почистить все кэши и привязки динамических либ утилитой ldconfig.


        Ну да, в пользовательском каталоге экспериментировать надо было по-хорошему. Но откатить-то обратно не большая проблема будет.

        Либы просеярил. Перед сборкой обновленной версии все вычищал - там libopenbabel не было. Сейчас лежит. Да и ldd проблем с поиском либ не видит.

        ldconfig гонял. Не помогло.
          Сложно так сказать. Выложи линки (и/или необходимое на яндекс.диск) - попробую на своей тестовой машине собрать. Мож чего и обнаружится.
            Цитата JoeUser @
            Сложно так сказать. Выложи линки (и/или необходимое на яндекс.диск) - попробую на своей тестовой машине собрать. Мож чего и обнаружится.

            Окей... Сам думал сейчас виртуалку с голой системой стартануть и попробовать собрать.

            Отбой. Нашел проблему. В путях нашлась вторая версия утилит, не залогированная менеджером пакетов.

            Соответственно еще один шаг к отладке райнтайм ошибок - which'ем проверить запускается ли ожидаемый файл, или какой-то другой.
            Сообщение отредактировано: Yakudza -
              Цитата Yakudza @
              Соответственно еще один шаг к отладке райнтайм ошибок - which'ем проверить запускается ли ожидаемый файл, или какой-то другой.

              :wacko: ты сам понял что сказал? :D

              Добавлено
              мая русский не учила? :D
                Цитата Cfon @
                :wacko: ты сам понял что сказал? :D

                Ну в целом понял.
                Если после make install вбивается progname do someshit и оно внезапно не работает, то перед ldd /usr/bin/progname надо сделать which progname и удостовериться, что там реально /usr/bin/progname , а не остатки от какого-нибудь теста типа /home/username/bin/progname .
                  Цитата Yakudza @
                  Окей... Сам думал сейчас виртуалку с голой системой стартануть и попробовать собрать.

                  Ну так ... "хозяйке на заметку", рекомендую Manjaro Linux (Арч-based дистр).
                  Мне, как давнишнему пользователю Gentoo/Funtoo, этот дистрибут для "мгновенной" установки ну оч понравился :)
                    Цитата Cfon @
                    ты сам понял что сказал?

                    Цитата
                    which search for executables in the directories specified by the environment variable PATH. And if found out, the full pathname of this executable will be printed.

                    Если в $PATH у тебя есть /usr/local/bin и /home/user/work/bingo, и там, и там есть исполняемые файлы perl, то команда "witch perl" даст тебе полный путь к Перловке, которая при парсинге $PATH будет раньше (или даст единственный, если он один).

                    К примеру:
                    ExpandedWrap disabled
                      echo `witch perl`

                    Тебе напечатает "/usr/local/bin/perl"
                    0 пользователей читают эту тему (0 гостей и 0 скрытых пользователей)
                    0 пользователей:


                    Рейтинг@Mail.ru
                    [ Script execution time: 0,0423 ]   [ 16 queries used ]   [ Generated: 29.03.24, 07:31 GMT ]