【问题标题】:SQLite3 iOS Segmentation Fault (Xamarin)SQLite3 iOS 分段错误 (Xamarin)
【发布时间】:2017-03-29 14:59:01
【问题描述】:

我很难诊断 sqlite3 内部引发的分段错误。我可以将入口点缩小到对我的代码的单个查询,之后堆栈永远不会返回到我的代码并在 sqlite3 中爆炸。

我知道这可能不是 sqlite3 的问题,但从给出的消息和堆栈跟踪来看,我不知道从哪里开始。

我的代码-

private Session GetCurrentSession()
{
    return Database.Query<Session>("select * from Session").FirstOrDefault();
}

堆栈跟踪从我的代码的最后一次调用开始-

线程 0 名称:tid_a0b 调度队列:com.apple.main-thread 线程 0 崩溃:

0 libsystem_kernel.dylib 0x23d86c5c __pthread_kill + 8

1 libsystem_pthread.dylib 0x23e30732 pthread_kill + 62

2 libsystem_c.dylib 0x23d1b0ac 中止 + 108

3 MyMobileAppiOS 0x0011e834 mono_handle_native_sigsegv (mini-exceptions.c:2420)

4 MyMobileAppiOS 0x0012612c mono_sigsegv_signal_handler (mini-runtime.c:2875)

5 libsystem_platform.dylib 0x23e2a076 _sigtramp + 42

6 libsqlite3.dylib 0x2453cc34 0x2451d000 + 130100

7 libsqlite3.dylib 0x2453cc34 0x2451d000 + 130100

8 libsqlite3.dylib 0x2453cb4a 0x2451d000 + 129866

9 libsqlite3.dylib 0x2452809a 0x2451d000 + 45210

10 libsqlite3.dylib 0x245269e2 0x2451d000 + 39394

11 libsqlite3.dylib 0x24526128 0x2451d000 + 37160

12 libsqlite3.dylib 0x24525aa4 0x2451d000 + 35492

13 libsqlite3.dylib 0x2452583e 0x2451d000 + 34878

14 libsqlite3.dylib 0x24567e50 sqlite3_prepare_v2 + 44

15 MyMobileAppiOS 0x00a2bba0 wrapper_managed_to_native_SQLitePCL_SQLite3Provider_default_NativeMethods_sqlite3_prepare_v2_intptr_byte___int_intptr__intptr_ (/:1)

16 MyMobileAppiOS 0x00a1c754 SQLitePCL_SQLite3Provider_default_SQLitePCL_ISQLite3Provider_sqlite3_prepare_v2_intptr_string_intptr__string_ (/:1)

17 MyMobileAppiOS 0x00a18aa8 SQLitePCL_raw_sqlite3_prepare_v2_SQLitePCL_sqlite3_string_SQLitePCL_sqlite3_stmt__string_ (/:1)

18 MyMobileAppiOS 0x00a189f8 SQLitePCL_raw_sqlite3_prepare_v2_SQLitePCL_sqlite3_string_SQLitePCL_sqlite3_stmt_ (/:1)

19 MyMobileAppiOS 0x009ec278 SQLite_SQLite3_Prepare2_SQLitePCL_sqlite3_string (SQLite.cs:3322)

20 MyMobileAppiOS 0x009e5e00 SQLite_SQLiteCommand_Prepare (SQLite.cs:2289)

21 MyMobileAppiOS 0x009e750c SQLite_SQLiteCommand__ExecuteDeferredQueryc__Iterator0_1_T_REF_MoveNext (SQLite.cs:2201)

22 MyMobileAppiOS 0x002a0db8 System_Collections_Generic_List_1_T_REF__ctor_System_Collections_Generic_IEnumerable_1_T_REF + 596

23 MyMobileAppiOS 0x005b0ae4 System_Linq_Enumerable_ToList_TSource_REF_System_Collections_Generic_IEnumerable_1_TSource_REF (Enumerable.cs:861)

24 MyMobileAppiOS 0x009e58c8 SQLite_SQLiteCommand_ExecuteQuery_T_REF (SQLite.cs:2170)

25 MyMobileAppiOS 0x009debb0 > SQLite_SQLiteConnection_Query_T_REF_string_object__ (SQLite.cs:711)

26 MyMobileAppiOS 0x009c4344 MyMobileAppiOS_SQLiteAccess_Repository_SqlSessionRepository_GetCurrentSession (SqlSessionRepository.cs:35)

应用启动时会调用此行。该应用程序有 50% 的时间崩溃。我知道给出的内容可能不足以解决问题,但我希望从堆栈跟踪中并打电话给我可能导致此问题的方向。

编辑-

看起来这不仅限于此查询,并且可以在任何时候发生 Database.Query 被调用。

【问题讨论】:

    标签: ios xamarin sqlite xamarin.ios


    【解决方案1】:

    这个问题很难找到。但也许这会帮助其他遇到同样错误的人。

    在其中一个查询中,列名不正确。该错误不是与不正确的列名相关的错误,而是段错误。

    为了追查这个问题,我们必须让我们的大部分异步任务在调试器发现错误之前同步运行。显然在 iOS 中,如果一个线程失败,整个应用程序就会失败。在 android 中,它只是忽略它并继续前进。

    检查您的查询并确保您没有引用不存在的列。

    【讨论】:

      猜你喜欢
      • 2013-10-28
      • 2014-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多