This is an archive of the discontinued LLVM Phabricator instance.

[asan][test] Fix use-after-scope-capture test after D148269
ClosedPublic

Authored by paulkirth on Apr 14 2023, 4:57 PM.

Details

Summary

After enabling ArgPromotion at lower opt levels, the body of this test
was optimized away, and the CHECK lines no longer functioned.

Setting -O0 is a hammer, but gets the test passing again, until code owners
can find a better solution.

Diff Detail

Event Timeline

paulkirth created this revision.Apr 14 2023, 4:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 14 2023, 4:57 PM
Herald added a subscriber: Enna1. · View Herald Transcript
paulkirth requested review of this revision.Apr 14 2023, 4:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 14 2023, 4:57 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript

What's wrong with the fix I commited in D148376? We no longer assert the line.

ASAN doesn't trigger at all. There's no error. Main is basically empty, so FileCheck sees an empty stdin and errors out.

This is long after your patch landed:
https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8783802891855939169/overview

I see the same locally.

paulkirth added a comment.EditedApr 14 2023, 5:05 PM

This is a dump of th IR by adding -S -emit-llvm to the command from lit. Main is pretty empty.

; ModuleID = '/usr/local/google/home/paulkirth/llvm-upstream/compiler-rt/test/asan/TestCases/use-after-scope-capture.cpp'
source_filename = "/usr/local/google/home/paulkirth/llvm-upstream/compiler-rt/test/asan/TestCases/use-after-scope-capture.cpp"
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"

@llvm.used = appending global [1 x ptr] [ptr @asan.module_ctor], section "llvm.metadata"
@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 1, ptr @asan.module_ctor, ptr null }]

; Function Attrs: mustprogress nofree norecurse nosync nounwind sanitize_address willreturn memory(none) uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 !dbg !10 {
entry:
  ret i32 0, !dbg !14
}

declare i32 @__gxx_personality_v0(...)

declare void @__asan_init()

; Function Attrs: nounwind uwtable
define internal void @asan.module_ctor() #1 {
  call void @__asan_init()
  call void @__asan_version_mismatch_check_v8()
  ret void
}

declare void @__asan_version_mismatch_check_v8()

attributes #0 = { mustprogress nofree norecurse nosync nounwind sanitize_address willreturn memory(none) uwtable "disable-tail-calls"="true" "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 = { nounwind uwtable "frame-pointer"="all" }

!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: "Fuchsia clang version 17.0.0 (git@github.com:llvm/llvm-project.git e3b378fad95196c721fc2258f325591f21595c81)", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, splitDebugInlining: false, nameTableKind: None)
!1 = !DIFile(filename: "/usr/local/google/home/paulkirth/llvm-upstream/compiler-rt/test/asan/TestCases/use-after-scope-capture.cpp", directory: "/usr/local/google/home/paulkirth/llvm-upstream/build", checksumkind: CSK_MD5, checksum: "5a3c1e2ee765a8c5617c785e93f76014")
!2 = !{i32 7, !"Dwarf Version", i32 5}
!3 = !{i32 2, !"Debug Info Version", i32 3}
!4 = !{i32 1, !"wchar_size", i32 4}
!5 = !{i32 8, !"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 = !{!"Fuchsia clang version 17.0.0 (git@github.com:llvm/llvm-project.git e3b378fad95196c721fc2258f325591f21595c81)"}
!10 = distinct !DISubprogram(name: "main", scope: !11, file: !11, line: 5, type: !12, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13)
!11 = !DIFile(filename: "compiler-rt/test/asan/TestCases/use-after-scope-capture.cpp", directory: "/usr/local/google/home/paulkirth/llvm-upstream", checksumkind: CSK_MD5, checksum: "5a3c1e2ee765a8c5617c785e93f76014")
!12 = !DISubroutineType(types: !13)
!13 = !{}
!14 = !DILocation(line: 18, column: 1, scope: !10)
fmayer accepted this revision.Apr 14 2023, 5:05 PM

ASAN doesn't trigger at all. There's no error. Main is basically empty, so FileCheck sees an empty stdin and errors out.

This is long after your patch landed:
https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8783802891855939169/overview

I see the same locally.

Weird, it fixed it locally for me. Not sure why.

This revision is now accepted and ready to land.Apr 14 2023, 5:05 PM
This revision was landed with ongoing or failed builds.Apr 14 2023, 5:11 PM
This revision was automatically updated to reflect the committed changes.