@@ -303,14 +303,6 @@ unsafe fn rstring_checked_or_empty(val: VALUE) -> String {
303303 }
304304}
305305
306- unsafe fn value_to_string ( recorder : & Recorder , val : VALUE ) -> String {
307- if RB_TYPE_P ( val, rb_sys:: ruby_value_type:: RUBY_T_STRING ) {
308- rstring_lossy ( val)
309- } else {
310- rstring_lossy ( rb_funcall ( val, recorder. id . to_s , 0 ) )
311- }
312- }
313-
314306unsafe extern "C" fn call_to_s ( arg : VALUE ) -> VALUE {
315307 let data = & * ( arg as * const ( VALUE , ID ) ) ;
316308 rb_funcall ( data. 0 , data. 1 , 0 )
@@ -479,7 +471,7 @@ unsafe fn to_value(recorder: &mut Recorder, val: VALUE, depth: usize) -> ValueRe
479471 if !RB_TYPE_P ( members, rb_sys:: ruby_value_type:: RUBY_T_ARRAY )
480472 || !RB_TYPE_P ( values, rb_sys:: ruby_value_type:: RUBY_T_ARRAY )
481473 {
482- let text = value_to_string ( recorder, val) ;
474+ let text = value_to_string_exception_safe ( recorder, val) ;
483475 let type_id =
484476 TraceWriter :: ensure_type_id ( & mut * recorder. tracer , TypeKind :: Raw , & class_name) ;
485477 return ValueRecord :: Raw { r : text, type_id } ;
@@ -510,7 +502,7 @@ unsafe fn to_value(recorder: &mut Recorder, val: VALUE, depth: usize) -> ValueRe
510502 // generic object
511503 let ivars = rb_funcall ( val, recorder. id . instance_variables , 0 ) ;
512504 if !RB_TYPE_P ( ivars, rb_sys:: ruby_value_type:: RUBY_T_ARRAY ) {
513- let text = value_to_string ( recorder, val) ;
505+ let text = value_to_string_exception_safe ( recorder, val) ;
514506 let type_id =
515507 TraceWriter :: ensure_type_id ( & mut * recorder. tracer , TypeKind :: Raw , & class_name) ;
516508 return ValueRecord :: Raw { r : text, type_id } ;
@@ -528,7 +520,7 @@ unsafe fn to_value(recorder: &mut Recorder, val: VALUE, depth: usize) -> ValueRe
528520 if !names. is_empty ( ) {
529521 return struct_value ( recorder, & class_name, & names, & vals, depth) ;
530522 }
531- let text = value_to_string ( recorder, val) ;
523+ let text = value_to_string_exception_safe ( recorder, val) ;
532524 let type_id = TraceWriter :: ensure_type_id ( & mut * recorder. tracer , TypeKind :: Raw , & class_name) ;
533525 ValueRecord :: Raw { r : text, type_id }
534526}
@@ -724,7 +716,7 @@ unsafe extern "C" fn record_event_api(
724716 let recorder = & mut * get_recorder ( self_val) ;
725717 let path_string = rstring_checked_or_empty ( path) ;
726718 let line_num = rb_num2long ( line) as i64 ;
727- let content_str = value_to_string ( recorder, content) ;
719+ let content_str = value_to_string_exception_safe ( recorder, content) ;
728720 record_event ( & mut * recorder. tracer , & path_string, line_num, content_str) ;
729721 Qnil . into ( )
730722}
@@ -824,7 +816,7 @@ unsafe extern "C" fn event_hook_raw(data: VALUE, arg: *mut rb_trace_arg_t) {
824816 TraceWriter :: register_return ( & mut * recorder. tracer , val_rec) ;
825817 } else if ( ev & RUBY_EVENT_RAISE ) != 0 {
826818 let exc = rb_tracearg_raised_exception ( arg) ;
827- let msg = value_to_string ( recorder, exc) ;
819+ let msg = value_to_string_exception_safe ( recorder, exc) ;
828820 TraceWriter :: register_special_event ( & mut * recorder. tracer , EventLogKind :: Error , & msg) ;
829821 }
830822}
0 commit comments