Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake-build : Enable allow_user_poisoning #2326

Open
abhigunj opened this issue May 11, 2024 · 1 comment
Open

cmake-build : Enable allow_user_poisoning #2326

abhigunj opened this issue May 11, 2024 · 1 comment
Assignees

Comments

@abhigunj
Copy link
Member

abhigunj commented May 11, 2024

user poisoning is disabled at #2318 to unblock integrate.

Updating description with notes from the debugging:

Remove the workaround then,
build_tools/build_mlir.sh llvm-project llvm-build

STABLEHLO_ENABLE_SANITIZER=address STABLEHLO_ENABLE_BINDINGS_PYTHON=OFF CMAKE_BUILD_TYPE=Release ./build_tools/github_actions/ci_build_cmake.sh llvm-build build

cmake --build build --target example-add-test
  • ExampleAdd.cpp is not touched recently, but build started failing due to some unknown upstream changes
@abhigunj abhigunj self-assigned this May 11, 2024
abhigunj added a commit that referenced this issue May 13, 2024
This PR bumps LLVM version to the latest LLVM integration commit. 

(backported from g3)
1. Tosa dialect op change form div to int_div
2. CHECK test expected log change

(manually updated CHECK test expected logs)
3. stablehlo_legalize_to_vhlo.0_20_0.mlir test file, it is newly
introduced

(to fix asan cmake build failure)
3. disabled allow_user_poisoning. Created tracker
#2326 to reenable it. Thanks
@mlevesquedion for the workaround.
@abhigunj
Copy link
Member Author

abhigunj commented Jul 8, 2024

error logs

cmake --build build --target example-add-test
[1/1] Executing example-add to validate it works.
FAILED: examples/c++/CMakeFiles/example-add-test  /stablehlo/stablehlo/build/examples/c++/CMakeFiles/example-add-test 
cd  /stablehlo/stablehlo/examples/c++ &&  /stablehlo/stablehlo/build/examples/c++/example-add
=================================================================
==3502535==ERROR: AddressSanitizer: use-after-poison on address 0x621000000b18 at pc 0x55631fe91746 bp 0x7fffeb3f5e80 sp 0x7fffeb3f5640
WRITE of size 16 at 0x621000000b18 thread T0
    #0 0x55631fe91745 in memcpy ( /stablehlo/stablehlo/build/examples/c++/example-add+0x1447745) (BuildId: d5eb03de6d712a8d)
    #1 0x5563219e0503 in _ZN4llvm23SmallVectorTemplateBaseISt4pairIN4mlir6TypeIDEPvELb1EE18uninitialized_copyIS5_S5_EEvPT_S9_PT0_PNSt9enable_ifIXsrSt7is_sameINSt12remove_constIS8_E4typeESA_E5valueEvE4typeE  /stablehlo/stablehlo/llvm-project/llvm/include/llvm/ADT/SmallVector.h:533:13
    #2 0x5563219e0503 in _ZN4llvm23SmallVectorTemplateBaseISt4pairIN4mlir6TypeIDEPvELb1EE18uninitialized_copyIS5_S5_EEvPT_S9_PT0_PNSt9enable_ifIXsrSt7is_sameINSt12remove_constIS8_E4typeESA_E5valueEvE4typeE  /stablehlo/stablehlo/llvm-project/llvm/include/llvm/ADT/SmallVector.h:524:15
    #3 0x5563219e0503 in void llvm::SmallVectorTemplateBase<std::pair<mlir::TypeID, void*>, true>::uninitialized_move<std::pair<mlir::TypeID, void*>*, std::pair<mlir::TypeID, void*>*>(std::pair<mlir::TypeID, void*>*, std::pair<mlir::TypeID, void*>*, std::pair<mlir::TypeID, void*>*)  /stablehlo/stablehlo/llvm-project/llvm/include/llvm/ADT/SmallVector.h:510:23
    #4 0x5563219e0503 in llvm::SmallVectorImpl<std::pair<mlir::TypeID, void*>>::operator=(llvm::SmallVectorImpl<std::pair<mlir::TypeID, void*>>&&) (.isra.0)  /stablehlo/stablehlo/llvm-project/llvm/include/llvm/ADT/SmallVector.h:1110:27
    #5 0x5563219eb45d in llvm::SmallVector<std::pair<mlir::TypeID, void*>, 3u>::SmallVector(llvm::SmallVector<std::pair<mlir::TypeID, void*>, 3u>&&)  /stablehlo/stablehlo/llvm-project/llvm/include/llvm/ADT/SmallVector.h:1261:36
    #6 0x5563219eb45d in mlir::detail::InterfaceMap::InterfaceMap(mlir::detail::InterfaceMap&&)  /stablehlo/stablehlo/llvm-project/mlir/include/mlir/Support/InterfaceSupport.h:176:3
    #7 0x5563219eb45d in mlir::AbstractType::AbstractType(mlir::AbstractType&&)  /stablehlo/stablehlo/llvm-project/mlir/include/mlir/IR/TypeSupport.h:30:7
    #8 0x5563219eb45d in mlir::Dialect::addType(mlir::TypeID, mlir::AbstractType&&)  /stablehlo/stablehlo/llvm-project/mlir/lib/IR/MLIRContext.cpp:713:43
    #9 0x5563219be893 in void mlir::Dialect::addType<mlir::MemRefType>()  /stablehlo/stablehlo/llvm-project/mlir/include/mlir/IR/Dialect.h:341:12
    #10 0x5563219becf8 in void mlir::Dialect::addTypes<mlir::ComplexType, mlir::Float8E5M2Type, mlir::Float8E4M3FNType, mlir::Float8E5M2FNUZType, mlir::Float8E4M3FNUZType, mlir::Float8E4M3B11FNUZType, mlir::BFloat16Type, mlir::Float16Type, mlir::FloatTF32Type, mlir::Float32Type, mlir::Float64Type, mlir::Float80Type, mlir::Float128Type, mlir::FunctionType, mlir::IndexType, mlir::IntegerType, mlir::MemRefType, mlir::NoneType, mlir::OpaqueType, mlir::RankedTensorType, mlir::TupleType, mlir::UnrankedMemRefType, mlir::UnrankedTensorType, mlir::VectorType>()  /stablehlo/stablehlo/llvm-project/mlir/include/mlir/IR/Dialect.h:296:55
    #11 0x5563219becf8 in mlir::BuiltinDialect::registerTypes()  /stablehlo/stablehlo/llvm-project/mlir/lib/IR/BuiltinTypes.cpp:43:8
    #12 0x5563219aacc5 in mlir::BuiltinDialect::initialize()  /stablehlo/stablehlo/llvm-project/mlir/lib/IR/BuiltinDialect.cpp:116:16
    #13 0x55632196d462 in mlir::BuiltinDialect* mlir::MLIRContext::getOrLoadDialect<mlir::BuiltinDialect>()::'lambda'()::operator()() const  /stablehlo/stablehlo/llvm-project/mlir/include/mlir/IR/MLIRContext.h:100:38
    #14 0x55632196d462 in std::unique_ptr<mlir::Dialect, std::default_delete<mlir::Dialect>> llvm::function_ref<std::unique_ptr<mlir::Dialect, std::default_delete<mlir::Dialect>> ()>::callback_fn<mlir::BuiltinDialect* mlir::MLIRContext::getOrLoadDialect<mlir::BuiltinDialect>()::'lambda'()>(long)  /stablehlo/stablehlo/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:40
    #15 0x5563219e808c in llvm::function_ref<std::unique_ptr<mlir::Dialect, std::default_delete<mlir::Dialect>> ()>::operator()() const  /stablehlo/stablehlo/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:62
    #16 0x5563219e808c in mlir::MLIRContext::getOrLoadDialect(llvm::StringRef, mlir::TypeID, llvm::function_ref<std::unique_ptr<mlir::Dialect, std::default_delete<mlir::Dialect>> ()>)  /stablehlo/stablehlo/llvm-project/mlir/lib/IR/MLIRContext.cpp:486:53
    #17 0x5563219e8fab in mlir::BuiltinDialect* mlir::MLIRContext::getOrLoadDialect<mlir::BuiltinDialect>()  /stablehlo/stablehlo/llvm-project/mlir/include/mlir/IR/MLIRContext.h:99:25
    #18 0x5563219e8fab in mlir::MLIRContext::MLIRContext(mlir::DialectRegistry const&, mlir::MLIRContext::Threading)  /stablehlo/stablehlo/llvm-project/mlir/lib/IR/MLIRContext.cpp:307:35
    #19 0x5563219e9fd4 in mlir::MLIRContext::MLIRContext(mlir::MLIRContext::Threading)  /stablehlo/stablehlo/llvm-project/mlir/lib/IR/MLIRContext.cpp:292:45
    #20 0x55631ff4e957 in main ( /stablehlo/stablehlo/build/examples/c++/example-add+0x1504957) (BuildId: d5eb03de6d712a8d)
    #21 0x7f665d8456c9 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #22 0x7f665d845784 in __libc_start_main csu/../csu/libc-start.c:360:3
    #23 0x55631fe75770 in _start ( /stablehlo/stablehlo/build/examples/c++/example-add+0x142b770) (BuildId: d5eb03de6d712a8d)

