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

Tests fail when compiled with UBSan #224

Closed
ceeac opened this issue Oct 10, 2022 · 2 comments
Closed

Tests fail when compiled with UBSan #224

ceeac opened this issue Oct 10, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@ceeac
Copy link

ceeac commented Oct 10, 2022

OS: Ubuntu 22.04
Commit: 3628823

Tests fail to complete successfully when they are compiled with Undefined Behaviour Sanitizer ("-fsanitize=undefined").

Steps to reproduce:

mkdir build
cd build
CC=clang-12 CXX=clang++-12 cmake -DCMAKE_CXX_FLAGS="-fsanitize=undefined -fno-sanitize-recover=all" -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=undefined" ..
make
ctest --output-on-failure

Result:

$ ctest --output-on-failure 
Test project /home/ceeac/Projects/code/Heimer/build
    Start 1: editor_data_test
1/6 Test #1: editor_data_test .................***Failed    0.33 sec
********* Start testing of EditorDataTest *********
Config: Using QtTest library 5.15.3, Qt 5.15.3 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 11.3.0), ubuntu 22.04
PASS   : EditorDataTest::initTestCase()
/home/ceeac/Projects/code/Heimer/src/edge.cpp:507:94: runtime error: member call on address 0x0000020f1e10 which does not point to an object of type 'Node'
0x0000020f1e10: note: object is of type 'QObject'
 84 af 78 12  00 bf e5 fb 29 7f 00 00  80 58 0f 02 00 00 00 00  08 95 da fc 29 7f 00 00  a0 a5 0f 02
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for 'QObject'
    #0 0x4e5eb3 in Edge::~Edge() (/media/ceeac/Projects/code/Heimer/build/unit_tests/editor_data_test+0x4e5eb3)
    #1 0x4bab7a in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() (/media/ceeac/Projects/code/Heimer/build/unit_tests/editor_data_test+0x4bab7a)
    #2 0x4ba3a3 in std::vector<std::shared_ptr<Edge>, std::allocator<std::shared_ptr<Edge> > >::~vector() (/media/ceeac/Projects/code/Heimer/build/unit_tests/editor_data_test+0x4ba3a3)
    #3 0x50ef1a in Graph::~Graph() (/media/ceeac/Projects/code/Heimer/build/unit_tests/editor_data_test+0x50ef1a)
    #4 0x5577b2 in MindMapData::~MindMapData() (/media/ceeac/Projects/code/Heimer/build/unit_tests/editor_data_test+0x5577b2)
    #5 0x4bab7a in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() (/media/ceeac/Projects/code/Heimer/build/unit_tests/editor_data_test+0x4bab7a)
    #6 0x4a079e in EditorDataTest::testAddAndDeleteEdge() (/media/ceeac/Projects/code/Heimer/build/unit_tests/editor_data_test+0x4a079e)
    #7 0x7f29fbbc925a in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const src/corelib/kernel/qmetaobject.cpp:2303:25
    #8 0x7f29fce74382  (/usr/lib/x86_64-linux-gnu/libQt5Test.so.5+0x1c382)
    #9 0x7f29fce74e1a  (/usr/lib/x86_64-linux-gnu/libQt5Test.so.5+0x1ce1a)
    #10 0x7f29fce75378  (/usr/lib/x86_64-linux-gnu/libQt5Test.so.5+0x1d378)
    #11 0x7f29fce75863 in QTest::qRun() (/usr/lib/x86_64-linux-gnu/libQt5Test.so.5+0x1d863)
    #12 0x7f29fce75c3f in QTest::qExec(QObject*, int, char**) (/usr/lib/x86_64-linux-gnu/libQt5Test.so.5+0x1dc3f)
    #13 0x4ba0e3 in main (/media/ceeac/Projects/code/Heimer/build/unit_tests/editor_data_test+0x4ba0e3)
    #14 0x7f29fb3d4d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #15 0x7f29fb3d4e3f in __libc_start_main csu/../csu/libc-start.c:392:3
    #16 0x47b5e4 in _start (/media/ceeac/Projects/code/Heimer/build/unit_tests/editor_data_test+0x47b5e4)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/ceeac/Projects/code/Heimer/src/edge.cpp:507:94 in 

    Start 2: graph_test
