Welcome! Log In Create A New Profile

Advanced

[nginx] Valgrind: supressed complaints about uninitialized bytes.

Maxim Dounin
June 05, 2013 12:12PM
details: http://hg.nginx.org/nginx/rev/711fa02afae8
branches:
changeset: 5245:711fa02afae8
user: Maxim Dounin <mdounin@mdounin.ru>
date: Wed Jun 05 19:44:22 2013 +0400
description:
Valgrind: supressed complaints about uninitialized bytes.

Valgrind complains if we pass uninitialized memory to a syscall:

==36492== Syscall param sendmsg(msg.msg_iov[0]) points to uninitialised byte(s)
==36492== at 0x6B5E6A: sendmsg (in /usr/lib/system/libsystem_kernel.dylib)
==36492== by 0x10004288E: ngx_signal_worker_processes (ngx_process_cycle.c:527)
==36492== by 0x1000417A7: ngx_master_process_cycle (ngx_process_cycle.c:203)
==36492== by 0x100001F10: main (nginx.c:410)
==36492== Address 0x7fff5fbff71c is on thread 1's stack

Even initialization of all members of the structure passed isn't enough, as
there is padding which still remains uninitialized and results in Valgrind
complaint. Note there is no real problem here as data from uninitialized
memory isn't used.

diffstat:

src/http/ngx_http_file_cache.c | 2 ++
src/os/unix/ngx_process_cycle.c | 8 ++++++++
2 files changed, 10 insertions(+), 0 deletions(-)

diffs (51 lines):

diff --git a/src/http/ngx_http_file_cache.c b/src/http/ngx_http_file_cache.c
--- a/src/http/ngx_http_file_cache.c
+++ b/src/http/ngx_http_file_cache.c
@@ -875,6 +875,8 @@ ngx_http_file_cache_set_header(ngx_http_

c = r->cache;

+ ngx_memzero(h, sizeof(ngx_http_file_cache_header_t));
+
h->valid_sec = c->valid_sec;
h->last_modified = c->last_modified;
h->date = c->date;
diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -355,6 +355,8 @@ ngx_start_worker_processes(ngx_cycle_t *

ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "start worker processes");

+ ngx_memzero(&ch, sizeof(ngx_channel_t));
+
ch.command = NGX_CMD_OPEN_CHANNEL;

for (i = 0; i < n; i++) {
@@ -401,6 +403,8 @@ ngx_start_cache_manager_processes(ngx_cy
&ngx_cache_manager_ctx, "cache manager process",
respawn ? NGX_PROCESS_JUST_RESPAWN : NGX_PROCESS_RESPAWN);

+ ngx_memzero(&ch, sizeof(ngx_channel_t));
+
ch.command = NGX_CMD_OPEN_CHANNEL;
ch.pid = ngx_processes[ngx_process_slot].pid;
ch.slot = ngx_process_slot;
@@ -460,6 +464,8 @@ ngx_signal_worker_processes(ngx_cycle_t
ngx_err_t err;
ngx_channel_t ch;

+ ngx_memzero(&ch, sizeof(ngx_channel_t));
+
#if (NGX_BROKEN_SCM_RIGHTS)

ch.command = 0;
@@ -561,6 +567,8 @@ ngx_reap_children(ngx_cycle_t *cycle)
ngx_channel_t ch;
ngx_core_conf_t *ccf;

+ ngx_memzero(&ch, sizeof(ngx_channel_t));
+
ch.command = NGX_CMD_CLOSE_CHANNEL;
ch.fd = -1;


_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Valgrind: supressed complaints about uninitialized bytes.

Maxim Dounin 779 June 05, 2013 12:12PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 177
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready