Skip to content

UT of bspline have illegal memory access #849

@caic99

Description

@caic99

The sanitizer prompts this line

EXPECT_NEAR(bp.bezier_ele(norder+1),0,1.e-16);

of array access is out of bound under the implementation of bspline.

From https://github.com/deepmodeling/abacus-develop/runs/6037165782?check_suite_focus=true line 3311:

25: Test command: /__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline
25: Test timeout computed to be: 1500
25: Running main() from /tmp/googletest/googletest/src/gtest_main.cc
25: [==========] Running 2 tests from 1 test suite.
25: [----------] Global test environment set-up.
25: [----------] 2 tests from MathBsplineTest
25: [ RUN      ] MathBsplineTest.Init
25: [       OK ] MathBsplineTest.Init (5 ms)
25: [ RUN      ] MathBsplineTest.Properties
25: =================================================================
25: ==2277==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6030000010d8 at pc 0x55edaedbbeb6 bp 0x7ffe6a963bd0 sp 0x7ffe6a963bc8
25: READ of size 8 at 0x6030000010d8 thread T0
25:     #0 0x55edaedbbeb5 in ModuleBase::Bspline::bezier_ele(int) /__w/abacus-develop/abacus-develop/source/module_base/math_bspline.cpp:37
25:     #1 0x55edaedb65d6 in MathBsplineTest_Properties_Test::TestBody() /__w/abacus-develop/abacus-develop/source/module_base/test/math_bspline_test.cpp:60
25:     #2 0x55edaedf5504 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (/__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline+0x4b504)
25:     #3 0x55edaedee6ee in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (/__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline+0x446ee)
25:     #4 0x55edaedcd5eb in testing::Test::Run() (/__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline+0x235eb)
25:     #5 0x55edaedcdf43 in testing::TestInfo::Run() (/__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline+0x23f43)
25:     #6 0x55edaedce779 in testing::TestSuite::Run() (/__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline+0x24779)
25:     #7 0x55edaeddd89d in testing::internal::UnitTestImpl::RunAllTests() (/__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline+0x3389d)
25:     #8 0x55edaedf66d4 in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (/__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline+0x4c6d4)
25:     #9 0x55edaedef716 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (/__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline+0x45716)
25:     #10 0x55edaeddc17c in testing::UnitTest::Run() (/__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline+0x3217c)
25:     #11 0x55edaedbc150 in RUN_ALL_TESTS() (/__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline+0x12150)
25:     #12 0x55edaedbc0de in main (/__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline+0x120de)
25:     #13 0x7f110c8a4d09 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x26d09)
25:     #14 0x55edaedb60f9 in _start (/__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline+0xc0f9)
25: 
25: 0x6030000010d8 is located 0 bytes to the right of 24-byte region [0x6030000010c0,0x6030000010d8)
25: allocated by thread T0 here:
25:     #0 0x7f110ce3b7a7 in operator new[](unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:102
25:     #1 0x55edaedbbd68 in ModuleBase::Bspline::init(int, double, double) /__w/abacus-develop/abacus-develop/source/module_base/math_bspline.cpp:28
25:     #2 0x55edaedb62f7 in MathBsplineTest_Properties_Test::TestBody() /__w/abacus-develop/abacus-develop/source/module_base/test/math_bspline_test.cpp:47
25:     #3 0x55edaedf5504 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (/__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline+0x4b504)
25:     #4 0x55edaedee6ee in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (/__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline+0x446ee)
25:     #5 0x55edaedcd5eb in testing::Test::Run() (/__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline+0x235eb)
25:     #6 0x55edaedcdf43 in testing::TestInfo::Run() (/__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline+0x23f43)
25:     #7 0x55edaedce779 in testing::TestSuite::Run() (/__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline+0x24779)
25:     #8 0x55edaeddd89d in testing::internal::UnitTestImpl::RunAllTests() (/__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline+0x3389d)
25:     #9 0x55edaedf66d4 in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (/__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline+0x4c6d4)
25:     #10 0x55edaedef716 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (/__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline+0x45716)
25:     #11 0x55edaeddc17c in testing::UnitTest::Run() (/__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline+0x3217c)
25:     #12 0x55edaedbc150 in RUN_ALL_TESTS() (/__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline+0x12150)
25:     #13 0x55edaedbc0de in main (/__w/abacus-develop/abacus-develop/build/source/module_base/test/base_math_bspline+0x120de)
25:     #14 0x7f110c8a4d09 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x26d09)
25: 
25: SUMMARY: AddressSanitizer: heap-buffer-overflow /__w/abacus-develop/abacus-develop/source/module_base/math_bspline.cpp:37 in ModuleBase::Bspline::bezier_ele(int)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions