issue with mutex.lock in _Task_impl_base on iOS version 7.11 throwing system exception with EINVAL

Jun 18, 2014 at 2:19 PM
Edited Jun 18, 2014 at 5:05 PM
I am running into a crash with Casablanca on iOS v7.1.1, (note: this was not an issue on 7.0.4.) The first line in _Task_impl::_TransitionedToStart() in pplxtasks.h where the _LockHolder is constructed an exception is being thrown with the system_error of EINVAL ( invalid value. ) I think this may be due to this: http://comments.gmane.org/gmane.comp.compilers.llvm.bugs/29379. So as the last line of the c-tor in _Task_impl_base I tried constructing a ::pplx::extensibility::scoped_critical_section_t for force a lock and unlock of the mutex so that it gets init'ed correctly, but still doesn't appear to fix the problem. Has anyone else run into anything similar to this?

Thanks in advance
Coordinator
Jun 18, 2014 at 11:02 PM
Hi Les,

Thanks for finding this issue. Reading through the bug report you've listed, it comments that
The correct, portable way to initialize a pthread_mutex member variable is with pthread_mutex_init() (as the libstdc++ and boost mutex implementations do).
Since we have boost available, perhaps replacing the std::mutex with boost::mutex will fix the issue?

I've copied the issue into a workitem for tracking: https://casablanca.codeplex.com/workitem/199

Sincerely,
roschuma
Jun 18, 2014 at 11:43 PM
I have just pulled the 2.1 version of cpprest. Once I verify the bug is still present. If it is will try that in pplxlinux.hi will let you know what I find.

Thanks

-Leslie


roschuma <[email removed]> wrote:

From: roschuma

Hi Les,

Thanks for finding this issue. Reading through the bug report you've listed, it comments that
The correct, portable way to initialize a pthread_mutex member variable is with pthread_mutex_init() (as the libstdc++ and boost mutex implementations do).
Since we have boost available, perhaps replacing the std::mutex with boost::mutex will fix the issue?

I've copied the issue into a workitem for tracking: https://casablanca.codeplex.com/workitem/199

Sincerely,
roschuma
Jun 19, 2014 at 11:05 PM
Changing it to use boost::mutex instead of std::mutex seems to do the trick. In case anyone is interested, I pushed the changes I needed to make pplx/pplxlinux.h to my fork in the iOSMutexFix branch at

https://casablanca.codeplex.com/SourceControl/network/forks/Les1966/unreferencedparameterfix2/changeset/0a867a340b28a53d7b2c2f9407b95bade7a866f6.

Additionally, if you use this change, you will need to build the boost chrono library as well as the others mentioned in the build instructions for iOS

-Leslie
Marked as answer by Les1966 on 6/19/2014 at 3:05 PM
Coordinator
Jun 19, 2014 at 11:07 PM
Thank you very much for finding and fixing this; I'll look into merging the changes back into our development branch.

Sincerely,
roschuma