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

add sanitizer in CI #256

Merged
merged 3 commits into from
Nov 28, 2023
Merged

add sanitizer in CI #256

merged 3 commits into from
Nov 28, 2023

Conversation

tigercosmos
Copy link
Collaborator

@tigercosmos tigercosmos commented Nov 28, 2023

add sanitizer in CI

@tigercosmos
Copy link
Collaborator Author

got a issue

tests/test_profile.py::TimeRegistryTC::test_status PASSED
=================================================================
==6149==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60f000005498 at pc 0x7f9530d9dd45 bp 0x7ffca3bfeb10 sp 0x7ffca3bfeb00
READ of size 8 at 0x60f000005498 thread T0
    #0 0x7f9530d9dd44 in modmesh::spacetime::BadEuler1DSolver::march_half_so0(bool) (/home/runner/work/modmesh/modmesh/_modmesh.cpython-310-x86_64-linux-gnu.so+0x599dd44)
    #1 0x7f95309e5d1d  (/home/runner/work/modmesh/modmesh/_modmesh.cpython-310-x86_64-linux-gnu.so+0x55e5d1d)
    #2 0x7f952f270b2b  (/home/runner/work/modmesh/modmesh/_modmesh.cpython-310-x86_64-linux-gnu.so+0x3e70b2b)
    #3 0x56350afd1e0d  (/usr/bin/python3.10+0x15fe0d)
    #4 0x56350afc85ea in _PyObject_MakeTpCall (/usr/bin/python3.10+0x1565ea)
    #55 0x56350afc1907 in _PyEval_EvalFrameDefault (/usr/bin/python3.10+0x14f907)
    #56 0x56350afd270b in _PyFunction_Vectorcall (/usr/bin/python3.10+0x16070b)
    #57 0x56350afbd2c0 in _PyEval_EvalFrameDefault (/usr/bin/python3.10+0x14b2c0)
    #58 0x56350afd270b in _PyFunction_Vectorcall (/usr/bin/python3.10+0x16070b)
    #59 0x56350afc08a1 in _PyEval_EvalFrameDefault (/usr/bin/python3.10+0x14e8a1)
    #60 0x56350afe04e0  (/usr/bin/python3.10+0x16e4e0)
    #61 0x56350afc08a1 in _PyEval_EvalFrameDefault (/usr/bin/python3.10+0x14e8a1)
    #62 0x56350afd270b in _PyFunction_Vectorcall (/usr/bin/python3.10+0x16070b)
    #63 0x56350afc782c in _PyObject_FastCallDictTstate (/usr/bin/python3.10+0x15582c)
    #64 0x56350afdd54b in _PyObject_Call_Prepend (/usr/bin/python3.10+0x16b54b)
    #65 0x56350b0f61df  (/usr/bin/python3.10+0x2841df)
    #66 0x56350afc85ea in _PyObject_MakeTpCall (/usr/bin/python3.10+0x1565ea)
    #67 0x56350afc1907 in _PyEval_EvalFrameDefault (/usr/bin/python3.10+0x14f907)
    #68 0x56350afd270b in _PyFunction_Vectorcall (/usr/bin/python3.10+0x16070b)
    #69 0x56350afbae0c in _PyEval_EvalFrameDefault (/usr/bin/python3.10+0x148e0c)
    #70 0x56350afd270b in _PyFunction_Vectorcall (/usr/bin/python3.10+0x16070b)
    #71 0x56350afbae0c in _PyEval_EvalFrameDefault (/usr/bin/python3.10+0x148e0c)
    #72 0x56350afd270b in _PyFunction_Vectorcall (/usr/bin/python3.10+0x16070b)
    #73 0x56350afbd2c0 in _PyEval_EvalFrameDefault (/usr/bin/python3.10+0x14b2c0)
    #74 0x56350afd270b in _PyFunction_Vectorcall (/usr/bin/python3.10+0x16070b)
    #75 0x56350afc08a1 in _PyEval_EvalFrameDefault (/usr/bin/python3.10+0x14e8a1)
    #76 0x56350afe04e0  (/usr/bin/python3.10+0x16e4e0)
    #77 0x56350afc08a1 in _PyEval_EvalFrameDefault (/usr/bin/python3.10+0x14e8a1)
    #78 0x56350afd270b in _PyFunction_Vectorcall (/usr/bin/python3.10+0x16070b)
    #79 0x56350afc782c in _PyObject_FastCallDictTstate (/usr/bin/python3.10+0x15582c)
    #80 0x56350afdd54b in _PyObject_Call_Prepend (/usr/bin/python3.10+0x16b54b)
    #81 0x56350b0f61df  (/usr/bin/python3.10+0x2841df)
    #82 0x56350afc85ea in _PyObject_MakeTpCall (/usr/bin/python3.10+0x1565ea)
    #83 0x56350afc1907 in _PyEval_EvalFrameDefault (/usr/bin/python3.10+0x14f907)
    #84 0x56350afd270b in _PyFunction_Vectorcall (/usr/bin/python3.10+0x16070b)
    #85 0x56350afbae0c in _PyEval_EvalFrameDefault (/usr/bin/python3.10+0x148e0c)
    #86 0x56350afd270b in _PyFunction_Vectorcall (/usr/bin/python3.10+0x16070b)
    #87 0x56350afbae0c in _PyEval_EvalFrameDefault (/usr/bin/python3.10+0x148e0c)
    #88 0x56350b0abe55  (/usr/bin/python3.10+0x239e55)
    #89 0x56350b0abcf5 in PyEval_EvalCode (/usr/bin/python3.10+0x239cf5)
    #90 0x56350b0d67d7  (/usr/bin/python3.10+0x2647d7)
    #91 0x56350b0d00ba  (/usr/bin/python3.10+0x25e0ba)
    #92 0x56350b0d6524  (/usr/bin/python3.10+0x264524)
    #93 0x56350b0d5a07 in _PyRun_SimpleFileObject (/usr/bin/python3.10+0x263a07)
    #94 0x56350b0d5652 in _PyRun_AnyFileObject (/usr/bin/python3.10+0x263652)
    #95 0x56350b0c841d in Py_RunMain (/usr/bin/python3.10+0x25641d)
    #96 0x56350b09ecac in Py_BytesMain (/usr/bin/python3.10+0x22ccac)
    #97 0x7f9536829d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
    #98 0x7f9536829e3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f)
    #99 0x56350b09eba4 in _start (/usr/bin/python3.10+0x22cba4)

