@@ -5442,7 +5442,16 @@ get_object_id_for_debugger_method (MonoClass* async_builder_class)
5442
5442
MonoError error ;
5443
5443
GPtrArray * array = mono_class_get_methods_by_name (async_builder_class , "get_ObjectIdForDebugger" , 0x24 , FALSE, FALSE, & error );
5444
5444
mono_error_assert_ok (& error );
5445
- g_assert (array -> len == 1 );
5445
+ if (array -> len != 1 ) {
5446
+ g_ptr_array_free (array , TRUE);
5447
+ //if we don't find method get_ObjectIdForDebugger we try to find the property Task to continue async debug.
5448
+ MonoProperty * prop = mono_class_get_property_from_name (async_builder_class , "Task" );
5449
+ if (!prop ) {
5450
+ DEBUG_PRINTF (1 , "Impossible to debug async methods.\n" );
5451
+ return NULL ;
5452
+ }
5453
+ return prop -> get ;
5454
+ }
5446
5455
MonoMethod * method = (MonoMethod * )g_ptr_array_index (array , 0 );
5447
5456
g_ptr_array_free (array , TRUE);
5448
5457
return method ;
@@ -5460,7 +5469,9 @@ get_class_to_get_builder_field(StackFrame *frame)
5460
5469
MonoGenericContext context ;
5461
5470
MonoType * inflated_type ;
5462
5471
5463
- g_assert (this_obj );
5472
+ if (!this_obj )
5473
+ return NULL ;
5474
+
5464
5475
context = mono_get_generic_context_from_stack_frame (frame -> ji , this_obj -> vtable );
5465
5476
inflated_type = mono_class_inflate_generic_type_checked (& original_class -> byval_arg , & context , & error );
5466
5477
mono_error_assert_ok (& error ); /* FIXME don't swallow the error */
@@ -5484,7 +5495,8 @@ get_async_method_builder (StackFrame *frame)
5484
5495
5485
5496
klass = get_class_to_get_builder_field (frame );
5486
5497
builder_field = mono_class_get_field_from_name_full (klass , "<>t__builder" , NULL );
5487
- g_assert (builder_field );
5498
+ if (!builder_field )
5499
+ return NULL ;
5488
5500
5489
5501
this_addr = get_this_addr (frame );
5490
5502
if (!this_addr )
@@ -5524,7 +5536,8 @@ get_this_async_id (StackFrame *frame)
5524
5536
return 0 ;
5525
5537
5526
5538
builder_field = mono_class_get_field_from_name (get_class_to_get_builder_field (frame ), "<>t__builder" );
5527
- g_assert (builder_field );
5539
+ if (!builder_field )
5540
+ return 0 ;
5528
5541
5529
5542
tls = (DebuggerTlsData * )mono_native_tls_get_value (debugger_tls_id );
5530
5543
if (tls ) {
@@ -5533,6 +5546,11 @@ get_this_async_id (StackFrame *frame)
5533
5546
}
5534
5547
5535
5548
method = get_object_id_for_debugger_method (mono_class_from_mono_type (mono_field_get_type (builder_field )));
5549
+ if (!method ) {
5550
+ if (tls )
5551
+ tls -> disable_breakpoints = old_disable_breakpoints ;
5552
+ return 0 ;
5553
+ }
5536
5554
obj = mono_runtime_try_invoke (method , builder , NULL , & ex , & error );
5537
5555
mono_error_assert_ok (& error );
5538
5556
@@ -5548,9 +5566,11 @@ static gboolean
5548
5566
set_set_notification_for_wait_completion_flag (StackFrame * frame )
5549
5567
{
5550
5568
MonoClassField * builder_field = mono_class_get_field_from_name (get_class_to_get_builder_field (frame ), "<>t__builder" );
5551
- g_assert (builder_field );
5569
+ if (!builder_field )
5570
+ return FALSE;
5552
5571
gpointer builder = get_async_method_builder (frame );
5553
- g_assert (builder );
5572
+ if (!builder )
5573
+ return FALSE;
5554
5574
5555
5575
void * args [1 ];
5556
5576
gboolean arg = TRUE;
@@ -6042,7 +6062,6 @@ process_single_step_inner (DebuggerTlsData *tls, gboolean from_signal)
6042
6062
return ;
6043
6063
}
6044
6064
6045
-
6046
6065
/*
6047
6066
* The ip points to the instruction causing the single step event, which is before
6048
6067
* the offset recorded in the seq point map, so find the next seq point after ip.
@@ -6814,7 +6833,10 @@ ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, StepFilte
6814
6833
* We are stopped at a throw site. Stepping should go to the catch site.
6815
6834
*/
6816
6835
frame = tls -> catch_frame ;
6817
- g_assert (frame .type == FRAME_TYPE_MANAGED || frame .type == FRAME_TYPE_INTERP );
6836
+ if (frame .type != FRAME_TYPE_MANAGED && frame .type != FRAME_TYPE_INTERP ) {
6837
+ DEBUG_PRINTF (1 , "Current frame is not managed nor interpreter.\n" );
6838
+ return ERR_INVALID_ARGUMENT ;
6839
+ }
6818
6840
6819
6841
/*
6820
6842
* Find the seq point corresponding to the landing site ip, which is the first seq
@@ -6824,7 +6846,11 @@ ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, StepFilte
6824
6846
sp = (found_sp )? & local_sp : NULL ;
6825
6847
if (!sp )
6826
6848
no_seq_points_found (frame .method , frame .native_offset );
6827
- g_assert (sp );
6849
+
6850
+ if (!sp ) {
6851
+ DEBUG_PRINTF (1 , "Could not find next sequence point.\n" );
6852
+ return ERR_INVALID_ARGUMENT ;
6853
+ }
6828
6854
6829
6855
method = frame .method ;
6830
6856
@@ -6870,7 +6896,10 @@ ss_create (MonoInternalThread *thread, StepSize size, StepDepth depth, StepFilte
6870
6896
sp = (found_sp )? & local_sp : NULL ;
6871
6897
if (!sp )
6872
6898
no_seq_points_found (frame -> method , frame -> native_offset );
6873
- g_assert (sp );
6899
+ if (!sp ) {
6900
+ DEBUG_PRINTF (1 , "Could not find next sequence point.\n" );
6901
+ return ERR_INVALID_ARGUMENT ;
6902
+ }
6874
6903
method = frame -> method ;
6875
6904
}
6876
6905
}
@@ -10838,7 +10867,11 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g
10838
10867
if (mono_class_get_context (klass )) {
10839
10868
MonoError error ;
10840
10869
result = mono_class_inflate_generic_method_full_checked (result , klass , mono_class_get_context (klass ), & error );
10841
- g_assert (mono_error_ok (& error )); /* FIXME don't swallow the error */
10870
+ if (!mono_error_ok (& error )) {
10871
+ buffer_add_string (buf , mono_error_get_message (& error ));
10872
+ mono_error_cleanup (& error );
10873
+ return ERR_INVALID_ARGUMENT ;
10874
+ }
10842
10875
}
10843
10876
}
10844
10877
}
@@ -10981,7 +11014,12 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g
10981
11014
char * s ;
10982
11015
10983
11016
s = mono_string_to_utf8_checked ((MonoString * )val , & error );
10984
- mono_error_assert_ok (& error );
11017
+ if (!mono_error_ok (& error )) {
11018
+ buffer_add_string (buf , mono_error_get_message (& error ));
11019
+ mono_error_cleanup (& error );
11020
+ g_free (s );
11021
+ return ERR_INVALID_ARGUMENT ;
11022
+ }
10985
11023
buffer_add_byte (buf , TOKEN_TYPE_STRING );
10986
11024
buffer_add_string (buf , s );
10987
11025
g_free (s );
@@ -11049,7 +11087,11 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g
11049
11087
tmp_context .method_inst = ginst ;
11050
11088
11051
11089
inflated = mono_class_inflate_generic_method_checked (method , & tmp_context , & error );
11052
- g_assert (mono_error_ok (& error )); /* FIXME don't swallow the error */
11090
+ if (!mono_error_ok (& error )) {
11091
+ buffer_add_string (buf , mono_error_get_message (& error ));
11092
+ mono_error_cleanup (& error );
11093
+ return ERR_INVALID_ARGUMENT ;
11094
+ }
11053
11095
if (!mono_verifier_is_method_valid_generic_instantiation (inflated ))
11054
11096
return ERR_INVALID_ARGUMENT ;
11055
11097
buffer_add_methodid (buf , domain , inflated );
@@ -11518,7 +11560,10 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
11518
11560
set_interp_var (& frame -> actual_method -> klass -> this_arg , addr , val_buf );
11519
11561
} else {
11520
11562
var = jit -> this_var ;
11521
- g_assert (var );
11563
+ if (!var ) {
11564
+ buffer_add_string (buf , "Invalid this object" );
11565
+ return ERR_INVALID_ARGUMENT ;
11566
+ }
11522
11567
11523
11568
set_var (& frame -> actual_method -> klass -> this_arg , var , & frame -> ctx , frame -> domain , val_buf , frame -> reg_locations , & tls -> restore_state .ctx );
11524
11569
}
@@ -11561,9 +11606,11 @@ array_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
11561
11606
index = decode_int (p , & p , end );
11562
11607
len = decode_int (p , & p , end );
11563
11608
11564
- g_assert (index >= 0 && len >= 0 );
11609
+ if (index < 0 || len < 0 )
11610
+ return ERR_INVALID_ARGUMENT ;
11565
11611
// Reordered to avoid integer overflow
11566
- g_assert (!(index > arr -> max_length - len ));
11612
+ if (index > arr -> max_length - len )
11613
+ return ERR_INVALID_ARGUMENT ;
11567
11614
11568
11615
esize = mono_array_element_size (mono_object_get_class (& arr -> obj ));
11569
11616
for (i = index ; i < index + len ; ++ i ) {
@@ -11575,9 +11622,11 @@ array_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
11575
11622
index = decode_int (p , & p , end );
11576
11623
len = decode_int (p , & p , end );
11577
11624
11578
- g_assert (index >= 0 && len >= 0 );
11625
+ if (index < 0 || len < 0 )
11626
+ return ERR_INVALID_ARGUMENT ;
11579
11627
// Reordered to avoid integer overflow
11580
- g_assert (!(index > arr -> max_length - len ));
11628
+ if (index > arr -> max_length - len )
11629
+ return ERR_INVALID_ARGUMENT ;
11581
11630
11582
11631
esize = mono_array_element_size (mono_object_get_class (& arr -> obj ));
11583
11632
for (i = index ; i < index + len ; ++ i ) {
0 commit comments