[PATCH]Valgind: a complaint about uninitialized bytes

cubicdaiya cubicdaiya at gmail.com
Tue Jun 11 15:51:56 UTC 2013


Hi.

2013/6/12 Maxim Dounin <mdounin at mdounin.ru>
> The memzero call is certainly only needed in case of fd != -1
> (i.e., to suppress valgrind warning).

I see. How is that?

# HG changeset patch
# User Tatsuhiko Kubo <cubicdaiya at gmail.com>
# Date 1370965284 -32400
# Node ID 2bb2b7d3a263d97b148b706407caf16fd0f074eb
# Parent  725fb71ab1a60bd48b0afb8b001b5349f5054cb1
Valgrind: a complaint about uninitialized bytes

Valgrind outputs the following message
when NGX_HAVE_MSGHDR_MSG_CONTROL is 1.

==12605== Syscall param socketcall.sendmsg(msg.msg_control) points to
uninitialised byte(s)
==12605==    at 0x4E37660: __sendmsg_nocancel (syscall-template.S:82)
==12605==    by 0x41C9BF: ngx_write_channel (ngx_channel.c:77)
==12605==    by 0x41E2DC: ngx_pass_open_channel (ngx_process_cycle.c:454)
==12605==    by 0x41E3B6: ngx_start_worker_processes
(ngx_process_cycle.c:371)
==12605==    by 0x41F368: ngx_master_process_cycle (ngx_process_cycle.c:136)
==12605==    by 0x404A19: main (nginx.c:412)
==12605==  Address 0x7ff000614 is on thread 1's stack

diff -r 725fb71ab1a6 -r 2bb2b7d3a263 src/os/unix/ngx_channel.c
--- a/src/os/unix/ngx_channel.c Fri Jun 07 13:16:00 2013 -0700
+++ b/src/os/unix/ngx_channel.c Wed Jun 12 00:41:24 2013 +0900
@@ -31,6 +31,7 @@
         msg.msg_controllen = 0;

     } else {
+        ngx_memzero(&cmsg, sizeof(cmsg));
         msg.msg_control = (caddr_t) &cmsg;
         msg.msg_controllen = sizeof(cmsg);



-- 
Tatsuhiko Kubo

E-Mail : cubicdaiya at gmail.com
HP      : http://cccis.jp/index_en.html
Twitter : http://twitter.com/cubicdaiya
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20130612/f439b736/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: valgrind_complaint_fix.patch
Type: application/octet-stream
Size: 1265 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20130612/f439b736/attachment.obj>


More information about the nginx-devel mailing list