Open vikrant0786 opened 2 years ago
@llvm/issue-subscribers-clang-frontend
Not a dup. (Not all big arrays are the same; we have to look at the stack trace.)
Reduced: build the following with -fsanitize=address.
void z(int*);
void zz() {
int dp[100005][100005];
z(&dp[0][0]);
}
This is almost certainly going to overflow the stack at runtime, but that doesn't mean the compiler should crash.
IR reproducer with -passes=asan-module
: https://llvm.godbolt.org/z/qEGxTxT1M
; ModuleID = '<source>'
source_filename = "<source>"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: mustprogress noinline optnone sanitize_address uwtable
define dso_local void @_Z2zzv() #0 !dbg !10 {
entry:
%dp = alloca [100005 x [100005 x i32]], align 16
call void @llvm.lifetime.start.p0(i64 40004000100, ptr %dp) #4, !dbg !15
call void @llvm.dbg.declare(metadata ptr %dp, metadata !16, metadata !DIExpression()), !dbg !21
%arrayidx = getelementptr inbounds [100005 x [100005 x i32]], ptr %dp, i64 0, i64 0, !dbg !22
%arrayidx1 = getelementptr inbounds [100005 x i32], ptr %arrayidx, i64 0, i64 0, !dbg !22
call void @_Z1zPi(ptr noundef %arrayidx1), !dbg !23
call void @llvm.lifetime.end.p0(i64 40004000100, ptr %dp) #4, !dbg !24
ret void, !dbg !24
}
; Function Attrs: argmemonly nocallback nofree nosync nounwind willreturn
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
declare void @llvm.dbg.declare(metadata, metadata, metadata) #2
declare void @_Z1zPi(ptr noundef) #3
; Function Attrs: argmemonly nocallback nofree nosync nounwind willreturn
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
attributes #0 = { mustprogress noinline optnone sanitize_address uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { argmemonly nocallback nofree nosync nounwind willreturn }
attributes #2 = { nocallback nofree nosync nounwind readnone speculatable willreturn }
attributes #3 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8}
!llvm.ident = !{!9}
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 15.0.0 (https://github.com/llvm/llvm-project.git c261f78d05deee305166e5f8c91e347b8401dfa4)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
!1 = !DIFile(filename: "<source>", directory: "/app", checksumkind: CSK_MD5, checksum: "639fdf3394c480ff23b62f52ecc69cc2")
!2 = !{i32 7, !"Dwarf Version", i32 5}
!3 = !{i32 2, !"Debug Info Version", i32 3}
!4 = !{i32 1, !"wchar_size", i32 4}
!5 = !{i32 7, !"PIC Level", i32 2}
!6 = !{i32 7, !"PIE Level", i32 2}
!7 = !{i32 7, !"uwtable", i32 2}
!8 = !{i32 7, !"frame-pointer", i32 2}
!9 = !{!"clang version 15.0.0 (https://github.com/llvm/llvm-project.git c261f78d05deee305166e5f8c91e347b8401dfa4)"}
!10 = distinct !DISubprogram(name: "zz", linkageName: "_Z2zzv", scope: !11, file: !11, line: 2, type: !12, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !14)
!11 = !DIFile(filename: "example.cpp", directory: "/app", checksumkind: CSK_MD5, checksum: "639fdf3394c480ff23b62f52ecc69cc2")
!12 = !DISubroutineType(types: !13)
!13 = !{null}
!14 = !{}
!15 = !DILocation(line: 3, column: 5, scope: !10)
!16 = !DILocalVariable(name: "dp", scope: !10, file: !11, line: 3, type: !17)
!17 = !DICompositeType(tag: DW_TAG_array_type, baseType: !18, size: 320032000800, elements: !19)
!18 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!19 = !{!20, !20}
!20 = !DISubrange(count: 100005)
!21 = !DILocation(line: 3, column: 9, scope: !10)
!22 = !DILocation(line: 4, column: 8, scope: !10)
!23 = !DILocation(line: 4, column: 5, scope: !10)
!24 = !DILocation(line: 5, column: 1, scope: !10)
LEETCODE problem 1423. Maximum Points You Can Obtain from Cards
CODE:
error message: