[ https://issues.apache.org/jira/browse/LOGCXX-394?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13903070#comment-13903070 ]
Thorsten Schöning commented on LOGCXX-394: ------------------------------------------ Don't we have two problems here? First there is the use of singletons ultimately causing the bug in some multithreaded environments, but second there are those tests or other users which want to compare the equality of levels by relying on the (former) implementation detail that all same levels are in fact the same object. I find the latter behavior to be wrong because the users shouldn't rely on those implementation details and would suggest changing this anyways. The use of singletons already seem to cause problems in some multithreaded environments (LOGCXX-322 and others), so do we really want to stick with those if we already know there are problems with thread safetiness? The only benefit using a singleton I see is if one has a use case where one needs to compare Levels a lot of times and is always using Level::get* instead of simply saving the result once. The only two things I see to stay with the singletons would be using a mutex for each to protect it's construction or using static data members. But the latter seems to already fail around LOGCXX-322 and others and all the Level::get* methods were introduced in rev 308676 because of seg faults in using static data members. And I don't think introducing mutexes is worth the effort. > Levels are not thread safe > -------------------------- > > Key: LOGCXX-394 > URL: https://issues.apache.org/jira/browse/LOGCXX-394 > Project: Log4cxx > Issue Type: Bug > Components: Appender > Environment: Windows 7, Visual Studio 2010 SP1 > Reporter: Petro Protsyk > Assignee: Thorsten Schöning > Priority: Minor > Labels: thread-safety > > Level.cpp. All default level variables are function static. This is not > thread safe, especially in Visual C++ compiler. > Here is code to reproduce the issue in VC++ 2010: > Concurrency::parallel_for (int(0), int(10), [&](int i) > { > if (::log4cxx::Level::getWarn() == NULL) > { > throw std::exception(); > } > }); -- This message was sent by Atlassian JIRA (v6.1.5#6160)