0x60f000005498 is located 8 bytes to the left of 168-byte region [0x60f0000054a0,0x60f000005548)
allocated by thread T0 here:
    #0 0x7f952aab6357 in operator new[](unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:102
    #1 0x7f95300f4ff1 in modmesh::SimpleArray<double>::SimpleArray(unsigned long) (/home/runner/work/modmesh/modmesh/_modmesh.cpython-310-x86_64-linux-gnu.so+0x4cf4ff1)
    #2 0x7ffca3bfe80f  ([stack]+0x1880f)

SUMMARY: AddressSanitizer: heap-buffer-overflow (/home/runner/work/modmesh/modmesh/_modmesh.cpython-310-x86_64-linux-gnu.so+0x599dd44) in modmesh::spacetime::BadEuler1DSolver::march_half_so0(bool)
Shadow bytes around the buggy address:
  0x0c1e7fff8a40: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fa
  0x0c1e7fff8a50: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
  0x0c1e7fff8a60: fd fd fd fd fd fd fd fd fd fd fd fd fd fa fa fa
  0x0c1e7fff8a70: fa fa fa fa fa fa fd fd fd fd fd fd fd fd fd fd
  0x0c1e7fff8a80: fd fd fd fd fd fd fd fd fd fd fd fa fa fa fa fa
=>0x0c1e7fff8a90: fa fa fa[fa]00 00 00 00 00 00 00 00 00 00 00 00
  0x0c1e7fff8aa0: 00 00 00 00 00 00 00 00 00 fa fa fa fa fa fa fa
  0x0c1e7fff8ab0: fa fa 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c1e7fff8ac0: 00 00 00 00 00 00 00 fa fa fa fa fa fa fa fa fa
  0x0c1e7fff8ad0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c1e7fff8ae0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
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
  Shadow gap:              cc
==6149==ABORTING

Copy link
Member

@yungyuc yungyuc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank for the addition. This is wonderful! Some items to be improved.

  • Add the reference information.
  • Make it default off in CI. It can only be turned on after the code is clean with the sanitization.

I think it needs a separate PR to turn on the sanitizer in CI. But the building code can be added right away.

CMakeLists.txt Outdated
@@ -23,6 +23,8 @@ endif()
option(USE_CLANG_TIDY "use clang-tidy" OFF)
option(LINT_AS_ERRORS "clang-tidy warnings as errors" OFF)

option(USE_SANITIZER "use sanitizer" OFF)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add more information in the message about what sanitizer it is? And in the code comments, write down the reference and/or URL for the sanitizer.

@tigercosmos
Copy link
Collaborator Author

@yungyuc thanks for the review. The aforementioned two points are addressed, please take a look.

@@ -328,6 +341,19 @@ jobs:
run: |
make run_viewer_pytest VERBOSE=1

# FIXME: turn off until all issues resolved
- name: make cmake USE_SANITIZER=ON & make pytest
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test with sanitizer on macOS

@@ -196,6 +196,19 @@ jobs:
export LD_LIBRARY_PATH=$(python3 -c "import sys, os, shiboken6; sys.stdout.write(os.path.dirname(shiboken6.__file__))")
make run_viewer_pytest VERBOSE=0

# FIXME: turn off until all issues resolved
- name: make cmake USE_SANITIZER=ON & make pytest
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test with sanitizer on ubuntu

Copy link
Member

@yungyuc yungyuc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yungyuc yungyuc merged commit e1cea03 into solvcon:master Nov 28, 2023
11 checks passed
@yungyuc yungyuc added the test testing and continuous integration label Nov 28, 2023
@yungyuc
Copy link
Member

yungyuc commented Nov 28, 2023

ref #255

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

Successfully merging this pull request may close these issues.

2 participants