0x621000000b18 is located 2584 bytes inside of 4096-byte region [0x621000000100,0x621000001100)
allocated by thread T0 here:
    #0 0x55631ff4c186 in operator new(unsigned long, std::align_val_t) ( /stablehlo/stablehlo/build/examples/c++/example-add+0x1502186) (BuildId: d5eb03de6d712a8d)
    #1 0x55632031b002 in llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul, 128ul>::AllocateSlow(unsigned long, unsigned long, llvm::Align) StablehloOps.cpp
    #2 0x5563219eb447 in llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul, 128ul>::Allocate(unsigned long, llvm::Align)  /stablehlo/stablehlo/llvm-project/llvm/include/llvm/Support/Allocator.h:176:24
    #3 0x5563219eb447 in llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul, 128ul>::Allocate(unsigned long, unsigned long)  /stablehlo/stablehlo/llvm-project/llvm/include/llvm/Support/Allocator.h:214:20
    #4 0x5563219eb447 in llvm::AllocatorBase<llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul, 128ul>>::Allocate(unsigned long, unsigned long)  /stablehlo/stablehlo/llvm-project/llvm/include/llvm/Support/AllocatorBase.h:53:51
    #5 0x5563219eb447 in mlir::AbstractType* llvm::AllocatorBase<llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul, 128ul>>::Allocate<mlir::AbstractType>(unsigned long)  /stablehlo/stablehlo/llvm-project/llvm/include/llvm/Support/AllocatorBase.h:76:37
    #6 0x5563219eb447 in mlir::Dialect::addType(mlir::TypeID, mlir::AbstractType&&)  /stablehlo/stablehlo/llvm-project/mlir/lib/IR/MLIRContext.cpp:712:70

SUMMARY: AddressSanitizer: use-after-poison ( /stablehlo/stablehlo/build/examples/c++/example-add+0x1447745) (BuildId: d5eb03de6d712a8d) in memcpy
Shadow bytes around the buggy address:
  0x621000000880: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x621000000900: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x621000000980: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x621000000a00: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x621000000a80: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
=>0x621000000b00: f7 f7 f7[f7]f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x621000000b80: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x621000000c00: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x621000000c80: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x621000000d00: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
  0x621000000d80: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==3502535==ABORTING
ninja: build stopped: subcommand failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant