dunst-project / dunst

Lightweight and customizable notification daemon
https://dunst-project.org
Other
4.44k stars 338 forks source link

Test program has segfault #1228

Closed apprehensions closed 3 months ago

apprehensions commented 8 months ago
~/src/dunst-og $ make test-valgrind
valgrind \
        --suppressions=.valgrind.suppressions \
        --leak-check=full \
        --show-leak-kinds=definite \
        --errors-for-leak-kinds=definite \
        --num-callers=40 \
        --error-exitcode=123 \
        ./test/test -v
==17713== Memcheck, a memory error detector
==17713== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==17713== Using Valgrind-3.21.0 and LibVEX; rerun with -h for copyright info
==17713== Command: ./test/test -v
==17713== 

* Suite suite_utils:
PASS test_string_replace_char:  (1081 ticks, 0.001 sec)
PASS test_string_replace_all:  (2692 ticks, 0.002 sec)
PASS test_string_append:  (2841 ticks, 0.002 sec)
PASS test_string_strip_quotes:  (1186 ticks, 0.001 sec)
PASS test_string_strip_delimited:  (2480 ticks, 0.002 sec)
PASS test_string_to_path:  (1484 ticks, 0.001 sec)
PASS test_string_to_time:  (1038 ticks, 0.001 sec)

7 tests - 7 passed, 0 failed, 0 skipped (22409 ticks, 0.022 sec)

* Suite suite_option_parser:
PASS test_cmdline_get_string:  (2322 ticks, 0.002 sec)
PASS test_cmdline_get_list:  (1930 ticks, 0.001 sec)
PASS test_cmdline_get_path:  (1033 ticks, 0.001 sec)
PASS test_cmdline_get_int:  (2041 ticks, 0.002 sec)
SKIP test_cmdline_get_double: Skipping test_cmdline_get_double, as it seems we're running under musl+valgrind! (6486 ticks, 0.006 sec)
PASS test_cmdline_get_bool:  (964 ticks, 0.000 sec)
PASS test_cmdline_create_usage:  (3585 ticks, 0.003 sec)
PASS test_string_to_int:  (1064 ticks, 0.001 sec)
PASS test_string_to_int_invalid:  (1231 ticks, 0.001 sec)
SKIP test_string_to_double: Skipping test_string_to_double, as it seems we're running under musl+valgrind! (183 ticks, 0.000 sec)
PASS test_string_to_double_invalid:  (2142 ticks, 0.002 sec)
PASS test_string_to_enum:  (651 ticks, 0.000 sec)
PASS test_string_to_enum_invalid:  (842 ticks, 0.000 sec)
PASS test_string_to_boolean:  (976 ticks, 0.000 sec)
PASS test_string_to_boolean_invalid:  (789 ticks, 0.000 sec)
PASS test_string_to_list:  (2118 ticks, 0.002 sec)
PASS test_string_to_list_invalid:  (1718 ticks, 0.001 sec)
PASS test_string_to_time:  (1053 ticks, 0.001 sec)
PASS test_string_to_time_invalid:  (1478 ticks, 0.001 sec)
PASS test_string_to_path:  (1845 ticks, 0.001 sec)
PASS test_string_to_sepcolor:  (1804 ticks, 0.001 sec)
PASS test_string_to_sepcolor_invalid:  (1301 ticks, 0.001 sec)
PASS test_enum_size:  (147 ticks, 0.000 sec)
PASS test_string_to_length:  (2132 ticks, 0.002 sec)
PASS test_string_to_length_invalid:  (1954 ticks, 0.001 sec)

25 tests - 23 passed, 0 failed, 2 skipped (45283 ticks, 0.045 sec)

