[Insight-developers] itkWarningMacro not thread safe?

Williams, Norman K norman-k-williams at uiowa.edu
Wed May 2 13:10:00 EDT 2012


I didn't investigate the thread safety or lack thereof in
itk::OutputWindow, because I had a soft target to fix: It didn't make any
sense to warn the user every time TransformPoint got called in
BSplineDeformableTransform.


The actual problem was a 'double-free' error that only came up
intermittently; I didn't completely track it down, but it had to do with
temp objects being destroyed in the static method
itk::OutputWindow::OutputWindowDisplayText.

That's a singleton class, and if you look at
itk::OutputWindow::GetInstance() there's no interlock to keep multiple
threads from getting into the singleton instance creation code. That's
thread unsafe right there.  The calls to DisplayText don't have any
obvious problems with thread safety except that there's no thread safety
guaranteed for std::cout and std::cerr.

On 5/2/12 11:53 AM, "Bradley Lowekamp" <blowekamp at mail.nih.gov> wrote:

>Sorry, I prematurely hit the send button by mistake.
>I was going to go on to say that I don't have a good grasp of all the
>different Outputs and loggers and other display text like things that are
>in ITK, neither why they are all needed or which one to choose. Kris
>Zygmunt recently said she uses the logger for debug output because the
>output is multi-thread coherent, and not intermixed.
>
>I think that these methods should be concurrent thread safe.
>
>Brad
>
>
>On May 2, 2012, at 12:48 PM, Bradley Lowekamp wrote:
>
>
>Hello Kent,
>I have expected that method to be concurrent thread safe. That's
>impressive you were able to track that down. This would also mean that
>the DebugMacro is not thread safe either, which I would be quite
>surprised about.
>
>
>
>
>On May 2, 2012, at 12:38 PM, Williams, Norman K wrote:
>
>
>I was trying to chase down an intermittent bug in one of our programs,
>BRAINSTransformConvert.
>
>Without going into my particular issue too much, the problem is that
>BSplineDeformableTransform::TransformPoint prints out an warning message
>using itkWarningMacro, and the underlying print mechanism --
>itk::OutputWindow -- is apparently not thread safe.
>
>I logged a Jira ticket about it and will submit a patch
>https://itk.icts.uiowa.edu/jira/secure/EditIssue!default.jspa?id=18327
>
>My question is this: Is it reasonable to expect that itkWarningMacro (and
>behind the scenes itk::OutputWindow) be callable from a multithreaded
>filter?  If so, could itk::OutputWindow be made thread-safe?
>
>--
>Kent Williams norman-k-williams at uiowa.edu
>
>
>
>
>
>
>________________________________
>Notice: This UI Health Care e-mail (including attachments) is covered by
>the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is
>confidential and may be legally privileged.  If you are not the intended
>recipient, you are hereby notified that any retention, dissemination,
>distribution, or copying of this communication is strictly prohibited.
>Please reply to the sender that you have received the message in error,
>then delete it.  Thank you.
>________________________________
>_______________________________________________
>Powered by www.kitware.com <http://www.kitware.com>
>
>Visit other Kitware open-source projects at
>http://www.kitware.com/opensource/opensource.html
>
>Kitware offers ITK Training Courses, for more information visit:
>http://kitware.com/products/protraining.php
>
>Please keep messages on-topic and check the ITK FAQ at:
>http://www.itk.org/Wiki/ITK_FAQ
>
>Follow this link to subscribe/unsubscribe:
>http://www.itk.org/mailman/listinfo/insight-developers
>
>
>
>
>
>========================================================
>Bradley Lowekamp
>Medical Science and Computing for
>Office of High Performance Computing and Communications
>National Library of Medicine
>blowekamp at mail.nih.gov
>
>
>
>
>
>
>
>
>
>
>
>========================================================
>Bradley Lowekamp
>Medical Science and Computing for
>Office of High Performance Computing and Communications
>National Library of Medicine
>blowekamp at mail.nih.gov
>
>
>
>
>



________________________________
Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged.  If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited.  Please reply to the sender that you have received the message in error, then delete it.  Thank you.
________________________________


More information about the Insight-developers mailing list