Opened 8 years ago

Closed 8 years ago

#10638 closed Bugs (fixed)

unhandled exception in async sink, created by init_from_settings

Reported by: pal666@… Owned by: Andrey Semashev
Milestone: To Be Determined Component: log
Version: Boost 1.56.0 Severity: Problem
Keywords: Cc:

Description

when settings file describes async file sink pointing to inaccessible location, async sink will be created without exception handler and will throw unhandled exception from async thread, killing application. easiest way to fix it is to add exception suppressor to async sinks, created by init_from_settings. i.e.

        else {
            p = init_formatter(boost::make_shared< sinks::asynchronous_sink< backend_t > >(backend), params, is_formatting_t());
            p -> set_exception_handler ( make_exception_suppressor ( ) );
	}

instead of

        else
            p = init_formatter(boost::make_shared< sinks::asynchronous_sink< backend_t > >(backend), params, is_formatting_t());

Change History (3)

comment:1 by Andrey Semashev, 8 years ago

You can register your own sink factory and configure the sink the way you need. The default factory doesn't set any exception handler because there is no good default one.

comment:2 by anonymous, 8 years ago

well, registering new factories will mean reimplement/copypaste all init_from_settings.cpp. btw we are not talking about default behavior, we are talking about the behavior, since it is impossible to add/change exception handler afterwards afaik. the only other way to change exception handler is ... to register new factories, which will not use code in question anyway. to me it looks like suppressing exception is much better than just killing application. we are talking about suppressing only those exceptions which otherwise will kill application. basically my suggestion boils down to "suppress instead of dying", i fail to see downsides.

comment:3 by Andrey Semashev, 8 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.