Bug 1196228

Summary: [GSS] (6.4.z) ConsoleAppenders can deadlock if included in application log4j configs
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Aaron Ogburn <aogburn>
Component: LoggingAssignee: Lin Gao <lgao>
Status: CLOSED CURRENTRELEASE QA Contact: Nikoleta Hlavickova <nziakova>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.4.0CC: bbaranow, bmaxwell, cdewolf, chaowan, csutherl, jawilson, joallen, lgao, sfikes
Target Milestone: CR1   
Target Release: EAP 6.4.2   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1211155, 1219165    

Description Aaron Ogburn 2015-02-25 14:24:18 UTC
Description of problem:

While the use of ConsoleAppender in Log4J application logging configurations is discouraged, JBoss could probably do a better job of managing its use.

Currently it's possible to encounter a deadlock if thread A invokes System.out.println() and thread B invokes Logger.info(). Thread A will get the lock on System.out (a java.io.PrintWriter), but then thread B will get the lock on the org.apache.log4j.ConsoleAppender. Then each thread is waiting on the other's lock.

Comment 1 Aaron Ogburn 2015-02-25 14:25:27 UTC
Work around is to not use ConsoleAppenders in app log4js or them in async appender/handlers.

Comment 2 James Perkins 2015-02-25 18:32:40 UTC
We'd have to fork the ConsoleAppender to make this work properly since each append invocation uses System.xxx.write(). We'd need to update it to capture System.out and System.err in a static variable to ensure it would work correctly.

Comment 4 Aaron Ogburn 2015-03-06 15:36:05 UTC
If we don't want to go for a ConsoleAppender fork to resolve the deadlock, perhaps we can at least add a warn to notify that a deadlock is likely with the application level ConsoleAppender?

Comment 19 Nikoleta Hlavickova 2015-06-23 10:54:52 UTC
Verified with EAP 6.4.2.CP.CR1 using attached reproducer.

Comment 20 Petr Penicka 2017-01-17 10:17:07 UTC
Retroactively bulk-closing issues from released EAP 6.4 cumulative patches.

Comment 21 Petr Penicka 2017-01-17 10:17:13 UTC
Retroactively bulk-closing issues from released EAP 6.4 cumulative patches.