Skip to content

config-parser: use zalloc()

Pekka Paalanen requested to merge pq/weston:mr/msan-config into master

While the code looks fine, clang 7 memory sanitizer complains about things like:

==26052==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x7f4f4d003327 in weston_config_get_section /home/pq/build/weston-clang/../../git/weston/shared/config-parser.c:141:2
    #1 0x7f4f4cfce11a in wet_main /home/pq/build/weston-clang/../../git/weston/compositor/main.c:3266:12

==26683==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x7f09ebd638e2 in config_section_get_entry /home/pq/build/weston-clang/../../git/weston/shared/config-parser.c:125:2
    #1 0x7f09ebd661c4 in weston_config_section_get_bool /home/pq/build/weston-clang/../../git/weston/shared/config-parser.c:310:10
    #2 0x7f09ebd2e1e5 in wet_main /home/pq/build/weston-clang/../../git/weston/compositor/main.c:3269:3

In all cases, the errors point to wl_list_for_each().

Making these allocations use zalloc() avoids these errors. Since using zalloc() is a good habit in any case, I didn't dig deeper.


It looks like running Weston with Clang's Memory Sanitizer could be quite a chore. After this fix, the next error is:

Uninitialized bytes in __interceptor_getsockname at offset 0 inside [0x7ffde1ecbb14, 4)
==28387==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x7f02705bbe5d  (/lib/x86_64-linux-gnu/libxcb.so.1+0x10e5d)
    #1 0x7f02705bbfaf  (/lib/x86_64-linux-gnu/libxcb.so.1+0x10faf)
    #2 0x7f02705bb972 in xcb_connect_to_display_with_auth_info (/lib/x86_64-linux-gnu/libxcb.so.1+0x10972)
    #3 0x7f026ffa1ca1 in _XConnectXCB (/lib/x86_64-linux-gnu/libX11.so.6+0x42ca1)
    #4 0x7f026ff92814 in XOpenDisplay (/lib/x86_64-linux-gnu/libX11.so.6+0x33814)
    #5 0x7f02705f9639 in x11_backend_create /home/pq/build/weston-clang/../../git/weston/libweston/backend-x11/x11.c:1847:11
    #6 0x7f02705f9092 in weston_backend_init /home/pq/build/weston-clang/../../git/weston/libweston/backend-x11/x11.c:1952:6
    #7 0x7f027287c726 in weston_compositor_load_backend /home/pq/build/weston-clang/../../git/weston/libweston/compositor.c:7928:6
    #8 0x7f0272d33321 in load_x11_backend /home/pq/build/weston-clang/../../git/weston/compositor/main.c:2841:8
    #9 0x7f0272d2c400 in load_backend /home/pq/build/weston-clang/../../git/weston/compositor/main.c:3038:10
    #10 0x7f0272d24a23 in wet_main /home/pq/build/weston-clang/../../git/weston/compositor/main.c:3313:6

I don't have the time to pursue that. I tried memory sanitizer only because I was debugging something else.

Merge request reports