* Suite suite_notification:
PASS test_notification_is_duplicate:  (4335 ticks, 0.004 sec)
PASS test_notification_replace_single_field:  (4723 ticks, 0.004 sec)
PASS test_notification_referencing:  (638 ticks, 0.000 sec)
==17713== Invalid read of size 8
==17713==    at 0x4B07C50: cairo_image_surface_get_width (in /usr/lib/libcairo.so.2.11800.0)
==17713==    by 0x12CA4E: get_icon_width (icon.c:87)
==17713==    by 0x1357D1: test_notification_icon_scaling_toosmall (notification.c:154)
==17713==    by 0x1357D1: suite_notification (notification.c:240)
==17713==    by 0x149DB0: greatest_run_suite (test.c:33)
==17713==    by 0x149DB0: greatest_run_suite (test.c:33)
==17713==    by 0x11FBDF: main (test.c:57)
==17713==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==17713== 
==17713== 
==17713== Process terminating with default action of signal 11 (SIGSEGV)
==17713==  Access not within mapped region at address 0x0
==17713==    at 0x4B07C50: cairo_image_surface_get_width (in /usr/lib/libcairo.so.2.11800.0)
==17713==    by 0x12CA4E: get_icon_width (icon.c:87)
==17713==    by 0x1357D1: test_notification_icon_scaling_toosmall (notification.c:154)
==17713==    by 0x1357D1: suite_notification (notification.c:240)
==17713==    by 0x149DB0: greatest_run_suite (test.c:33)
==17713==    by 0x149DB0: greatest_run_suite (test.c:33)
==17713==    by 0x11FBDF: main (test.c:57)
==17713==  If you believe this happened as a result of a stack
==17713==  overflow in your program's main thread (unlikely but
==17713==  possible), you can try to increase the size of the
==17713==  main thread stack using the --main-stacksize= flag.
==17713==  The main thread stack size used in this run was 8388608.
==17713== 
==17713== HEAP SUMMARY:
==17713==     in use at exit: 57,483 bytes in 383 blocks
==17713==   total heap usage: 1,781 allocs, 1,398 frees, 157,929 bytes allocated
==17713== 
==17713== 540 (336 direct, 204 indirect) bytes in 1 blocks are definitely lost in loss record 305 of 315
==17713==    at 0x48C273F: calloc (vg_replace_malloc.c:1554)
==17713==    by 0x500ADE5: g_malloc0 (in /usr/lib/libglib-2.0.so.0.7800.1)
==17713==    by 0x1345DA: notification_create (notification.c:405)
==17713==    by 0x13470C: notification_load_icon_with_scaling (notification.c:134)
==17713==    by 0x1357B2: test_notification_icon_scaling_toosmall (notification.c:152)
==17713==    by 0x1357B2: suite_notification (notification.c:240)
==17713==    by 0x149DB0: greatest_run_suite (test.c:33)
==17713==    by 0x149DB0: greatest_run_suite (test.c:33)
==17713==    by 0x11FBDF: main (test.c:57)
==17713== 
==17713== LEAK SUMMARY:
==17713==    definitely lost: 336 bytes in 1 blocks
==17713==    indirectly lost: 204 bytes in 5 blocks
==17713==      possibly lost: 0 bytes in 0 blocks
==17713==    still reachable: 54,927 bytes in 356 blocks
==17713==         suppressed: 0 bytes in 0 blocks
==17713== Reachable blocks (those to which a pointer was found) are not shown.
==17713== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==17713== 
==17713== For lists of detected and suppressed errors, rerun with: -s
==17713== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
make: *** [Makefile:80: test-valgrind] Segmentation fault

Currently close to implementing the test program in Dunst!

fwsmit commented 8 months ago

I couldn't reproduce this error on the current master branch. What version and what operating system are you using?

apprehensions commented 8 months ago

I am using KISS Linux with musl 1.2.4, on master.

fwsmit commented 8 months ago

Hmm, you could take a look where this was introduced. We do test on alpine linux, which also uses musl

bynect commented 6 months ago

I also get a segfault ~but in a different part of the test suites~!

Edit: I redid a couple test and the problem is the same

Also I use normal glibc on gentoo linux so I think it's not really related to the libc. It seems like the icon is not loaded properly resulting in a null cairo surface...

bynect commented 6 months ago

I confirm that the problem is that loading icons from the data directory results in a null icon. I still don't know why, but adding a null check will at least prevent the whole test program from dying. Also I found another segfault in test_new_icon_overrides_raw_icon so I'll try to fix that also.

bynect commented 5 months ago

The problem could be caused by the absence of librsvg which is used as a runtime dependency to load icons

apprehensions commented 5 months ago

runtime

...

bynect commented 5 months ago

runtime

...

After #1269 the test don't crash if the icon is NULL and just fail. However I can't find a reason as to why the loading would fail if not for not being able to use an svg icon. So it probably is something related to gdk-pixbuf and librsvg, as we discussed in #1171

bynect commented 4 months ago

Does the test program still segfault for you even with librsvg?

apprehensions commented 4 months ago

This could be related to gdk-pixbuf since i am on Alpine, and the test program no longer segfaults.

Please try to fix this anyway, since gdk-pixbuf can be built without it.

bynect commented 4 months ago

Please try to fix this anyway, since gdk-pixbuf can be built without it.

That's the problem: it is a runtime dependency.

I can try to change the test to use the png instead of the svg.

bynect commented 3 months ago

Should have been solved by #1329