EXC_BAD_ACCESS (code=EXC_I386_GPFLT) on app foreground

3650
4
05-11-2018 06:50 PM
JakeShapley
New Contributor III

I've been chasing this bug for weeks. Getting crash due to EXC_BAD_ACCESS (code=EXC_I386_GPFLT) frequently (~25% of the time) when backgrounding and re-foregrounding iOS app. We are using iOS Runtime 100.2.1. Crash is occurring across device types and iOS versions. Any help in identifying a workaround would be appreciated.

Our implementation:

1) all tables and layers instantiated from local runtime replica geodatabase (regsGDB.geodatabase):

    fileprivate func initGDB() -> Void {

        self.deinitGDB()

        regsGDB = AGSGeodatabase(fileURL: FileUtil.urlFor(GlobalConstants.fileNames.REGS_WORKING_GDB)!)

        regsGDB.load(completion: {[weak self] (error: Error?) in

            if (error != nil) {

                self?.regsGDBLoaded = false

                self?.disableFeatureInteraction()

                os_log("Error loading geodatabase", [error?.localizedDescription])

            } else {

                self?.loadLayers()

            }})

    }

2) strong references to tables and layers, with nil checks on regsGDB before calling load (for tables and layers):

fileprivate func loadLayers() -> Void {

        if regsGDB != nil && regsGDB.loadStatus == .loaded {

            self.countiesTable = (regsGDB.geodatabaseFeatureTable(byServiceLayerID: GlobalConstants.IDs.COUNTIES_LAYER_INDEX)!) as AGSFeatureTable

            self.countiesLayer = AGSFeatureLayer(featureTable: (self.countiesTable)!)

            self.countiesLayer.renderer = EsriUtil.municipalityPolyRenderer

            self.countiesLayer.labelsEnabled = true

            self.countiesLayer.selectionColor = UIColor.cyan

            self.countiesLayer.selectionWidth = 5

            self.countiesLayer.minScale = 6000000

            self.map.operationalLayers.add(self.countiesLayer)

            

            self.citiesTable = (regsGDB.geodatabaseFeatureTable(byServiceLayerID: GlobalConstants.IDs.CITIES_LAYER_INDEX)!) as AGSFeatureTable

            self.citiesLayer = AGSFeatureLayer(featureTable: (self.citiesTable)!)

            self.citiesLayer.renderer = EsriUtil.municipalityPolyRenderer

            self.citiesLayer.labelsEnabled = true

            self.citiesLayer.selectionColor = UIColor.cyan

            self.citiesLayer.selectionWidth = 5

            self.citiesLayer.minScale = 6000000

            self.map.operationalLayers.add(self.citiesLayer)

.

.

.

3) deinit by manually removing all operationalLayers and tables, nilling out all layers and tables prior to reinitializing and loading gdb, tables and layers: 

fileprivate func deinitGDB() -> Void {

        // remove and nil out the layers

        self.map.operationalLayers.removeAllObjects()

        self.countiesLayer = nil

        self.citiesLayer = nil

       .

       .

       .

        // remove and nil out the tables

        self.map.tables.removeAllObjects()

        self.countiesTable = nil

        self.citiesTable = nil

       .

       .

       .

        if regsGDB != nil {

            switch regsGDB.loadStatus {

            case .loading:

                regsGDB.cancelLoad()

                break

            default:

                break

            }

            regsGDB.close()

        }

        regsGDBLoaded = false

    }

I have not been able to reproduce by stepping through/over. Thoughts?

Attached is a debug log of ObjC and C++ Exceptions encountered on foregrounding repeatedly in the same session. Note, crash only occurs when breakpoints are turned off (see crash again in last backtrace in this file).

Here's a back-trace of the crash (full stack is attached):

* thread #67, queue = 'com.apple.root.default-qos', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)

  * frame #0: 0x000000010f2574b4 ArcGIS`columnMem + 88

    frame #1: 0x000000010f257535 ArcGIS`ags_sqlite3_column_bytes + 15

    frame #2: 0x000000010e87a38d ArcGIS`Esri_runtimecore::Geodatabase::Sqlite_command::get_as_text(int) + 77

    frame #3: 0x000000010e81287e ArcGIS`Esri_runtimecore::Geodatabase::Bound_row_value::operator std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >() const + 28

    frame #4: 0x000000010e848b6d ArcGIS`Esri_runtimecore::Geodatabase::populate_field_definitions(std::__1::shared_ptr<Esri_runtimecore::Geodatabase::Database>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) + 503

    frame #5: 0x000000010e814079 ArcGIS`Esri_runtimecore::Geodatabase::Catalog_dataset::get_item_definition(Esri_runtimecore::Geodatabase::Catalog_item_reference const&) + 2825

    frame #6: 0x000000010e890fce ArcGIS`Esri_runtimecore::Geodatabase::Details::Table_schema::describe(std::__1::shared_ptr<Esri_runtimecore::Geodatabase::Database>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 232

    frame #7: 0x000000010e891aab ArcGIS`Esri_runtimecore::Geodatabase::Details::Table_schema::open(std::__1::shared_ptr<Esri_runtimecore::Geodatabase::Database>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 191

    frame #8: 0x000000010e8ad763 ArcGIS`std::__1::shared_ptr<Esri_runtimecore::Geodatabase::Table> Esri_runtimecore::Geodatabase::Database::open<Esri_runtimecore::Geodatabase::Table>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 51

    frame #9: 0x000000010da7a276 ArcGIS`Esri_runtimecore::Mapping::Geodatabase_feature_table::load_sync(pplx::cancellation_token) + 206

    frame #10: 0x000000010da7cc3a ArcGIS`std::__1::__function::__func<Esri_runtimecore::Mapping::Geodatabase_feature_table::load_or_retry_(Esri_runtimecore::Mapping::Loadable::Load_or_retry_mode)::$_2, std::__1::allocator<Esri_runtimecore::Mapping::Geodatabase_feature_table::load_or_retry_(Esri_runtimecore::Mapping::Loadable::Load_or_retry_mode)::$_2>, void ()>::operator()() + 150

    frame #11: 0x000000010db748b2 ArcGIS`std::__1::__function::__func<Esri_runtimecore::Mapping::Task<void>::Task(std::__1::function<void ()>, pplx::cancellation_token_source)::'lambda'(), std::__1::allocator<Esri_runtimecore::Mapping::Task<void>::Task(std::__1::function<void ()>, pplx::cancellation_token_source)::'lambda'()>, boost::any ()>::operator()() + 18

    frame #12: 0x000000010deeb4fb ArcGIS`std::__1::function<boost::any ()>::operator()() const + 27

    frame #13: 0x000000010deeb75e ArcGIS`std::__1::__function::__func<Esri_runtimecore::Mapping::Task_implementation::Task_implementation(std::__1::function<boost::any ()>, Esri_runtimecore::Mapping::Task_options)::$_0, std::__1::allocator<Esri_runtimecore::Mapping::Task_implementation::Task_implementation(std::__1::function<boost::any ()>, Esri_runtimecore::Mapping::Task_options)::$_0>, boost::any ()>::operator()() + 50

    frame #14: 0x000000010deeb4fb ArcGIS`std::__1::function<boost::any ()>::operator()() const + 27

    frame #15: 0x000000010deeb28f ArcGIS`pplx::details::_PPLTaskHandle<boost::any, pplx::task<boost::any>::_InitialTaskHandle<boost::any, Esri_runtimecore::Mapping::Task_implementation::Task_implementation(std::__1::function<boost::any ()>, Esri_runtimecore::Mapping::Task_options)::$_0, pplx::details::_TypeSelectorNoAsync>, pplx::details::_TaskProcHandle>::invoke() const + 267

    frame #16: 0x000000010f55d5c4 ArcGIS`pplx::details::_TaskProcHandle::_RunChoreBridge(void*) + 16

    frame #17: 0x000000010ee1b428 ArcGIS`Esri_runtimecore::Common::Core_scheduler::invoke_(Esri_runtimecore::Common::Core_scheduler::Queued_proc*) + 24

    frame #18: 0x000000010ee1b3d0 ArcGIS`Esri_runtimecore::Common::Core_scheduler::Queued_proc::invoke() + 48

    frame #19: 0x000000010ee1ad1f ArcGIS`Esri_runtimecore::Common::Core_scheduler::bridge_proc_(void*) + 23

    frame #20: 0x0000000119e8a848 libdispatch.dylib`_dispatch_client_callout + 8

    frame #21: 0x0000000119e8f675 libdispatch.dylib`_dispatch_queue_override_invoke + 1451

    frame #22: 0x0000000119e963c8 libdispatch.dylib`_dispatch_root_queue_drain + 664

    frame #23: 0x0000000119e960d2 libdispatch.dylib`_dispatch_worker_thread3 + 132

    frame #24: 0x000000011c615169 libsystem_pthread.dylib`_pthread_wqthread + 1387

    frame #25: 0x000000011c614be9 libsystem_pthread.dylib`start_wqthread + 13

(lldb)

0 Kudos
4 Replies
Nicholas-Furness
Esri Regular Contributor

Hey Jake,

Not sure this is the same as the other app freezing issue we discussed separately yesterday, but I'd like to get a repro case for this. I think I can work with what you've given me access to but I'll let you know if I need more info.

Separately, if you wouldn't mind (and to help with the readability of this thread), could you edit your post to include the full stack as another attachment. Maybe just keep the crash back trace?

Thanks!

Nick.

0 Kudos
JakeShapley
New Contributor III

Hi Nick,

I'm not sure if it's the same issue, or not. I appreciate the help. I moved the full stack to an attachment.

Cheers,

Jake

JakeShapley
New Contributor III

Hi Nick,

I am able to reproduce a EXC_BAD_ACCESS crash consistently (though with less frequency) in the same background/foreground scenario. Here is the back trace:

(lldb) bt

* thread #62, queue = 'com.apple.root.default-qos', stop reason = EXC_BAD_ACCESS (code=1, address=0xa000000000000044)

  * frame #0: 0x000000010510a76c ArcGIS`columnMem.llvm.82BCAFF3 + 92

    frame #1: 0x0000000104868314 ArcGIS`Esri_runtimecore::Geodatabase::Sqlite_command::is_null(int) + 24

    frame #2: 0x0000000104868400 ArcGIS`Esri_runtimecore::Geodatabase::Sqlite_command::get_as_int32(int) + 32

    frame #3: 0x0000000104839fac ArcGIS`Esri_runtimecore::Geodatabase::populate_field_definitions(std::__1::shared_ptr<Esri_runtimecore::Geodatabase::Database>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) + 1352

    frame #4: 0x0000000104805f30 ArcGIS`Esri_runtimecore::Geodatabase::Catalog_dataset::get_item_definition(Esri_runtimecore::Geodatabase::Catalog_item_reference const&) + 4116

    frame #5: 0x000000010487d90c ArcGIS`Esri_runtimecore::Geodatabase::Details::Table_schema::describe(std::__1::shared_ptr<Esri_runtimecore::Geodatabase::Database>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 208

    frame #6: 0x000000010487e400 ArcGIS`Esri_runtimecore::Geodatabase::Details::Table_schema::open(std::__1::shared_ptr<Esri_runtimecore::Geodatabase::Database>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 172

    frame #7: 0x0000000103ba40d4 ArcGIS`std::__1::shared_ptr<Esri_runtimecore::Geodatabase::Table> Esri_runtimecore::Geodatabase::Database::open<Esri_runtimecore::Geodatabase::Table>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 56

    frame #8: 0x0000000103be9edc ArcGIS`Esri_runtimecore::Mapping::Geodatabase_feature_table::load_sync(pplx::cancellation_token) + 172

    frame #9: 0x0000000103bebfd8 ArcGIS`std::__1::__function::__func<Esri_runtimecore::Mapping::Geodatabase_feature_table::load_or_retry_(Esri_runtimecore::Mapping::Loadable::Load_or_retry_mode)::$_2, std::__1::allocator<Esri_runtimecore::Mapping::Geodatabase_feature_table::load_or_retry_(Esri_runtimecore::Mapping::Loadable::Load_or_retry_mode)::$_2>, void ()>::operator()() + 164

    frame #10: 0x0000000103b39024 ArcGIS`std::__1::__function::__func<Esri_runtimecore::Mapping::Task<void>::Task(std::__1::function<void ()>, pplx::cancellation_token_source)::'lambda'(), std::__1::allocator<Esri_runtimecore::Mapping::Task<void>::Task(std::__1::function<void ()>, pplx::cancellation_token_source)::'lambda'()>, boost::any ()>::operator()() + 24

    frame #11: 0x0000000103fed794 ArcGIS`std::__1::__function::__func<Esri_runtimecore::Mapping::Task_implementation::Task_implementation(std::__1::function<boost::any ()>, Esri_runtimecore::Mapping::Task_options)::$_0, std::__1::allocator<Esri_runtimecore::Mapping::Task_implementation::Task_implementation(std::__1::function<boost::any ()>, Esri_runtimecore::Mapping::Task_options)::$_0>, boost::any ()>::operator()() + 52

    frame #12: 0x0000000103fed190 ArcGIS`pplx::details::_PPLTaskHandle<boost::any, pplx::task<boost::any>::_InitialTaskHandle<boost::any, Esri_runtimecore::Mapping::Task_implementation::Task_implementation(std::__1::function<boost::any ()>, Esri_runtimecore::Mapping::Task_options)::$_0, pplx::details::_TypeSelectorNoAsync>, pplx::details::_TaskProcHandle>::invoke() const + 188

    frame #13: 0x00000001053ccd74 ArcGIS`pplx::details::_TaskProcHandle::_RunChoreBridge(void*) + 28

    frame #14: 0x0000000104d41a88 ArcGIS`Esri_runtimecore::Common::Core_scheduler::bridge_proc_(void*) + 60

    frame #15: 0x0000000116af945c libdispatch.dylib`_dispatch_client_callout + 16

    frame #16: 0x0000000116b0556c libdispatch.dylib`_dispatch_queue_override_invoke + 980

    frame #17: 0x0000000116b0ab54 libdispatch.dylib`_dispatch_root_queue_drain + 616

    frame #18: 0x0000000116b0a880 libdispatch.dylib`_dispatch_worker_thread3 + 136

    frame #19: 0x00000001842e3120 libsystem_pthread.dylib`_pthread_wqthread + 1268

    frame #20: 0x00000001842e2c20 libsystem_pthread.dylib`start_wqthread + 4

(lldb)

0 Kudos
JakeShapley
New Contributor III

And another:

(lldb) bt

* thread #33, queue = 'com.apple.root.default-qos', stop reason = EXC_BAD_ACCESS (code=1, address=0x736120657079542e)

  * frame #0: 0x00000001842ebe4c libsystem_pthread.dylib`pthread_mutex_unlock$VARIANT$armv81

    frame #1: 0x0000000104d28330 ArcGIS`Esri_runtimecore::Geodatabase::Sqlite_command::is_null(int) + 52

    frame #2: 0x0000000104d2894c ArcGIS`Esri_runtimecore::Geodatabase::Sqlite_command::get_as_text(int) + 52

    frame #3: 0x0000000104d286dc ArcGIS`Esri_runtimecore::Geodatabase::Sqlite_command::get_as_guid(int) + 84

    frame #4: 0x0000000104ccc220 ArcGIS`Esri_runtimecore::Geodatabase::Catalog_dataset::get_related_items_origins(Esri_runtimecore::Geodatabase::Catalog_item_reference const&) + 508

    frame #5: 0x0000000104ccca80 ArcGIS`Esri_runtimecore::Geodatabase::Catalog_dataset::for_each_relationship_class(Esri_runtimecore::Geodatabase::Catalog_item_reference&, std::__1::function<bool (Esri_runtimecore::Geodatabase::Relationship_class_definition&)>) + 52

    frame #6: 0x0000000104d3db30 ArcGIS`Esri_runtimecore::Geodatabase::Details::Table_schema::describe(std::__1::shared_ptr<Esri_runtimecore::Geodatabase::Database>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 756

    frame #7: 0x0000000104d3e400 ArcGIS`Esri_runtimecore::Geodatabase::Details::Table_schema::open(std::__1::shared_ptr<Esri_runtimecore::Geodatabase::Database>&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 172

    frame #8: 0x00000001040640d4 ArcGIS`std::__1::shared_ptr<Esri_runtimecore::Geodatabase::Table> Esri_runtimecore::Geodatabase::Database::open<Esri_runtimecore::Geodatabase::Table>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 56

    frame #9: 0x00000001040a9edc ArcGIS`Esri_runtimecore::Mapping::Geodatabase_feature_table::load_sync(pplx::cancellation_token) + 172

    frame #10: 0x00000001040abfd8 ArcGIS`std::__1::__function::__func<Esri_runtimecore::Mapping::Geodatabase_feature_table::load_or_retry_(Esri_runtimecore::Mapping::Loadable::Load_or_retry_mode)::$_2, std::__1::allocator<Esri_runtimecore::Mapping::Geodatabase_feature_table::load_or_retry_(Esri_runtimecore::Mapping::Loadable::Load_or_retry_mode)::$_2>, void ()>::operator()() + 164

    frame #11: 0x0000000103ff9024 ArcGIS`std::__1::__function::__func<Esri_runtimecore::Mapping::Task<void>::Task(std::__1::function<void ()>, pplx::cancellation_token_source)::'lambda'(), std::__1::allocator<Esri_runtimecore::Mapping::Task<void>::Task(std::__1::function<void ()>, pplx::cancellation_token_source)::'lambda'()>, boost::any ()>::operator()() + 24

    frame #12: 0x00000001044ad794 ArcGIS`std::__1::__function::__func<Esri_runtimecore::Mapping::Task_implementation::Task_implementation(std::__1::function<boost::any ()>, Esri_runtimecore::Mapping::Task_options)::$_0, std::__1::allocator<Esri_runtimecore::Mapping::Task_implementation::Task_implementation(std::__1::function<boost::any ()>, Esri_runtimecore::Mapping::Task_options)::$_0>, boost::any ()>::operator()() + 52

    frame #13: 0x00000001044ad190 ArcGIS`pplx::details::_PPLTaskHandle<boost::any, pplx::task<boost::any>::_InitialTaskHandle<boost::any, Esri_runtimecore::Mapping::Task_implementation::Task_implementation(std::__1::function<boost::any ()>, Esri_runtimecore::Mapping::Task_options)::$_0, pplx::details::_TypeSelectorNoAsync>, pplx::details::_TaskProcHandle>::invoke() const + 188

    frame #14: 0x000000010588cd74 ArcGIS`pplx::details::_TaskProcHandle::_RunChoreBridge(void*) + 28

    frame #15: 0x0000000105201a88 ArcGIS`Esri_runtimecore::Common::Core_scheduler::bridge_proc_(void*) + 60

    frame #16: 0x0000000116fbd45c libdispatch.dylib`_dispatch_client_callout + 16

    frame #17: 0x0000000116fc956c libdispatch.dylib`_dispatch_queue_override_invoke + 980

    frame #18: 0x0000000116fceb54 libdispatch.dylib`_dispatch_root_queue_drain + 616

    frame #19: 0x0000000116fce880 libdispatch.dylib`_dispatch_worker_thread3 + 136

    frame #20: 0x00000001842e3120 libsystem_pthread.dylib`_pthread_wqthread + 1268

    frame #21: 0x00000001842e2c20 libsystem_pthread.dylib`start_wqthread + 4

(lldb)

I've been looking through our crash reports and found these occurring in the wild, as well.

Cheers,

Jake

0 Kudos