Skip to content

deadlock when app exit if AsyncChannel is used in the logging system #5228

@victor-tsang

Description

@victor-tsang

Describe the bug
Use poco/Util/samples/SampleApp/SampleApp with AsyncChannel configured in the properties file, the SampleApp will hang upon app termination.

To Reproduce

  1. build Util/samples/SampleApp
  2. run the SampleApp with its original SampleApp.properties file. It prints the environment and quit.
  3. replace the SampleApp.properties file with the content listed below. Run the SampleApp it will hang after output the environment logs.
# # This is a sample configuration file.
# logging.loggers.root.channel.class = ConsoleChannel
# logging.loggers.app.name = Application
# logging.loggers.app.channel = c1
# logging.formatters.f1.class = PatternFormatter
# logging.formatters.f1.pattern = [%p] %t
# logging.channels.c1.class = ConsoleChannel
# logging.channels.c1.formatter = f1



############################################
# logging
############################################
logging.loggers.root.channel = topChannel
logging.loggers.root.level = debug

logging.loggers.Application.name = Application
logging.loggers.Application.level = information

logging.channels.topChannel.class = AsyncChannel
logging.channels.topChannel.channel = c1
logging.channels.topChannel.priority = normal

logging.channels.c1.class = FileChannel
logging.channels.c1.formatter = f1

logging.channels.c1.path  = /tmp/PocoSampleApp.log
logging.channels.c1.times = local
logging.channels.c1.rotation = 5M
logging.channels.c1.archive = timestamp
logging.channels.c1.purgeAge = 3 months

logging.formatters.f1.class = PatternFormatter
logging.formatters.f1.pattern = %Y-%m-%d %H:%M:%S.%i %Z [%P] [%s] [%p] %t
logging.formatters.f1.times = local

Expected behavior
The app should log the contents into the log file and the app should be exit normally.

Logs
In FreeBSD environment, with poco debug build, the following message is observed:

[fai@ale ~/Lab/C++/VSCode_playground/out/build/Clang19 Debug]$ LD_LIBRARY_PATH=~/Library/usr/local/lib ./PocoSampleApp 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
mutex lock failed: Invalid argument [in file "/home/fai/Opensource/poco/git/poco/Foundation/src/ErrorHandler.cpp", line 43]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Please add relevant environment information:

  1. macOS Tahoe 26.3, Homebrew, Poco 1.15.0
  2. FreeBSD 14.3-RELEASE amd64, Poco 1.15.0 clone from git.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions