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

Error when compiling with log4cxx 0.12.0 #50

Open
AchmadFathoni opened this issue Aug 14, 2021 · 4 comments · May be fixed by #54
Open

Error when compiling with log4cxx 0.12.0 #50

AchmadFathoni opened this issue Aug 14, 2021 · 4 comments · May be fixed by #54

Comments

@AchmadFathoni
Copy link

/home/toni/Documents/source/ros_ws/contribution/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp: In function ‘void ros::console::impl::initialize()’:
/home/toni/Documents/source/ros_ws/contribution/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp:169:23: error: cannot convert ‘ros::console::impl::ROSConsoleStdioAppender*’ to ‘log4cxx::AppenderPtr’ {aka ‘std::shared_ptr<log4cxx::Appender>’}
  169 |   logger->addAppender(new ROSConsoleStdioAppender);
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                       |
      |                       ros::console::impl::ROSConsoleStdioAppender*
In file included from /usr/include/log4cxx/spi/loggingevent.h:28,
                 from /usr/include/log4cxx/layout.h:29,
                 from /usr/include/log4cxx/appenderskeleton.h:28,
                 from /home/toni/Documents/source/ros_ws/contribution/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp:42:
/usr/include/log4cxx/logger.h:144:60: note:   initializing argument 1 of ‘virtual void log4cxx::Logger::addAppender(log4cxx::AppenderPtr)’
  144 |                 virtual void addAppender(const AppenderPtr newAppender);
      |                                          ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
/home/toni/Documents/source/ros_ws/contribution/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp: In function ‘void* ros::console::impl::getHandle(const string&)’:
/home/toni/Documents/source/ros_ws/contribution/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp:203:36: error: cannot convert ‘log4cxx::LoggerPtr’ {aka ‘std::shared_ptr<log4cxx::Logger>’} to ‘void*’ in return
  203 |   return log4cxx::Logger::getLogger(name);
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
      |                                    |
      |                                    log4cxx::LoggerPtr {aka std::shared_ptr<log4cxx::Logger>}
/home/toni/Documents/source/ros_ws/contribution/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp: In function ‘bool ros::console::impl::get_loggers(std::map<std::__cxx11::basic_string<char>, ros::console::levels::Level>&)’:
/home/toni/Documents/source/ros_ws/contribution/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp:219:120: error: conversion from ‘log4cxx::spi::LoggerRepositoryWeakPtr’ {aka ‘std::weak_ptr<log4cxx::spi::LoggerRepository>’} to non-scalar type ‘log4cxx::spi::LoggerRepositoryPtr’ {aka ‘std::shared_ptr<log4cxx::spi::LoggerRepository>’} requested
  219 | ::LoggerRepositoryPtr repo = log4cxx::Logger::getLogger(ROSCONSOLE_ROOT_LOGGER_NAME)->getLoggerRepository();
      |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~

/home/toni/Documents/source/ros_ws/contribution/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp: In function ‘void ros::console::impl::register_appender(ros::console::LogAppender*)’:
/home/toni/Documents/source/ros_ws/contribution/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp:361:23: error: cannot convert ‘ros::console::impl::Log4cxxAppender*’ to ‘log4cxx::AppenderPtr’ {aka ‘std::shared_ptr<log4cxx::Appender>’}
  361 |   logger->addAppender(g_log4cxx_appender);
      |                       ^~~~~~~~~~~~~~~~~~
      |                       |
      |                       ros::console::impl::Log4cxxAppender*
In file included from /usr/include/log4cxx/spi/loggingevent.h:28,
                 from /usr/include/log4cxx/layout.h:29,
                 from /usr/include/log4cxx/appenderskeleton.h:28,
                 from /home/toni/Documents/source/ros_ws/contribution/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp:42:
/usr/include/log4cxx/logger.h:144:60: note:   initializing argument 1 of ‘virtual void log4cxx::Logger::addAppender(log4cxx::AppenderPtr)’
  144 |                 virtual void addAppender(const AppenderPtr newAppender);
      |                                          ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
/home/toni/Documents/source/ros_ws/contribution/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp: In function ‘void ros::console::impl::deregister_appender(ros::console::LogAppender*)’:
/home/toni/Documents/source/ros_ws/contribution/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp:368:27: error: no matching function for call to ‘log4cxx::Logger::removeAppender(ros::console::impl::Log4cxxAppender*&)’
  368 |     logger->removeAppender(g_log4cxx_appender);
      |     ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/log4cxx/spi/loggingevent.h:28,
                 from /usr/include/log4cxx/layout.h:29,
                 from /usr/include/log4cxx/appenderskeleton.h:28,
                 from /home/toni/Documents/source/ros_ws/contribution/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp:42:
/usr/include/log4cxx/logger.h:1450:22: note: candidate: ‘virtual void log4cxx::Logger::removeAppender(log4cxx::AppenderPtr)’
 1450 |                 void removeAppender(const AppenderPtr appender);
      |                      ^~~~~~~~~~~~~~
/usr/include/log4cxx/logger.h:1450:55: note:   no known conversion for argument 1 from ‘ros::console::impl::Log4cxxAppender*’ to ‘log4cxx::AppenderPtr’ {aka ‘std::shared_ptr<log4cxx::Appender>’}
 1450 |                 void removeAppender(const AppenderPtr appender);
      |                                     ~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/log4cxx/logger.h:1456:22: note: candidate: ‘virtual void log4cxx::Logger::removeAppender(const LogString&)’
 1456 |                 void removeAppender(const LogString& name);
      |                      ^~~~~~~~~~~~~~
/usr/include/log4cxx/logger.h:1456:54: note:   no known conversion for argument 1 from ‘ros::console::impl::Log4cxxAppender*’ to ‘const LogString&’ {aka ‘const std::__cxx11::basic_string<char>&’}
 1456 |                 void removeAppender(const LogString& name);
      |                                     ~~~~~~~~~~~~~~~~~^~~~
/home/toni/Documents/source/ros_ws/contribution/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp: In function ‘void ros::console::impl::shutdown()’:
/home/toni/Documents/source/ros_ws/contribution/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp:378:27: error: no matching function for call to ‘log4cxx::Logger::removeAppender(ros::console::impl::Log4cxxAppender*&)’
  378 |     logger->removeAppender(g_log4cxx_appender);
      |     ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/log4cxx/spi/loggingevent.h:28,
                 from /usr/include/log4cxx/layout.h:29,
                 from /usr/include/log4cxx/appenderskeleton.h:28,
                 from /home/toni/Documents/source/ros_ws/contribution/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp:42:
/usr/include/log4cxx/logger.h:1450:22: note: candidate: ‘virtual void log4cxx::Logger::removeAppender(log4cxx::AppenderPtr)’
 1450 |                 void removeAppender(const AppenderPtr appender);
      |                      ^~~~~~~~~~~~~~
/usr/include/log4cxx/logger.h:1450:55: note:   no known conversion for argument 1 from ‘ros::console::impl::Log4cxxAppender*’ to ‘log4cxx::AppenderPtr’ {aka ‘std::shared_ptr<log4cxx::Appender>’}
 1450 |                 void removeAppender(const AppenderPtr appender);
      |                                     ~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/log4cxx/logger.h:1456:22: note: candidate: ‘virtual void log4cxx::Logger::removeAppender(const LogString&)’
 1456 |                 void removeAppender(const LogString& name);
      |                      ^~~~~~~~~~~~~~
/usr/include/log4cxx/logger.h:1456:54: note:   no known conversion for argument 1 from ‘ros::console::impl::Log4cxxAppender*’ to ‘const LogString&’ {aka ‘const std::__cxx11::basic_string<char>&’}
 1456 |                 void removeAppender(const LogString& name);
      |                                     ~~~~~~~~~~~~~~~~~^~~~
/home/toni/Documents/source/ros_ws/contribution/src/rosconsole/src/rosconsole/impl/rosconsole_log4cxx.cpp:386:58: error: base operand of ‘->’ has non-pointer type ‘log4cxx::spi::LoggerRepositoryWeakPtr’ {aka ‘std::weak_ptr<log4cxx::spi::LoggerRepository>’}
  386 |   log4cxx::Logger::getRootLogger()->getLoggerRepository()->shutdown();
      |                                                          ^~
make[2]: *** [rosconsole/CMakeFiles/rosconsole_log4cxx.dir/build.make:76: rosconsole/CMakeFiles/rosconsole_log4cxx.dir/src/rosconsole/impl/rosconsole_log4cxx.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:638: rosconsole/CMakeFiles/rosconsole_log4cxx.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

Since 0.12.0 all object of log4cxx are shared_ptr as stated in here. Any hint to fix this?

@AchmadFathoni
Copy link
Author

Solved by #51

@AchmadFathoni
Copy link
Author

Well, my PR just solves the compile error but not this runtime error

hread 1 "talker" received signal SIGSEGV, Segmentation fault.
0x00007ffff7c01b0a in std::_Sp_counted_ptr<ros::console::impl::Log4cxxAppender*, (__gnu_cxx::_Lock_policy)2>::_M_dispose (this=0x55555559b6a0) at /usr/include/c++/11.1.0/bits/shared_ptr_base.h:348
348           { delete _M_ptr; }

From this source code example

#include "ros/ros.h"

int main(int argc, char **argv)
{
  ros::init(argc, argv, "talker");
  ros::NodeHandle n;
}
  

For now I just switch to glog backend

@jspricke
Copy link
Member

The patch works fine in Debian and I can't reproduce your segfault.

@jspricke
Copy link
Member

I was able to reproduce the segfault in Debian unstable now and pushed a fix here: https://github.com/AchmadFathoni/rosconsole/pull/1

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

Successfully merging a pull request may close this issue.

2 participants