@@ -732,6 +732,25 @@ struct Allocator {
732
732
return reinterpret_cast <AsanChunk *>(alloc_beg);
733
733
}
734
734
735
+ AsanChunk *GetAsanChunkDebug (void *alloc_beg) {
736
+ if (!alloc_beg) return nullptr ;
737
+ if (!allocator.FromPrimary (alloc_beg)) {
738
+ uptr *meta = reinterpret_cast <uptr *>(allocator.GetMetaData (alloc_beg));
739
+ AsanChunk *m = reinterpret_cast <AsanChunk *>(meta[1 ]);
740
+ Printf (" GetAsanChunkDebug1 alloc_beg %p meta %p m %p\n " , alloc_beg, meta, m);
741
+ return m;
742
+ }
743
+ uptr *alloc_magic = reinterpret_cast <uptr *>(alloc_beg);
744
+ Printf (
745
+ " GetAsanChunkDebug2 alloc_beg %p alloc_magic %p alloc_magic[0] %p "
746
+ " alloc_magic[1] %p\n " ,
747
+ alloc_beg, alloc_magic, alloc_magic[0 ], alloc_magic[1 ]);
748
+ if (alloc_magic[0 ] == kAllocBegMagic )
749
+ return reinterpret_cast <AsanChunk *>(alloc_magic[1 ]);
750
+ return reinterpret_cast <AsanChunk *>(alloc_beg);
751
+ }
752
+
753
+
735
754
AsanChunk *GetAsanChunkByAddr (uptr p) {
736
755
void *alloc_beg = allocator.GetBlockBegin (reinterpret_cast <void *>(p));
737
756
return GetAsanChunk (alloc_beg);
@@ -744,6 +763,13 @@ struct Allocator {
744
763
return GetAsanChunk (alloc_beg);
745
764
}
746
765
766
+ AsanChunk *GetAsanChunkByAddrFastLockedDebug (uptr p) {
767
+ void *alloc_beg =
768
+ allocator.GetBlockBeginFastLockedDebug (reinterpret_cast <void *>(p));
769
+ Printf (" GetAsanChunkByAddrFastLockedDebug p %p alloc_beg %p\n " , p, alloc_beg);
770
+ return GetAsanChunkDebug (alloc_beg);
771
+ }
772
+
747
773
uptr AllocationSize (uptr p) {
748
774
AsanChunk *m = GetAsanChunkByAddr (p);
749
775
if (!m) return 0 ;
@@ -1040,16 +1066,25 @@ uptr PointsIntoChunk(void* p) {
1040
1066
// Debug code. Delete once issue #1193 is chased down.
1041
1067
extern " C" SANITIZER_WEAK_ATTRIBUTE const char *__lsan_current_stage;
1042
1068
1069
+ void GetUserBeginDebug (uptr chunk) {
1070
+ Printf (" GetUserBeginDebug1 chunk %p\n " , chunk);
1071
+ __asan::AsanChunk *m = __asan::instance.GetAsanChunkByAddrFastLockedDebug (chunk);
1072
+ Printf (" GetUserBeginDebug2 m %p\n " , m);
1073
+ }
1074
+
1043
1075
uptr GetUserBegin (uptr chunk) {
1044
1076
__asan::AsanChunk *m = __asan::instance.GetAsanChunkByAddrFastLocked (chunk);
1045
- if (!m)
1077
+ if (!m) {
1046
1078
Printf (
1047
1079
" ASAN is about to crash with a CHECK failure.\n "
1048
1080
" The ASAN developers are trying to chase down this bug,\n "
1049
1081
" so if you've encountered this bug please let us know.\n "
1050
1082
" See also: https://github.com/google/sanitizers/issues/1193\n "
1083
+ " Internal ref b/149237057\n "
1051
1084
" chunk: %p caller %p __lsan_current_stage %s\n " ,
1052
1085
chunk, GET_CALLER_PC (), __lsan_current_stage);
1086
+ GetUserBeginDebug (chunk);
1087
+ }
1053
1088
CHECK (m);
1054
1089
return m->Beg ();
1055
1090
}
0 commit comments