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

Initialize struct with zeroes #11621

Merged
merged 1 commit into from Oct 6, 2021
Merged

Conversation

MrZammler
Copy link
Contributor

Summary

Zero initialize write_ctx to remove a valgrind warning in spawn/spawn_client.c.

This should remove this warning:

==7869== Thread 2:
==7869== Syscall param writev(vector[...]) points to uninitialised byte(s)
==7869==    at 0x55D3C1D: writev (in /lib64/libc-2.33.so)
==7869==    by 0x4E29909: ??? (in /usr/lib64/libuv.so.1.0.0)
==7869==    by 0x4E29AD8: ??? (in /usr/lib64/libuv.so.1.0.0)
==7869==    by 0x4E2AC25: uv_write2 (in /usr/lib64/libuv.so.1.0.0)
==7869==    by 0x28E641: spawn_process_cmd (spawn_client.c:160)
==7869==    by 0x28E641: spawn_client (spawn_client.c:215)
==7869==    by 0x54C8E5D: start_thread (in /lib64/libpthread-2.33.so)
==7869==    by 0x55DCEFE: clone (in /lib64/libc-2.33.so)
==7869==  Address 0x5a67d54 is 196 bytes inside a block of size 240 alloc'd
==7869==    at 0x483F855: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==7869==    by 0x15A64B: mallocz (libnetdata.c:177)
==7869==    by 0x28E591: spawn_process_cmd (spawn_client.c:142)
==7869==    by 0x28E591: spawn_client (spawn_client.c:215)
==7869==    by 0x54C8E5D: start_thread (in /lib64/libpthread-2.33.so)
==7869==    by 0x55DCEFE: clone (in /lib64/libc-2.33.so)
==7869==  Uninitialised value was created by a heap allocation
==7869==    at 0x483F855: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==7869==    by 0x15A64B: mallocz (libnetdata.c:177)
==7869==    by 0x28E591: spawn_process_cmd (spawn_client.c:142)
==7869==    by 0x28E591: spawn_client (spawn_client.c:215)
==7869==    by 0x54C8E5D: start_thread (in /lib64/libpthread-2.33.so)
==7869==    by 0x55DCEFE: clone (in /lib64/libc-2.33.so)
==7869== 
Component Name

Spawn server

Test Plan

Since spawn server is mainly used for running the alarm-notify.sh script, it should be tested that after this PR, notifications still get executed, but there is no warning from valgrind for this case.

Additional Information

@MrZammler MrZammler changed the title initialize struct with zeroes Initialize struct with zeroes Oct 5, 2021
Copy link
Contributor

@thiagoftsm thiagoftsm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the following alert:

 alarm: dev_dim_template
    on: system.cpu
    os: linux
lookup: sum -3s at 0 every 3 percentage foreach *
 units: %
 every: 1s
  warn: $this > 1
  crit: $this > 4

and running netdata inside valgrind-3.17.0 I did not observe more the reported problem.

I also did not observe any warning with libasan. For both scenarios I waited for 100 alerts.

LGTM!

@MrZammler
Copy link
Contributor Author

Thanks a lot!!

@MrZammler MrZammler merged commit 0024bf9 into netdata:master Oct 6, 2021
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 this pull request may close these issues.

None yet

3 participants