2/6 Test #2: graph_test .......................***Failed    0.33 sec
********* Start testing of GraphTest *********
Config: Using QtTest library 5.15.3, Qt 5.15.3 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 11.3.0), ubuntu 22.04
PASS   : GraphTest::initTestCase()
PASS   : GraphTest::testAddEdge()
PASS   : GraphTest::testAddNode()
PASS   : GraphTest::testAddTwoNodes()
PASS   : GraphTest::testAreNodesDirectlyConnected()
/home/ceeac/Projects/code/Heimer/src/edge.cpp:507:94: runtime error: member call on address 0x000001dddad0 which does not point to an object of type 'Node'
0x000001dddad0: note: object is of type 'QObject'
 38 c5 8e 00  00 2f 4f bb 2d 7f 00 00  f0 bf e0 01 00 00 00 00  08 65 48 bc 2d 7f 00 00  10 78 e0 01
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for 'QObject'
    #0 0x4cf713 in Edge::~Edge() (/media/ceeac/Projects/code/Heimer/build/unit_tests/graph_test+0x4cf713)
    #1 0x4a4b3a in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() (/media/ceeac/Projects/code/Heimer/build/unit_tests/graph_test+0x4a4b3a)
    #2 0x4a45e3 in std::vector<std::shared_ptr<Edge>, std::allocator<std::shared_ptr<Edge> > >::~vector() (/media/ceeac/Projects/code/Heimer/build/unit_tests/graph_test+0x4a45e3)
    #3 0x4f8d6a in Graph::~Graph() (/media/ceeac/Projects/code/Heimer/build/unit_tests/graph_test+0x4f8d6a)
    #4 0x4a0ac4 in GraphTest::testDeleteEdge() (/media/ceeac/Projects/code/Heimer/build/unit_tests/graph_test+0x4a0ac4)
    #5 0x7f2dbb26025a in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const src/corelib/kernel/qmetaobject.cpp:2303:25
    #6 0x7f2dbc50b382  (/usr/lib/x86_64-linux-gnu/libQt5Test.so.5+0x1c382)
    #7 0x7f2dbc50be1a  (/usr/lib/x86_64-linux-gnu/libQt5Test.so.5+0x1ce1a)
    #8 0x7f2dbc50c378  (/usr/lib/x86_64-linux-gnu/libQt5Test.so.5+0x1d378)
    #9 0x7f2dbc50c863 in QTest::qRun() (/usr/lib/x86_64-linux-gnu/libQt5Test.so.5+0x1d863)
    #10 0x7f2dbc50cc3f in QTest::qExec(QObject*, int, char**) (/usr/lib/x86_64-linux-gnu/libQt5Test.so.5+0x1dc3f)
    #11 0x4a3463 in main (/media/ceeac/Projects/code/Heimer/build/unit_tests/graph_test+0x4a3463)
    #12 0x7f2dbaa6bd8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #13 0x7f2dbaa6be3f in __libc_start_main csu/../csu/libc-start.c:392:3
    #14 0x47a594 in _start (/media/ceeac/Projects/code/Heimer/build/unit_tests/graph_test+0x47a594)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/ceeac/Projects/code/Heimer/src/edge.cpp:507:94 in 

    Start 3: layout_optimizer_test
3/6 Test #3: layout_optimizer_test ............   Passed    5.48 sec
    Start 4: node_test
4/6 Test #4: node_test ........................   Passed    0.01 sec
    Start 5: serializer_test
