You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2012/08/10 00:51:05 UTC

[Bug 53690] New: Calls to semctl() trigger "uninitialized memory" warning from valgrind

https://issues.apache.org/bugzilla/show_bug.cgi?id=53690

          Priority: P3
            Bug ID: 53690
          Keywords: PatchAvailable
          Assignee: bugs@httpd.apache.org
           Summary: Calls to semctl() trigger "uninitialized memory"
                    warning from valgrind
          Severity: normal
    Classification: Unclassified
                OS: Linux
          Reporter: mi+apache@aldan.algebra.com
          Hardware: All
            Status: NEW
           Version: 2.4.2
         Component: Core
           Product: Apache httpd-2

The warnings looks like this:
==977== Syscall param semctl(IPC_SET, arg.buf) points to uninitialised byte(s)
==977==    at 0x62FA8EA: semctl (in /lib64/libc-2.5.so)
==977==    by 0x18705C: ap_unixd_set_proc_mutex_perms (unixd.c:251)
==977==    by 0x1870E0: ap_unixd_set_global_mutex_perms (unixd.c:284)
==977==    by 0x16FC19: ap_global_mutex_create (util_mutex.c:444)
==977==    by 0xAE3D17A: rewritelock_create (mod_rewrite.c:2594)
==977==    by 0xAE41730: post_config (mod_rewrite.c:4316)
==977==    by 0x15F4B3: ap_run_post_config (config.c:105)
==977==    by 0x1365C5: main (main.c:696)
==977==  Address 0x7ff000430 is on thread 1's stack
==977==  Uninitialised value was created by a stack allocation
==977==    at 0x186FB1: ap_unixd_set_proc_mutex_perms (unixd.c:227)

Because the semid_ds structure on Linux (as well as FreeBSD and, likely, other
Unixes) contains some undocumented fields (such as __unused1 or sem_pad2),
explicitly setting each one is not portable -- far simpler to just request,
that the entire structure be zeroed at the declaration time:

--- os/unix/unixd.c        2011-12-18 13:02:21.000000000 -0500
+++ os/unix/unixd.c     2012-08-09 18:40:55.000000000 -0400
@@ -242,5 +242,5 @@
 #endif
             union semun ick;
-            struct semid_ds buf;
+            struct semid_ds buf = { 0 };

             apr_os_proc_mutex_get(&ospmutex, pmutex);

While the warning is benign, it is better to suppress it, then to needlessly
worry people attempting to use valgrind to debug some other problem -- the
fewer such false alarms, the better.

Earlier releases of httpd have the same issue (I've seen it in 2.2.22 myself).

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 53690] Calls to semctl() trigger "uninitialized memory" warning from valgrind

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53690

--- Comment #2 from Mikhail T. <mi...@aldan.algebra.com> ---
(In reply to comment #1)
> unixd.c: In function ‘ap_unixd_set_proc_mutex_perms’:
> unixd.c:244:20: warning: missing braces around initializer [-Wmissing-braces]

Yeah, the first field of the semid_ds-structure is also a structure (at least
on Linux and FreeBSD), so using two layers of braces should work:

     struct semid_ds buf = {{ 0 }};

If that's not portable enough, then bzero() might be in order:

     bzero(&buf, sizeof(buf));

however annoying it might be to have a function-call (even if compiler will
optimize it away) just to zero-out an automatic variable :-(

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 53690] Calls to semctl() trigger "uninitialized memory" warning from valgrind

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53690

Stefan Fritsch <sf...@sfritsch.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |FixedInTrunk

--- Comment #3 from Stefan Fritsch <sf...@sfritsch.de> ---
committed to trunk as r1442326

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 53690] Calls to semctl() trigger "uninitialized memory" warning from valgrind

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53690

--- Comment #1 from Jeff Trawick <tr...@apache.org> ---
with that I get 


unixd.c: In function ‘ap_unixd_set_proc_mutex_perms’:
unixd.c:244:20: warning: missing braces around initializer [-Wmissing-braces]
unixd.c:244:20: warning: (near initialization for ‘buf.sem_perm’)
[-Wmissing-braces]

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org