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 val-grind as a PR-checker #489

Open
kparichay opened this issue Mar 21, 2019 · 10 comments · Fixed by nnstreamer/nnstreamer#1361
Open

Add val-grind as a PR-checker #489

kparichay opened this issue Mar 21, 2019 · 10 comments · Fixed by nnstreamer/nnstreamer#1361

Comments

@kparichay
Copy link
Member

Wanted to opinion about adding val-grind as a PR-checker.
val-grind is known to have issues with false positives but glib maintains a suppression file to suppress such issues with their code. More suppression file can be taken as an input from the user as well.

If you think its a good idea, I will open a PR.

@taos-ci
Copy link
Collaborator

taos-ci commented Mar 21, 2019

:octocat: cibot: Thank you for posting issue #489. The person in charge will reply soon.

@leemgs
Copy link
Collaborator

leemgs commented Mar 22, 2019

@myungjoo
Copy link
Member

If you can create a machine-readable results with valgrind and results good enough to be enforced for every PR, it is great!

@kparichay
Copy link
Member Author

kparichay commented Apr 8, 2019

Supporting valgrind without --leak-check=full seems feasible with some of the current test cases I tried (unittest_common, plugins, repo, sink and src_iio).
However, running with valgrind exposes a deadlock issue inside gstreamer for both unittest_sink and unittest_src. The issues arises from the internals of gstreamer.
For src_iio, the deadlock happens when transitioning to PAUSED state from READY state. The function gst_base_src_start_complete() is waiting for the lock to be released which is never released. The filtered debug log is:

0:00:15.393980575 18575      0x82a2c20 DEBUG             GST_STATES gstelement.c:2561:gst_element_set_state_func:<pipeline2> current READY, old_pending VOID_PENDING, next VOID_PENDING, old return SUCCESS
0:00:15.394381284 18575      0x82a2c20 DEBUG             GST_STATES gstbin.c:2664:gst_bin_change_state_func:<pipeline2> changing state of children from READY to PAUSED
0:00:15.400072879 18575      0x82a2c20 DEBUG             GST_STATES gstelement.c:2561:gst_element_set_state_func:<tensorsrciio4> current READY, old_pending VOID_PENDING, next VOID_PENDING, old return SUCCESS
0:00:15.400192833 18575      0x82a2c20 DEBUG             GST_STATES gstelement.c:2595:gst_element_set_state_func:<tensorsrciio4> final: setting state from READY to PAUSED
0:00:15.439533208 18575      0x88a82d0 DEBUG                basesrc gstbasesrc.c:523:gst_base_src_wait_playing:<tensorsrciio4> live source waiting for running state

More info from the gdb with valgrind -

(gdb) bt full
#0  __lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
No locals.
#1  0x00000000060e3e42 in __GI___pthread_mutex_lock (mutex=0xa7e7680) at ../nptl/pthread_mutex_lock.c:115
        id = 101622381
        __PRETTY_FUNCTION__ = "__pthread_mutex_lock"
        type = 1
        id = <optimized out>
#2  0x00000000066f42d3 in gst_base_src_start_complete () from /usr/lib/x86_64-linux-gnu/libgstbase-1.0.so.0
No symbol table info available.
#3  0x00000000066f4a1b in ?? () from /usr/lib/x86_64-linux-gnu/libgstbase-1.0.so.0
No symbol table info available.
#4  0x00000000066f4d68 in ?? () from /usr/lib/x86_64-linux-gnu/libgstbase-1.0.so.0
No symbol table info available.
#5  0x0000000005418537 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#6  0x0000000005418d0c in gst_pad_set_active () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#7  0x00000000053fadbd in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#8  0x000000000540b22c in gst_iterator_fold () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#9  0x00000000053fb21a in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#10 0x00000000053fcfaf in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#11 0x00000000053fd247 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#12 0x00000000066f2bbd in ?? () from /usr/lib/x86_64-linux-gnu/libgstbase-1.0.so.0
No symbol table info available.
#13 0x00000000053ff1ce in gst_element_change_state () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#14 0x00000000053ff947 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#15 0x00000000053de365 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#16 0x00000000053ff1ce in gst_element_change_state () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#17 0x00000000053ff947 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#18 0x0000000000412497 in test_tensor_src_iio_data_verify_no_trigger_bits32_alternate2_Test::TestBody (this=0xa7d2c00)
    at ../tests/nnstreamer_source/unittest_src_iio.cpp:1145
---Type <return> to continue, or q <return> to quit---
        dev0 = 0xa7d0140
        src_iio_pipeline = 0xa7fa8f0
        status = GST_STATE_CHANGE_SUCCESS
        state = GST_STATE_VOID_PENDING
        parse_launch = 0xa7e5690 "tensor_src_iio device=test-device-1 silent=FALSE ! multifilesink location=/tmp/nnst-src-7PVQZZ/temp.log"
        data_value = 98
        samp_freq = 1000
        data_bits = 32
        fd = 15
        bytes_to_read = 0
        bytes_read = 0
        data_buffer = 0x0
        expect_val = 3.40016132e-35
        actual_val = 0
        expect_val_mask = 13
        expect_val_char = 0x5b <error: Cannot access memory at address 0x5b>
        actual_val_char = 0xd <error: Cannot access memory at address 0xd>
        stat_buf = {st_dev = 4098, st_ino = 99359050, st_nlink = 21474836486, st_mode = 2419617024, st_uid = 96960311, 
          st_gid = 4, __pad0 = 0, st_rdev = 96867266, st_size = 4427248, st_blksize = 416441367174606080, 
          st_blocks = 175982624, st_atim = {tv_sec = 68702694848, tv_nsec = 4375412}, st_mtim = {tv_sec = 0, 
            tv_nsec = 17}, st_ctim = {tv_sec = 96868073, tv_nsec = 175982416}, __glibc_reserved = {4429819, 0, 
            4427672}}
        stat_ret = -16781680
        __FUNCTION__ = "TestBody"
#19 0x0000000000443852 in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void> (
    object=0xa7d2c00, method=&virtual testing::Test::TestBody(), location=0x451e3b "the test body")
    at /usr/src/gtest/src/gtest.cc:2078
No locals.
#20 0x000000000043ea75 in testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void> (
    object=0xa7d2c00, method=&virtual testing::Test::TestBody(), location=0x451e3b "the test body")
    at /usr/src/gtest/src/gtest.cc:2114
No locals.
#21 0x00000000004248b8 in testing::Test::Run (this=0xa7d2c00) at /usr/src/gtest/src/gtest.cc:2151
        impl = 0x828f6d0
#22 0x00000000004250ea in testing::TestInfo::Run (this=0x8292450) at /usr/src/gtest/src/gtest.cc:2326
        impl = 0x828f6d0
        repeater = 0x828f920
        start = 1554712029886
        test = 0xa7d2c00
#23 0x0000000000425751 in testing::TestCase::Run (this=0x828fec0) at /usr/src/gtest/src/gtest.cc:2444
---Type <return> to continue, or q <return> to quit---
        i = 7
        impl = 0x828f6d0
        repeater = 0x828f920
        start = 1554712006878
#24 0x000000000042c62c in testing::internal::UnitTestImpl::RunAllTests (this=0x828f6d0)
    at /usr/src/gtest/src/gtest.cc:4315
        test_index = 0
        start = 1554712006851
        i = 0
        in_subprocess_for_death_test = false
        should_shard = false
        has_tests_to_run = true
        failed = false
        repeater = 0x828f920
        repeat = 1
        forever = false
#25 0x00000000004447a5 in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (object=0x828f6d0, 
    method=(bool (testing::internal::UnitTestImpl::*)(testing::internal::UnitTestImpl * const)) 0x42c374 <testing::internal::UnitTestImpl::RunAllTests()>, location=0x4526d0 "auxiliary test code (environments or event listeners)")
    at /usr/src/gtest/src/gtest.cc:2078
No locals.
#26 0x000000000043f8b5 in testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>
    (object=0x828f6d0, 
    method=(bool (testing::internal::UnitTestImpl::*)(testing::internal::UnitTestImpl * const)) 0x42c374 <testing::internal::UnitTestImpl::RunAllTests()>, location=0x4526d0 "auxiliary test code (environments or event listeners)")
    at /usr/src/gtest/src/gtest.cc:2114
No locals.
#27 0x000000000042b224 in testing::UnitTest::Run (this=0x66fd00 <testing::UnitTest::GetInstance()::instance>)
    at /usr/src/gtest/src/gtest.cc:3926
        in_death_test_child_process = false
        premature_exit_file = {premature_exit_filepath_ = 0x0}
#28 0x000000000041aab8 in RUN_ALL_TESTS () at /usr/include/gtest/gtest.h:2288
No locals.
#29 0x000000000041a3e8 in main (argc=1, argv=0xffefff278) at ../tests/nnstreamer_source/unittest_src_iio.cpp:1253
No locals.
(gdb) info threads
  Id   Target Id         Frame 
* 1    Thread 20202 (tid 1 VgTs_Runnable) __lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
  2    Thread 20456 (tid 2 VgTs_WaitSys tensorsrciio7:sr) syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38

I was unable to reproduce the same issue over 12 hours of run on my pc without valgrind though. Note that tensor_src_iio uses no locks, and relies on gstbasesrc (and its parent classes) to use locks effectively.

A similar issue (deadlock while using valgrind) has also been reported here before (http://gstreamer-devel.966125.n4.nabble.com/Deadlock-under-valgrind-tsdemux-fault-td4663281.html). However, I cannot the issue being posted on bugzilla as replied by the followup in the post.

@kparichay
Copy link
Member Author

Supporting valgrind without --leak-check=full seems feasible with some of the current test cases I tried (unittest_common, plugins, repo, sink and src_iio).
However, running with valgrind exposes a deadlock issue inside gstreamer for both unittest_sink and unittest_src. The issues arises from the internals of gstreamer.
For src_iio, the deadlock happens when transitioning to PAUSED state from READY state. The function gst_base_src_start_complete() is waiting for the lock to be released which is never released. The filtered debug log is:

0:00:15.393980575 18575      0x82a2c20 DEBUG             GST_STATES gstelement.c:2561:gst_element_set_state_func:<pipeline2> current READY, old_pending VOID_PENDING, next VOID_PENDING, old return SUCCESS
0:00:15.394381284 18575      0x82a2c20 DEBUG             GST_STATES gstbin.c:2664:gst_bin_change_state_func:<pipeline2> changing state of children from READY to PAUSED
0:00:15.400072879 18575      0x82a2c20 DEBUG             GST_STATES gstelement.c:2561:gst_element_set_state_func:<tensorsrciio4> current READY, old_pending VOID_PENDING, next VOID_PENDING, old return SUCCESS
0:00:15.400192833 18575      0x82a2c20 DEBUG             GST_STATES gstelement.c:2595:gst_element_set_state_func:<tensorsrciio4> final: setting state from READY to PAUSED
0:00:15.439533208 18575      0x88a82d0 DEBUG                basesrc gstbasesrc.c:523:gst_base_src_wait_playing:<tensorsrciio4> live source waiting for running state

More info from the gdb with valgrind -

(gdb) bt full
#0  __lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
No locals.
#1  0x00000000060e3e42 in __GI___pthread_mutex_lock (mutex=0xa7e7680) at ../nptl/pthread_mutex_lock.c:115
        id = 101622381
        __PRETTY_FUNCTION__ = "__pthread_mutex_lock"
        type = 1
        id = <optimized out>
#2  0x00000000066f42d3 in gst_base_src_start_complete () from /usr/lib/x86_64-linux-gnu/libgstbase-1.0.so.0
No symbol table info available.
#3  0x00000000066f4a1b in ?? () from /usr/lib/x86_64-linux-gnu/libgstbase-1.0.so.0
No symbol table info available.
#4  0x00000000066f4d68 in ?? () from /usr/lib/x86_64-linux-gnu/libgstbase-1.0.so.0
No symbol table info available.
#5  0x0000000005418537 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#6  0x0000000005418d0c in gst_pad_set_active () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#7  0x00000000053fadbd in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#8  0x000000000540b22c in gst_iterator_fold () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#9  0x00000000053fb21a in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#10 0x00000000053fcfaf in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#11 0x00000000053fd247 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#12 0x00000000066f2bbd in ?? () from /usr/lib/x86_64-linux-gnu/libgstbase-1.0.so.0
No symbol table info available.
#13 0x00000000053ff1ce in gst_element_change_state () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#14 0x00000000053ff947 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#15 0x00000000053de365 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#16 0x00000000053ff1ce in gst_element_change_state () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#17 0x00000000053ff947 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
No symbol table info available.
#18 0x0000000000412497 in test_tensor_src_iio_data_verify_no_trigger_bits32_alternate2_Test::TestBody (this=0xa7d2c00)
    at ../tests/nnstreamer_source/unittest_src_iio.cpp:1145
---Type <return> to continue, or q <return> to quit---
        dev0 = 0xa7d0140
        src_iio_pipeline = 0xa7fa8f0
        status = GST_STATE_CHANGE_SUCCESS
        state = GST_STATE_VOID_PENDING
        parse_launch = 0xa7e5690 "tensor_src_iio device=test-device-1 silent=FALSE ! multifilesink location=/tmp/nnst-src-7PVQZZ/temp.log"
        data_value = 98
        samp_freq = 1000
        data_bits = 32
        fd = 15
        bytes_to_read = 0
        bytes_read = 0
        data_buffer = 0x0
        expect_val = 3.40016132e-35
        actual_val = 0
        expect_val_mask = 13
        expect_val_char = 0x5b <error: Cannot access memory at address 0x5b>
        actual_val_char = 0xd <error: Cannot access memory at address 0xd>
        stat_buf = {st_dev = 4098, st_ino = 99359050, st_nlink = 21474836486, st_mode = 2419617024, st_uid = 96960311, 
          st_gid = 4, __pad0 = 0, st_rdev = 96867266, st_size = 4427248, st_blksize = 416441367174606080, 
          st_blocks = 175982624, st_atim = {tv_sec = 68702694848, tv_nsec = 4375412}, st_mtim = {tv_sec = 0, 
            tv_nsec = 17}, st_ctim = {tv_sec = 96868073, tv_nsec = 175982416}, __glibc_reserved = {4429819, 0, 
            4427672}}
        stat_ret = -16781680
        __FUNCTION__ = "TestBody"
#19 0x0000000000443852 in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void> (
    object=0xa7d2c00, method=&virtual testing::Test::TestBody(), location=0x451e3b "the test body")
    at /usr/src/gtest/src/gtest.cc:2078