5/6 Test #5: serializer_test ..................***Failed    0.33 sec
********* Start testing of SerializerTest *********
Config: Using QtTest library 5.15.3, Qt 5.15.3 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 11.3.0), ubuntu 22.04
PASS   : SerializerTest::initTestCase()
PASS   : SerializerTest::testEmptyDesign()
PASS   : SerializerTest::testArrowSize()
PASS   : SerializerTest::testBackgroundColor()
PASS   : SerializerTest::testCornerRadius()
PASS   : SerializerTest::testEdgeColor()
PASS   : SerializerTest::testEdgeWidth()
PASS   : SerializerTest::testFontItalic()
PASS   : SerializerTest::testFontNonItalic()
PASS   : SerializerTest::testFontBold()
PASS   : SerializerTest::testFontNonBold()
PASS   : SerializerTest::testFontOverline()
PASS   : SerializerTest::testFontNonOverline()
PASS   : SerializerTest::testFontStrikeOut()
PASS   : SerializerTest::testFontNonStrikeOut()
PASS   : SerializerTest::testFontUnderline()
PASS   : SerializerTest::testFontNonUnderline()
PASS   : SerializerTest::testGridColor()
PASS   : SerializerTest::testLayoutOptimizer()
PASS   : SerializerTest::testNotUsedImages()
/home/ceeac/Projects/code/Heimer/src/edge.cpp:507:94: runtime error: member call on address 0x00000270ee10 which does not point to an object of type 'Node'
0x00000270ee10: note: object is of type 'QObject'
 d7 53 a1 7e  00 ff f5 7c e7 7f 00 00  40 04 71 02 00 00 00 00  08 d5 ea 7d e7 7f 00 00  a0 70 71 02
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for 'QObject'
    #0 0x4df563 in Edge::~Edge() (/media/ceeac/Projects/code/Heimer/build/unit_tests/serializer_test+0x4df563)
    #1 0x4a793a in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() (/media/ceeac/Projects/code/Heimer/build/unit_tests/serializer_test+0x4a793a)
    #2 0x4a7263 in std::vector<std::shared_ptr<Edge>, std::allocator<std::shared_ptr<Edge> > >::~vector() (/media/ceeac/Projects/code/Heimer/build/unit_tests/serializer_test+0x4a7263)
    #3 0x5089aa in Graph::~Graph() (/media/ceeac/Projects/code/Heimer/build/unit_tests/serializer_test+0x5089aa)
    #4 0x551002 in MindMapData::~MindMapData() (/media/ceeac/Projects/code/Heimer/build/unit_tests/serializer_test+0x551002)
    #5 0x4a46c2 in SerializerTest::testNodeDeletion() (/media/ceeac/Projects/code/Heimer/build/unit_tests/serializer_test+0x4a46c2)
    #6 0x7fe77cccd25a in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const src/corelib/kernel/qmetaobject.cpp:2303:25
    #7 0x7fe77df78382  (/usr/lib/x86_64-linux-gnu/libQt5Test.so.5+0x1c382)
    #8 0x7fe77df78e1a  (/usr/lib/x86_64-linux-gnu/libQt5Test.so.5+0x1ce1a)
    #9 0x7fe77df79378  (/usr/lib/x86_64-linux-gnu/libQt5Test.so.5+0x1d378)
    #10 0x7fe77df79863 in QTest::qRun() (/usr/lib/x86_64-linux-gnu/libQt5Test.so.5+0x1d863)
    #11 0x7fe77df79c3f in QTest::qExec(QObject*, int, char**) (/usr/lib/x86_64-linux-gnu/libQt5Test.so.5+0x1dc3f)
    #12 0x4a6d33 in main (/media/ceeac/Projects/code/Heimer/build/unit_tests/serializer_test+0x4a6d33)
    #13 0x7fe77c4d8d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #14 0x7fe77c4d8e3f in __libc_start_main csu/../csu/libc-start.c:392:3
    #15 0x47b604 in _start (/media/ceeac/Projects/code/Heimer/build/unit_tests/serializer_test+0x47b604)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/ceeac/Projects/code/Heimer/src/edge.cpp:507:94 in 

    Start 6: version_test
6/6 Test #6: version_test .....................   Passed    0.01 sec

50% tests passed, 3 tests failed out of 6

Total Test time (real) =   6.49 sec

The following tests FAILED:
	  1 - editor_data_test (Failed)
	  2 - graph_test (Failed)
	  5 - serializer_test (Failed)
Errors while running CTest
@juzzlin
Copy link
Owner

juzzlin commented Oct 10, 2022

Thanks for reporting! I'll look into this.

@juzzlin juzzlin self-assigned this Oct 10, 2022
@juzzlin juzzlin added the bug Something isn't working label Oct 10, 2022
juzzlin added a commit that referenced this issue Oct 10, 2022
- Force deletion order of soft-deleted edges and soft-deleted nodes
- Solve some deletion order problems in unit tests
@juzzlin
Copy link
Owner

juzzlin commented Oct 10, 2022

Please try this: 50fd171

@juzzlin juzzlin closed this as completed Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants