From 48a42c655d11b7fc8c6c018ad1d22987f93ad52f Mon Sep 17 00:00:00 2001 From: monojenkins Date: Thu, 21 May 2020 14:24:31 -0400 Subject: [PATCH] Adding check to bypass decoding pdbs that have no sequence points. (#36771) Unity has a pdb with zero sequence points somehow. If a user added a reference to the library and then attempted to set a managed breakpoint mono would hit an assert and crash when it would attempt to decode this pdb. Call stack would look like: ``` > mono-2.0-boehm.dll!mono_ppdb_get_seq_points(_MonoDebugMethodInfo * minfo, char * * source_file, _GPtrArray * * source_file_list, int * * source_files, MonoSymSeqPoint * * seq_points, int * n_seq_points) Line 508 C mono-2.0-boehm.dll!mono_debug_get_seq_points(_MonoDebugMethodInfo * minfo, char * * source_file, _GPtrArray * * source_file_list, int * * source_files, MonoSymSeqPoint * * seq_points, int * n_seq_points) Line 1093 C mono-2.0-boehm.dll!get_source_files_for_type(_MonoClass * klass) Line 6920 C mono-2.0-boehm.dll!get_types_for_source_file(void * key, void * value, void * user_data) Line 7003 C mono-2.0-boehm.dll!monoeg_g_hash_table_foreach(_GHashTable * hash, void(*)(void *, void *, void *) func, void * user_data) Line 364 C mono-2.0-boehm.dll!mono_de_foreach_domain(void(*)(void *, void *, void *) func, void * user_data) Line 95 C mono-2.0-boehm.dll!vm_commands(int command, int id, unsigned char * p, unsigned char * end, Buffer * buf) Line 7341 C mono-2.0-boehm.dll!debugger_thread(void * arg) Line 10323 C mono-2.0-boehm.dll!start_wrapper_internal(StartInfo * start_info, unsigned __int64 * stack_ptr) Line 1241 C mono-2.0-boehm.dll!start_wrapper(void * data) Line 1315 C kernel32.dll!00007ffc12017bd4() Unknown ntdll.dll!00007ffc121ece51() Unknown ``` Adding a check to ignore pdbs like this prevents the crash and debugging can continue normally. Related unity issue: https://issuetracker.unity3d.com/issues/macos-editor-crashes-on-mono-log-write-logfile-when-attaching-a-debugger-and-then-setting-a-breakpoint Co-authored-by: UnityAlex --- src/mono/mono/metadata/debug-mono-ppdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/metadata/debug-mono-ppdb.c b/src/mono/mono/metadata/debug-mono-ppdb.c index 28c78c2..a5634f6 100644 --- a/src/mono/mono/metadata/debug-mono-ppdb.c +++ b/src/mono/mono/metadata/debug-mono-ppdb.c @@ -497,7 +497,7 @@ mono_ppdb_get_seq_points (MonoDebugMethodInfo *minfo, char **source_file, GPtrAr if (source_files) sindexes = g_ptr_array_new (); - if (!method->token) + if (!method->token || tables [MONO_TABLE_METHODBODY].rows == 0) return; method_idx = mono_metadata_token_index (method->token); -- 2.7.4