You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "atari83 (via GitHub)" <gi...@apache.org> on 2023/04/09 15:52:41 UTC

[GitHub] [logging-log4cxx] atari83 opened a new issue, #198: Some thread errors when user user send signals to application

atari83 opened a new issue, #198:
URL: https://github.com/apache/logging-log4cxx/issues/198

   Hello!
   First of all thanks to everybody who contributed to this great project! I really appreciate that.
   
   So, I have used log4cxx 0.11.0 in my application (running on FreeBSD 13.0 amd64), and just recently updated my application to use log4cxx 1.0.0 (with no change in my code and config). Everything looks fine which is amazing, however I noticed when user sends USR1 or USR2 signals or when application is getting exit there will be always some thread errors appears :
   
   ```
   __cxa_thread_call_dtors: dtr 0x803f37850 from unloaded dso, skipping
   __cxa_thread_call_dtors: dtr 0x803f37850 from unloaded dso, skipping
   __cxa_thread_call_dtors: dtr 0x803f37850 from unloaded dso, skipping
   __cxa_thread_call_dtors: dtr 0x803f37850 from unloaded dso, skipping
   __cxa_thread_call_dtors: dtr 0x803f37850 from unloaded dso, skipping
   __cxa_thread_call_dtors: dtr 0x803f37850 from unloaded dso, skipping
   __cxa_thread_call_dtors: dtr 0x803f37850 from unloaded dso, skipping
   __cxa_thread_call_dtors: dtr 0x803f37850 from unloaded dso, skipping
   ```
   
   Could anybody help me with this ?
   
   So, my usage from log4cxx is quite basic. I've multithreaded application, and use several global logger objects for logging information into log files.
   
   ```
   log4cxx::LoggerPtr _logger(log4cxx::Logger::getLogger("_logger1"));
   log4cxx::LoggerPtr _ss_logger(log4cxx::Logger::getLogger("_logger2"));
   log4cxx::LoggerPtr _misc_logger(log4cxx::Logger::getLogger("_logger3"));
   ```
   
   My configuration is stored in a .XML file and have created 3 RollingFileAppender with respective category to let each logger objects in my code to point to its specified config.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4cxx] atari83 closed issue #198: Some thread errors when user user send signals to application

Posted by "atari83 (via GitHub)" <gi...@apache.org>.
atari83 closed issue #198: Some thread errors when user user send signals to application
URL: https://github.com/apache/logging-log4cxx/issues/198


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4cxx] rm5248 commented on issue #198: Some thread errors when user user send signals to application

Posted by "rm5248 (via GitHub)" <gi...@apache.org>.
rm5248 commented on issue #198:
URL: https://github.com/apache/logging-log4cxx/issues/198#issuecomment-1565350899

   yes, that would be a problem.  There are only certain functions that you can call from a signal handler safely([here's a list](https://man7.org/linux/man-pages/man7/signal-safety.7.html)).  Whenever you get a signal, you have no idea where your program is, so it may or may not be in the middle of logging for example,


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4cxx] atari83 commented on issue #198: Some thread errors when user user send signals to application

Posted by "atari83 (via GitHub)" <gi...@apache.org>.
atari83 commented on issue #198:
URL: https://github.com/apache/logging-log4cxx/issues/198#issuecomment-1565684917

   Ok, as for workaround, I just moved the whole logic I had written inside signal callback function (including log4cxx function calls in between) to a main thread; and also made signal callback very minimum (basically a flag that shows a signal is received).
   Then in main thread I periodically (time-based) check if a signal is received, and if required then the logic will be executed.
   The thread errors are gone :)
   
   Thank you Robert for all supports.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4cxx] atari83 commented on issue #198: Some thread errors when user user send signals to application

Posted by "atari83 (via GitHub)" <gi...@apache.org>.
atari83 commented on issue #198:
URL: https://github.com/apache/logging-log4cxx/issues/198#issuecomment-1501222801

   Thank you for the response. You're correct, I always try to exit the program from non-main thread, thats for sure.
   So, I take that it is not harmful errors, is that right ?
   
   I'll read the manual and get back here to post the updates.
   
   Thanks again.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4cxx] rm5248 commented on issue #198: Some thread errors when user user send signals to application

Posted by "rm5248 (via GitHub)" <gi...@apache.org>.
rm5248 commented on issue #198:
URL: https://github.com/apache/logging-log4cxx/issues/198#issuecomment-1564686329

   Check the documentation for [pthread_sigmask](https://man7.org/linux/man-pages/man3/pthread_sigmask.3.html), that has an example for you that should be applicable to your situation.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4cxx] rm5248 commented on issue #198: Some thread errors when user user send signals to application

Posted by "rm5248 (via GitHub)" <gi...@apache.org>.
rm5248 commented on issue #198:
URL: https://github.com/apache/logging-log4cxx/issues/198#issuecomment-1564953854

   Unfortunately that's not something that I have much experience in.  Since it's not a log4cxx question, you may want to consider Stackoverflow.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4cxx] atari83 commented on issue #198: Some thread errors when user user send signals to application

Posted by "atari83 (via GitHub)" <gi...@apache.org>.
atari83 commented on issue #198:
URL: https://github.com/apache/logging-log4cxx/issues/198#issuecomment-1564504927

   Ok, I've read the online page about handling the signals when using log4cxx in multi-threaded app.
   But still I couldnt figure out how to handle the signals ...
   Based on proposed solutions, I think the 3rd one (Block signals in newly created threads, ensuring that signals can only be sent to threads of your choosing.) is suitable for my situation.
   
   Can anyone share a running code that show me how to do it ?
   
   Thanks.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4cxx] rm5248 commented on issue #198: Some thread errors when user user send signals to application

Posted by "rm5248 (via GitHub)" <gi...@apache.org>.
rm5248 commented on issue #198:
URL: https://github.com/apache/logging-log4cxx/issues/198#issuecomment-1501195099

   How are you exiting your application?  Are you calling `exit()` from a non-main thread?
   
   There are known issues that can sometimes occur when you call `exit()` from a thread that is not the main thread(and perhaps if you call `exit()` before all of the other threads have exited) due to how the loggers/library is initialized(using the `static` keyword).  Unfortunately there doesn't seem to be a way to fix that - when `exit()` is called, the destructors will run in some sort of random order, while other threads may or may not still be logging.
   
   The manual section on [threading](https://logging.staged.apache.org/log4cxx/latest_stable/threading.html) has some more information.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4cxx] atari83 commented on issue #198: Some thread errors when user user send signals to application

Posted by "atari83 (via GitHub)" <gi...@apache.org>.
atari83 commented on issue #198:
URL: https://github.com/apache/logging-log4cxx/issues/198#issuecomment-1564730533

   Robert, Thank you very much for your responses and following up this case with me.
   
   Regarding to using sigmask, I'm still confused ... This is my current implementation in my main for catching signals:
   
   ```
   	sigset_t ss;
   	sigemptyset(&ss);
   
   	sigaddset(&ss, SIGTERM);
   	sigaddset(&ss, SIGINT);
   	sigaddset(&ss, SIGUSR1);
   	sigaddset(&ss, SIGUSR2);
   
   	/* I've initially set the mask-mode to SIG_SETMASK, but same result when SIG_BLOCK is used */
   	pthread_sigmask( /*SIG_SETMASK*/ SIG_BLOCK, &ss, NULL );
   
   	while (1) {
   		int sig, *ps;
   		sigwait(&ss, &sig);
   
   		switch (sig) {
   			case SIGUSR1:
   			case SIGUSR2:
      			        // Here is where I create detached thread to process the event.
   				break;
   
   			case SIGINT:
   			case SIGTERM:
   				shutdown_func();
   				break;
   
   		}
   	}
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4cxx] atari83 commented on issue #198: Some thread errors when user user send signals to application

Posted by "atari83 (via GitHub)" <gi...@apache.org>.
atari83 commented on issue #198:
URL: https://github.com/apache/logging-log4cxx/issues/198#issuecomment-1565196825

   Thanks again :)
   
   For now, I dont have any choice but to stop calling log4cxx functions inside the signal callbacks (I need to build/release new version for my application soon). Later, I'll get back to this topic for a workaround.
   
   Thanks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org