Boost logo

Threads-Devel :

Subject: [Threads-devel] Intel compiler issue and boost::thread
From: Andy Schneider (aschneider_at_[hidden])
Date: 2012-08-06 11:14:57


Hi,

We have some code that looks like this:

void
fileProcessorFunction ()
{
       // ... some implementation ...
}

Later we do:

new boost::thread(fileProcessorFunction);

We found, using Intel C++ compiler v12 on Windows with boost 1.47 that our application crashed in both Debug and Release.

This constructor ends up initializing thread_info with the result of make_thread_info thus:

template <class F>
thread(F&& f) :
  thread_info(make_thread_info(static_cast<F&&>(f)))
{
    start_thread()
}

which maps into assembly that takes f and then dereferences it and passes it to make_thread_info so the thread_data member ends up having not the function pointer f that it should have but instead a pointer equal to the first 4 bytes of what f was pointing at. Things go downhill from there.

We noticed that removing the static_cast (as below) resolved this issue.

template <class F>
thread(F&& f) :
  thread_info(f)
{
    start_thread()
}
Clearly there's a compiler defect at play but I was wondering why the static_cast <F&&> in the first place? Does this result in a valuable optimization that's subverted by removing it?

Thanks,

Andy

________________________________
This e-mail and its attachments are intended only for the individual or entity to whom it is addressed and may contain information that is confidential, privileged, inside information, or subject to other restrictions on use or disclosure. Any unauthorized use, dissemination or copying of this transmission or the information in it is prohibited and may be unlawful. If you have received this transmission in error, please notify the sender immediately by return e-mail, and permanently delete or destroy this e-mail, any attachments, and all copies (digital or paper). Unless expressly stated in this e-mail, nothing in this message should be construed as a digital or electronic signature.

________________________________
GETCO Europe Limited is a wholly-owned subsidiary of GETCO Holding Company, and is a company registered in England and Wales with Company Number 4663084 and registered office at 2nd floor, Vintners Place, 68 Upper Thames Street, London, EC4V 3BJ. GETCO Europe Limited is authorised and regulated by the Financial Services Authority.



Threads-Devel list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk