https://bugs.kde.org/show_bug.cgi?id=486812
Bug ID: 486812 Summary: Valgrind reports read errors reading a memory area that has been used as `sigaltstack` memory Classification: Developer tools Product: valgrind Version: 3.22.0 Platform: Other OS: Linux Status: REPORTED Severity: normal Priority: NOR Component: memcheck Assignee: jsew...@acm.org Reporter: m...@3v1n0.net Target Milestone: --- # SUMMARY Valgrind reports read errors in the stack when such memory area has been used as `sigaltstack` memory allocation. # STEPS TO REPRODUCE 1. Run the GLib `unix` test with --setup=valgrind Which implies running it with this command: /usr/bin/valgrind --tool=memcheck --error-exitcode=1 --track-origins=yes --leak-check=full --leak-resolution=high --num-callers=50 --show-leak-kinds=definite,possible --show-error-list=yes --suppressions=/data/GNOME/glib/tools/glib.supp /data/GNOME/_BUILD/glib/glib/tests/unix # OBSERVED RESULT The test fails with these unexpected errors ==451302== ==451302== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) ==451300== Invalid read of size 8 ==451300== at 0x48514EB: bcmp (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==451300== by 0x10BAF9: test_signal_alternate_stack (unix.c:594) ==451300== by 0x48E123A: test_case_run (gtestutils.c:2988) ==451300== by 0x48E123A: g_test_run_suite_internal (gtestutils.c:3090) ==451300== by 0x48E11B2: g_test_run_suite_internal (gtestutils.c:3109) ==451300== by 0x48E11B2: g_test_run_suite_internal (gtestutils.c:3109) ==451300== by 0x48E1711: g_test_run_suite (gtestutils.c:3189) ==451300== by 0x48E1797: g_test_run (gtestutils.c:2275) ==451300== by 0x10AAD3: main (unix.c:886) ==451300== Address 0x1ffeffd518 is on thread 1's stack ==451300== in frame #1, created by test_signal_alternate_stack (unix.c:574) ==451300== ==451300== Invalid read of size 1 ==451300== at 0x48514B9: bcmp (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==451300== by 0x10BAF9: test_signal_alternate_stack (unix.c:594) ==451300== by 0x48E123A: test_case_run (gtestutils.c:2988) ==451300== by 0x48E123A: g_test_run_suite_internal (gtestutils.c:3090) ==451300== by 0x48E11B2: g_test_run_suite_internal (gtestutils.c:3109) ==451300== by 0x48E11B2: g_test_run_suite_internal (gtestutils.c:3109) ==451300== by 0x48E1711: g_test_run_suite (gtestutils.c:3189) ==451300== by 0x48E1797: g_test_run (gtestutils.c:2275) ==451300== by 0x10AAD3: main (unix.c:886) ==451300== Address 0x1ffeffd598 is on thread 1's stack ==451300== in frame #1, created by test_signal_alternate_stack (unix.c:574) ==451300== ==451300== Invalid write of size 8 ==451300== at 0x4851CD3: memset (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==451300== by 0x10BB30: memset (string_fortified.h:59) ==451300== by 0x10BB30: test_signal_alternate_stack (unix.c:600) ==451300== by 0x48E123A: test_case_run (gtestutils.c:2988) ==451300== by 0x48E123A: g_test_run_suite_internal (gtestutils.c:3090) ==451300== by 0x48E11B2: g_test_run_suite_internal (gtestutils.c:3109) ==451300== by 0x48E11B2: g_test_run_suite_internal (gtestutils.c:3109) ==451300== by 0x48E1711: g_test_run_suite (gtestutils.c:3189) ==451300== by 0x48E1797: g_test_run (gtestutils.c:2275) ==451300== by 0x10AAD3: main (unix.c:886) ==451300== Address 0x1ffeffd518 is on thread 1's stack ==451300== in frame #1, created by test_signal_alternate_stack (string_fortified.h:574) ==451300== ==451300== Invalid write of size 8 ==451300== at 0x4851CCC: memset (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==451300== by 0x10BB30: memset (string_fortified.h:59) ==451300== by 0x10BB30: test_signal_alternate_stack (unix.c:600) ==451300== by 0x48E123A: test_case_run (gtestutils.c:2988) ==451300== by 0x48E123A: g_test_run_suite_internal (gtestutils.c:3090) ==451300== by 0x48E11B2: g_test_run_suite_internal (gtestutils.c:3109) ==451300== by 0x48E11B2: g_test_run_suite_internal (gtestutils.c:3109) ==451300== by 0x48E1711: g_test_run_suite (gtestutils.c:3189) ==451300== by 0x48E1797: g_test_run (gtestutils.c:2275) ==451300== by 0x10AAD3: main (unix.c:886) ==451300== Address 0x1ffeffd520 is on thread 1's stack ==451300== in frame #1, created by test_signal_alternate_stack (string_fortified.h:574) ==451300== ==451300== Invalid read of size 8 ==451300== at 0x48514EB: bcmp (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==451300== by 0x10BCF7: test_signal_alternate_stack (unix.c:601) ==451300== by 0x48E123A: test_case_run (gtestutils.c:2988) ==451300== by 0x48E123A: g_test_run_suite_internal (gtestutils.c:3090) ==451300== by 0x48E11B2: g_test_run_suite_internal (gtestutils.c:3109) ==451300== by 0x48E11B2: g_test_run_suite_internal (gtestutils.c:3109) ==451300== by 0x48E1711: g_test_run_suite (gtestutils.c:3189) ==451300== by 0x48E1797: g_test_run (gtestutils.c:2275) ==451300== by 0x10AAD3: main (unix.c:886) ==451300== Address 0x1ffeffd518 is on thread 1's stack ==451300== in frame #1, created by test_signal_alternate_stack (unix.c:574) ==451300== ==451300== Invalid read of size 8 ==451300== at 0x48514EB: bcmp (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==451300== by 0x10BCA7: test_signal_alternate_stack (unix.c:607) ==451300== by 0x48E123A: test_case_run (gtestutils.c:2988) ==451300== by 0x48E123A: g_test_run_suite_internal (gtestutils.c:3090) ==451300== by 0x48E11B2: g_test_run_suite_internal (gtestutils.c:3109) ==451300== by 0x48E11B2: g_test_run_suite_internal (gtestutils.c:3109) ==451300== by 0x48E1711: g_test_run_suite (gtestutils.c:3189) ==451300== by 0x48E1797: g_test_run (gtestutils.c:2275) ==451300== by 0x10AAD3: main (unix.c:886) ==451300== Address 0x1ffeffd518 is on thread 1's stack ==451300== in frame #1, created by test_signal_alternate_stack (unix.c:574) ==451300== ==451300== Invalid read of size 1 ==451300== at 0x48514B9: bcmp (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==451300== by 0x10BCA7: test_signal_alternate_stack (unix.c:607) ==451300== by 0x48E123A: test_case_run (gtestutils.c:2988) ==451300== by 0x48E123A: g_test_run_suite_internal (gtestutils.c:3090) ==451300== by 0x48E11B2: g_test_run_suite_internal (gtestutils.c:3109) ==451300== by 0x48E11B2: g_test_run_suite_internal (gtestutils.c:3109) ==451300== by 0x48E1711: g_test_run_suite (gtestutils.c:3189) ==451300== by 0x48E1797: g_test_run (gtestutils.c:2275) ==451300== by 0x10AAD3: main (unix.c:886) ==451300== Address 0x1ffeffd598 is on thread 1's stack ==451300== in frame #1, created by test_signal_alternate_stack (unix.c:574) ==451300== ** GLib:ERROR:../../glib/glib/tests/unix.c:607:test_signal_alternate_stack: assertion failed (stack_memory == zero_mem) # EXPECTED RESULT The test does not fail --- To note that, manually looping through the stack area checking for memory changes, also valgrind reports an error when we reach to a specific point (that is not fixed): Reading byte 2646 Reading byte 2647 Reading byte 2648 ==46100== Invalid read of size 1 ==46100== at 0x1098B4: test_signal_alternate_stack (unix.c:615) ==46100== by 0x1098B4: test_sighup_alternate_stack (unix.c:643) ==46100== by 0x48DF23A: test_case_run (gtestutils.c:2988) ==46100== by 0x48DF23A: g_test_run_suite_internal (gtestutils.c:3090) ==46100== by 0x48DF1B2: g_test_run_suite_internal (gtestutils.c:3109) ==46100== by 0x48DF1B2: g_test_run_suite_internal (gtestutils.c:3109) ==46100== by 0x48DF711: g_test_run_suite (gtestutils.c:3189) ==46100== by 0x48DF797: g_test_run (gtestutils.c:2275) ==46100== by 0x1093B8: main (unix.c:915) ==46100== Address 0x1ffeffce88 is on thread 1's stack ==46100== in frame #0, created by test_sighup_alternate_stack (unix.c:642) ==46100== Reading byte 2649 Reading byte 2650 Reading byte 2651 As further note, the same issue happens also when using dynamically or mmap'ed memory areas instead. Note that no error is happening for other sanitizers (ASAN in various in compilers), so my feeling is that this is due the way valgrind implements this. Coming from https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4050 -- You are receiving this mail because: You are watching all bug changes.