Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXC BAD ACCESS Error on startup on device but not on simulator #36

Open
KenziTrader opened this issue Apr 27, 2016 · 4 comments
Open

EXC BAD ACCESS Error on startup on device but not on simulator #36

KenziTrader opened this issue Apr 27, 2016 · 4 comments

Comments

@KenziTrader
Copy link

I include ofxiOSBoost in my Xcode project. I also include QuantLib 1.6 from http://iphonesdkdev.blogspot.nl/2015/06/quantlib-16-framework-for-ios-and-mac.html. The project uses c++11 with libc++.

On the simulator the app runs without problems. On a real device it crashes with a EXC_BAD_ACCESS on startup. The stack trace is

#0  0x00000001000f7d88 in long double boost::math::detail::erf_imp<long double, boost::math::policies::policy<boost::math::policies::promote_float<false>, boost::math::policies::promote_double<false>, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy> >(long double, bool, boost::math::policies::policy<boost::math::policies::promote_float<false>, boost::math::policies::promote_double<false>, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy> const&, mpl_::int_<53> const&) at /Users/.../Frameworks/boost.framework/Headers/math/special_functions/erf.hpp:221
#1  0x00000001000f7b50 in boost::math::tools::promote_args<long double, float, float, float, float, float>::type boost::math::erf<long double, boost::math::policies::policy<boost::math::policies::promote_float<false>, boost::math::policies::promote_double<false>, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy> >(long double, boost::math::policies::policy<boost::math::policies::promote_float<false>, boost::math::policies::promote_double<false>, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy> const&) at /Users/.../Frameworks/boost.framework/Headers/math/special_functions/erf.hpp:1081
#2  0x00000001000f7ac0 in boost::math::detail::erf_initializer<long double, boost::math::policies::policy<boost::math::policies::promote_float<false>, boost::math::policies::promote_double<false>, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy>, mpl_::int_<53> >::init::do_init(mpl_::int_<53> const&) at /Users/.../Frameworks/boost.framework/Headers/math/special_functions/erf.hpp:1000
#3  0x00000001000f7a78 in boost::math::detail::erf_initializer<long double, boost::math::policies::policy<boost::math::policies::promote_float<false>, boost::math::policies::promote_double<false>, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy>, mpl_::int_<53> >::init::init() at /Users/.../Frameworks/boost.framework/Headers/math/special_functions/erf.hpp:994
#4  0x00000001000cd4e8 in boost::math::detail::erf_initializer<long double, boost::math::policies::policy<boost::math::policies::promote_float<false>, boost::math::policies::promote_double<false>, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy>, mpl_::int_<53> >::init::init() at /Users/.../Frameworks/boost.framework/Headers/math/special_functions/erf.hpp:993
#5  0x00000001000cba6c in __cxx_global_var_init.77 at /Users/.../Frameworks/boost.framework/Headers/math/special_functions/erf.hpp:1038
#6  0x00000001200508d8 in ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) ()
#7  0x0000000120050a78 in ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) ()
#8  0x000000012004c0dc in ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const*, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) ()
#9  0x000000012004b280 in ImageLoader::processInitializers(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) ()
#10 0x000000012004b334 in ImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) ()
#11 0x000000012003e088 in dyld::initializeMainExecutable() ()
#12 0x0000000120042130 in dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) ()
#13 0x000000012003d044 in _dyld_start ()

It fails when initializing the static vars in the erf.hpp file.

Has anybody any idea how to solve this?

@danoli3
Copy link
Owner

danoli3 commented Apr 27, 2016

Just a quick question what type of device?

(arm64 or armv7?) If you're not sure just say model.

Haven't seen this before no

On Thursday, 28 April 2016, Kenzi Trader [email protected] wrote:

I include ofxiOSBoost in my Xcode project. I also include QuantLib 1.6
from
http://iphonesdkdev.blogspot.nl/2015/06/quantlib-16-framework-for-ios-and-mac.html.
The project uses c++11 with libc++.

On the simulator the app runs without problems. On a real device it
crashes with a EXC_BAD_ACCESS on startup. The stack trace is

#0 0x00000001000f7d88 in long double boost::math::detail::erf_imp<long double, boost::math::policies::policy<boost::math::policies::promote_float, boost::math::policies::promote_double, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy> >(long double, bool, boost::math::policies::policyboost::math::policies::promote_float<false, boost::math::policies::promote_double, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policie
s::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy> const&, mpl_::int_<53> const&) at /Users/.../Frameworks/boost.framework/Headers/math/special_functions/erf.hpp:221
#1 0x00000001000f7b50 in boost::math::tools::promote_args<long double, float, float, float, float, float>::type boost::math::erf<long double, boost::math::policies::policy<boost::math::policies::promote_float, boost::math::policies::promote_double, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy> >(long double, boost::math::policies::policyboost::math::policies::promote_float<false, boost::math::policies::promote_double, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::
math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy> const&) at /Users/.../Frameworks/boost.framework/Headers/math/special_functions/erf.hpp:1081
#2 0x00000001000f7ac0 in boost::math::detail::erf_initializer<long double, boost::math::policies::policy<boost::math::policies::promote_float, boost::math::policies::promote_double, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy>, mpl_::int_<53> >::init::do_init(mpl_::int_<53> const&) at /Users/.../Frameworks/boost.framework/Headers/math/special_functions/erf.hpp:1000
#3 0x00000001000f7a78 in boost::math::detail::erf_initializer<long double, boost::math::policies::policy<boost::math::policies::promote_float, boost::math::policies::promote_double, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy>, mpl_::int_<53> >::init::init() at /Users/.../Frameworks/boost.framework/Headers/math/special_functions/erf.hpp:994
#4 0x00000001000cd4e8 in boost::math::detail::erf_initializer<long double, boost::math::policies::policy<boost::math::policies::promote_float, boost::math::policies::promote_double, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy>, mpl_::int_<53> >::init::init() at /Users/.../Frameworks/boost.framework/Headers/math/special_functions/erf.hpp:993
#5 0x00000001000cba6c in _cxx_global_var_init.77 at /Users/.../Frameworks/boost.framework/Headers/math/special_functions/erf.hpp:1038
#6 0x00000001200508d8 in ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) ()
#7 0x0000000120050a78 in ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) ()
#8 0x000000012004c0dc in ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int, char const
, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) ()
#9 0x000000012004b280 in ImageLoader::processInitializers(ImageLoader::LinkContext const&, unsigned int, ImageLoader::InitializerTimingList&, ImageLoader::UninitedUpwards&) ()
#10 0x000000012004b334 in ImageLoader::runInitializers(ImageLoader::LinkContext const&, ImageLoader::InitializerTimingList&) ()
#11 0x000000012003e088 in dyld::initializeMainExecutable() ()
#12 0x0000000120042130 in dyld::main(macho_header const, unsigned long, int, char const**, char const**, char const*, unsigned long) ()
#13 0x000000012003d044 in _dyld_start ()

It fails when initializing the static vars in the erf.hpp file.

Has anybody any idea how to solve this?


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#36

@KenziTrader
Copy link
Author

It's an iPhone 6 plus, so I geuss arm64.

@danoli3
Copy link
Owner

danoli3 commented Apr 27, 2016

Yeah that would be arm64.

Okay so I think I see the problem, the reason the simulator doesn't crash is for some reason your Xcode project is using a system installed version of boost (and likely the simulator one can handle the data type difference of potentially an older boost version)

Here is the clue '''&) at /Users/.../Frameworks/boost.framework/Headers/math/special_functions/erf.hpp'''

So when compiling for arm it is very sensetive to types, so likely the cause of the crash.

What you should check is how you have included the ofxiOSBoost library and make sure it is linked correctly, if it is then Xcode should look no further than the local include. If it still is occurring try and Uninstall and system level boost (usually installed by bootstrap or similiar)

@KenziTrader
Copy link
Author

KenziTrader commented Apr 28, 2016

I tried it on an iPhone 5 which is armv7 and had the same result. I removed the boost library on my Mac to make sure the linked version is used. I also print out the BOOST_VERSION macro to be sure to have the right library version. On the simulator everything runs fine.

This makes me think this is the infamous C++ static initialization order fiasco. A similar problem was reported here: http://stackoverflow.com/questions/28553143/exc-bad-access-error-building-quantlib-c-program-on-xcode but the solution doesn't work for me. Also there is no explanation what could be causing the problem to help me in the right direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants