@@ -474,7 +474,11 @@ func FuncForPC(pc uintptr) *Func {
474
474
return nil
475
475
}
476
476
if inldata := funcdata (f , _FUNCDATA_InlTree ); inldata != nil {
477
- if ix := pcdatavalue (f , _PCDATA_InlTreeIndex , pc , nil ); ix >= 0 {
477
+ // Note: strict=false so bad PCs (those between functions) don't crash the runtime.
478
+ // We just report the preceeding function in that situation. See issue 29735.
479
+ // TODO: Perhaps we should report no function at all in that case.
480
+ // The runtime currently doesn't have function end info, alas.
481
+ if ix := pcdatavalue1 (f , _PCDATA_InlTreeIndex , pc , nil , false ); ix >= 0 {
478
482
inltree := (* [1 << 20 ]inlinedCall )(inldata )
479
483
name := funcnameFromNameoff (f , inltree [ix ].func_ )
480
484
file , line := funcline (f , pc )
@@ -756,12 +760,22 @@ func funcspdelta(f funcInfo, targetpc uintptr, cache *pcvalueCache) int32 {
756
760
return x
757
761
}
758
762
763
+ func pcdatastart (f funcInfo , table int32 ) int32 {
764
+ return * (* int32 )(add (unsafe .Pointer (& f .nfuncdata ), unsafe .Sizeof (f .nfuncdata )+ uintptr (table )* 4 ))
765
+ }
766
+
759
767
func pcdatavalue (f funcInfo , table int32 , targetpc uintptr , cache * pcvalueCache ) int32 {
760
768
if table < 0 || table >= f .npcdata {
761
769
return - 1
762
770
}
763
- off := * (* int32 )(add (unsafe .Pointer (& f .nfuncdata ), unsafe .Sizeof (f .nfuncdata )+ uintptr (table )* 4 ))
764
- return pcvalue (f , off , targetpc , cache , true )
771
+ return pcvalue (f , pcdatastart (f , table ), targetpc , cache , true )
772
+ }
773
+
774
+ func pcdatavalue1 (f funcInfo , table int32 , targetpc uintptr , cache * pcvalueCache , strict bool ) int32 {
775
+ if table < 0 || table >= f .npcdata {
776
+ return - 1
777
+ }
778
+ return pcvalue (f , pcdatastart (f , table ), targetpc , cache , strict )
765
779
}
766
780
767
781
func funcdata (f funcInfo , i uint8 ) unsafe.Pointer {
0 commit comments