No locals.
#20 0x000000000043ea75 in testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void> (
    object=0xa7d2c00, method=&virtual testing::Test::TestBody(), location=0x451e3b "the test body")
    at /usr/src/gtest/src/gtest.cc:2114
No locals.
#21 0x00000000004248b8 in testing::Test::Run (this=0xa7d2c00) at /usr/src/gtest/src/gtest.cc:2151
        impl = 0x828f6d0
#22 0x00000000004250ea in testing::TestInfo::Run (this=0x8292450) at /usr/src/gtest/src/gtest.cc:2326
        impl = 0x828f6d0
        repeater = 0x828f920
        start = 1554712029886
        test = 0xa7d2c00
#23 0x0000000000425751 in testing::TestCase::Run (this=0x828fec0) at /usr/src/gtest/src/gtest.cc:2444
---Type <return> to continue, or q <return> to quit---
        i = 7
        impl = 0x828f6d0
        repeater = 0x828f920
        start = 1554712006878
#24 0x000000000042c62c in testing::internal::UnitTestImpl::RunAllTests (this=0x828f6d0)
    at /usr/src/gtest/src/gtest.cc:4315
        test_index = 0
        start = 1554712006851
        i = 0
        in_subprocess_for_death_test = false
        should_shard = false
        has_tests_to_run = true
        failed = false
        repeater = 0x828f920
        repeat = 1
        forever = false
#25 0x00000000004447a5 in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (object=0x828f6d0, 
    method=(bool (testing::internal::UnitTestImpl::*)(testing::internal::UnitTestImpl * const)) 0x42c374 <testing::internal::UnitTestImpl::RunAllTests()>, location=0x4526d0 "auxiliary test code (environments or event listeners)")
    at /usr/src/gtest/src/gtest.cc:2078
No locals.
#26 0x000000000043f8b5 in testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>
    (object=0x828f6d0, 
    method=(bool (testing::internal::UnitTestImpl::*)(testing::internal::UnitTestImpl * const)) 0x42c374 <testing::internal::UnitTestImpl::RunAllTests()>, location=0x4526d0 "auxiliary test code (environments or event listeners)")
    at /usr/src/gtest/src/gtest.cc:2114
No locals.
#27 0x000000000042b224 in testing::UnitTest::Run (this=0x66fd00 <testing::UnitTest::GetInstance()::instance>)
    at /usr/src/gtest/src/gtest.cc:3926
        in_death_test_child_process = false
        premature_exit_file = {premature_exit_filepath_ = 0x0}
#28 0x000000000041aab8 in RUN_ALL_TESTS () at /usr/include/gtest/gtest.h:2288
No locals.
#29 0x000000000041a3e8 in main (argc=1, argv=0xffefff278) at ../tests/nnstreamer_source/unittest_src_iio.cpp:1253
No locals.
(gdb) info threads
  Id   Target Id         Frame 
* 1    Thread 20202 (tid 1 VgTs_Runnable) __lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
  2    Thread 20456 (tid 2 VgTs_WaitSys tensorsrciio7:sr) syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38

I was unable to reproduce the same issue over 12 hours of run on my pc without valgrind though. Note that tensor_src_iio uses no locks, and relies on gstbasesrc (and its parent classes) to use locks effectively.

A similar issue (deadlock while using valgrind) has also been reported here before (http://gstreamer-devel.966125.n4.nabble.com/Deadlock-under-valgrind-tsdemux-fault-td4663281.html). However, I cannot the issue being posted on bugzilla as replied by the followup in the post.

This issue has been resolved with nnstreamer/nnstreamer#1359

@kparichay
Copy link
Member Author

kparichay commented Apr 12, 2019

Issue with unittest_sink resolved with correct paths and nnstreamer/nnstreamer#1361 .

@myungjoo
Copy link
Member

Both Tizen-OBS and Ubuntu-PPA should now support the updated SSAT with the option -vg. Please try them.

@kparichay
Copy link
Member Author

kparichay commented Apr 16, 2019

@kparichay
Copy link
Member Author

Both Tizen-OBS and Ubuntu-PPA should now support the updated SSAT with the option -vg. Please try them.

Verified that it works.

@leemgs
Copy link
Collaborator

leemgs commented Jun 26, 2020

How to use Valgrind on Gstreamer/NNStramer

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

Successfully merging a pull request may close this issue.

4 participants