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

Segmentation fault of firebase while rotating orientation of IOS #126

Open
Katos opened this issue Dec 11, 2019 · 1 comment
Open

Segmentation fault of firebase while rotating orientation of IOS #126

Katos opened this issue Dec 11, 2019 · 1 comment

Comments

@Katos
Copy link

Katos commented Dec 11, 2019

Hey,
I had few cases of segmentation fault of Firebase on my ios crash log. Based on it, it was because of incorrect re-initalization of the firebase while screen was being rotated int he application.

Please fill in the following fields:

Firebase C++ SDK version: 6.7
Firebase plugins in use (Auth, Database, etc.): FirebaseAnalytics, FirebaseCore, FirebaseInstanceID
Additional SDKs you are using (Facebook, AdMob, etc.): qt 5.13.2 + qfirebase lib to use firebase with a qml https://github.com/Larpon/QtFirebase
Platform you are using the SDK on (Mac, Windows, or Linux): Mac
Platform you are targeting (iOS, Android, and/or desktop): IOS

Please describe the issue here:

Looks like it is related to changing orientation of app, during that time firebase is re-initialised and mutex is not correctly handled

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [81193]
Triggered by Thread: 0

Thread 0 name:
Thread 0 Crashed:
0   libsystem_pthread.dylib       	0x0000000190a693fc pthread_mutex_lock$VARIANT$mp + 0 (pthread_mutex.c:1491)
1   app                           	0x00000001025fda80 std::__1::__tree_const_iterator<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, flatbuffers::EnumVal*>, std::__1::__tree_node<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, flatbuffers::EnumVal*>, void*>*, long> std::__1::__tree<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, flatbuffers::EnumVal*>, std::__1::__map_value_compare<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, flatbuffers::EnumVal*>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, true>, std::__1::allocator<std::__1::__value_type<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, flatbuffers::EnumVal*> > >::find<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >+ 1694336 (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const + 12
2   app                           	0x0000000102601110 std::__1::enable_if<(__is_forward_iterator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*>::value) && (is_constructible<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::iterator_traits<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*>::reference>::value), void>::type std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::assign<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*>+ 1708304 (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) + 36
3   app                           	0x00000001025fcc18 firebase::analytics::Initialize+ 1690648 (firebase::App const&) + 84
4   app                           	0x000000010252bb9c QtFirebaseAnalytics::init() + 834460 (qtfirebaseanalytics.cpp:0)
5   app                           	0x00000001034ca364 QQmlExpression::QQmlExpression+ 17212260 () + 2224
6   app                           	0x000000010252ab5c QtFirebase::requestInit() + 830300 (qtfirebase.cpp:0)
7   app                           	0x00000001034ca364 QQmlExpression::QQmlExpression+ 17212260 () + 2224
8   app                           	0x00000001034cec90 QWindowSystemInterfacePrivate::GeometryChangeEvent::GeometryChangeEvent+ 17230992 (QWindow*, QRect const&) + 120
9   app                           	0x00000001034c2e9c QObject::event+ 17182364 (QEvent*) + 80
10  app                           	0x00000001034a26f8 QObject::userData+ 17049336 (unsigned int) const + 124
11  app                           	0x00000001034a22cc QVector<QObjectUserData*>::resize+ 17048268 (int) + 204
12  app                           	0x00000001034e7bc4 QEucJpCodec::QEucJpCodec+ 17333188 () + 932
13  app                           	0x000000010353c9d8 QIPAddressUtils::parseIp4Internal+ 17680856 (unsigned int&, char const*, bool) + 620
14  CoreFoundation                	0x0000000190cd0e1c __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 28 (CFRunLoop.c:1766)
15  CoreFoundation                	0x0000000190cd0b58 __CFRunLoopDoTimer + 880 (CFRunLoop.c:2357)
16  CoreFoundation                	0x0000000190cd0228 __CFRunLoopDoTimers + 276 (CFRunLoop.c:2512)
17  CoreFoundation                	0x0000000190ccb364 __CFRunLoopRun + 1920 (CFRunLoop.c:0)
18  CoreFoundation                	0x0000000190cca8bc CFRunLoopRunSpecific + 464 (CFRunLoop.c:3192)
19  GraphicsServices              	0x000000019ab36328 GSEventRunModal + 104 (GSEvent.c:2246)
20  UIKitCore                     	0x0000000194d606d4 UIApplicationMain + 1936 (UIApplication.m:4753)
21  app                           	0x0000000102606df0 qt_main_wrapper + 820
22  libdyld.dylib                 	0x0000000190b55460 start + 4

Please answer the following, if applicable:

Have you been able to reproduce this issue with just the Firebase C++ quickstarts (this GitHub project)? Crash happent to a user, but based on crash log it was during app being rotated and Fireabe was being reinitalized.

What's the issue repro rate? (eg 100%, 1/5 etc) Wasn't able to repro myself so would say "low".

@chkuang-g
Copy link
Contributor

Hi @Katos

It definitely not a good idea to call firebase::analytics::Initialize() more than once before terminating it.

Perhaps what we can do is early out if Analytics has been initialized already here.
https://github.com/firebase/firebase-cpp-sdk/blob/master/analytics/src/analytics_ios.mm#L122

At the mean time, I would recommend to change your code so that QtFirebaseAnalytics::init() won't be called when the screen orientation is changed.

Shawn

@chkuang-g chkuang-g transferred this issue from firebase/quickstart-cpp Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants