Skip to content

SIGSEGV: invalid address at stop #195

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

Closed
tatouft opened this issue Sep 26, 2016 · 6 comments
Closed

SIGSEGV: invalid address at stop #195

tatouft opened this issue Sep 26, 2016 · 6 comments
Assignees
Labels

Comments

@tatouft
Copy link

tatouft commented Sep 26, 2016

My process exits with code 11. If I run it in the debugger, there is a "SIGSEGV: invalid address".
Here is the call stack:

pthread_join
log4cplus::thread::AbstractThread::join()
log4cplus::AsyncAppender::close()
log4cplus::spi::LoggerImpl::closeNestedAppenders()
log4cplus::Hierarchy::shutdown()
log4cplus::Hierarchy::~Hierarchy()

I have tried to simplify the code and here is what I have:

#include <iostream>
#include <log4cplus/logger.h>
#include <log4cplus/configurator.h>
int main()
{
  log4cplus::PropertyConfigurator config("/tmp/log.txt");
  config.configure();

  return 0;
}

And the config file:

log4cplus.rootLogger=OFF, A1
log4cplus.logger.L1=OFF, A5
log4cplus.logger.L2=OFF, A2
log4cplus.logger.L4=OFF, A3
log4cplus.logger.L6=OFF, A4
log4cplus.logger.L7=OFF, A1

log4cplus.appender.A1=log4cplus::AsyncAppender
log4cplus.appender.A1.Appender=log4cplus::ConsoleAppender

log4cplus.appender.A2=log4cplus::AsyncAppender
log4cplus.appender.A2.Appender=log4cplus::ConsoleAppender

log4cplus.appender.A3=log4cplus::AsyncAppender
log4cplus.appender.A3.Appender=log4cplus::ConsoleAppender

log4cplus.appender.A4=log4cplus::AsyncAppender
log4cplus.appender.A4.Appender=log4cplus::ConsoleAppender

log4cplus.appender.A5=log4cplus::AsyncAppender
log4cplus.appender.A5.Appender=log4cplus::ConsoleAppender

If I change the logger name L7 to L6, I don't have an error anymore.
Actually, if I delete any configuration line, I don't have an error anymore but I noticed that the name of my logger L7 worried.

I use log4cplus 1.1.3-0.4.rc3 on centos7

@wilx wilx self-assigned this Sep 27, 2016
@wilx
Copy link
Contributor

wilx commented Sep 27, 2016

Please try to modify the code and add log4cplus::Logger::shutdown(); before the return statement in your main().

@tatouft
Copy link
Author

tatouft commented Sep 27, 2016

I did but the error is still there, during shutdown call. I also tried to isolate the configurator into a block to be sure that the AppenderMap (contained in the configurator) was destructed before the call to shutdown but it didn't change anything.

@wilx wilx added the bug label Sep 29, 2016
@tatouft
Copy link
Author

tatouft commented Oct 3, 2016

I have test with log4cplus 1.2.0 and I have the same problem.

@tatouft
Copy link
Author

tatouft commented Oct 3, 2016

I fixed this adding one line in AsyncAppender::close method:

if(queue_thread->isRunning())

just before join call.

@wilx
Copy link
Contributor

wilx commented Oct 3, 2016

I do no entirely understand why this is happening but adding the condition before the close() call seems like something that should be there anyway. This is because if for some reason the thread is shut down in AsyncAppender::append() then without the conditional it will access NULL pointer.

wilx added a commit to wilx/log4cplus that referenced this issue Oct 3, 2016
Check if queue thread pointer is not NULL and if it is running before
trying to join it.
wilx added a commit to wilx/log4cplus that referenced this issue Oct 3, 2016
Check if queue thread pointer is not NULL and if it is running before
trying to join it.
wilx added a commit to wilx/log4cplus that referenced this issue Oct 3, 2016
Check if queue thread pointer is not NULL and if it is running before
trying to join it.
wilx added a commit that referenced this issue Oct 3, 2016
Merge fixes for #195 and SF#333.
wilx added a commit that referenced this issue Oct 3, 2016
wilx added a commit that referenced this issue Oct 3, 2016
Merge fixes for #195 and SF#333.
@wilx
Copy link
Contributor

wilx commented Oct 3, 2016

I have added the suggested fix to all active branches.

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

No branches or pull requests

2 participants