This is an automated email from the ASF dual-hosted git repository.

bneradt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 60904b8f6c Fix Valgrind uninitialized memory warnings (#12806)
60904b8f6c is described below

commit 60904b8f6c2b10a0eabbc72f07c462bdffa7f896
Author: Brian Neradt <[email protected]>
AuthorDate: Wed Jan 21 14:36:56 2026 -0600

    Fix Valgrind uninitialized memory warnings (#12806)
    
    Valgrind reported some uses of uninitialized memory when running the
    regression tests under it. This patch addresses the following valgrind
    reported issues:
    
    1. LogBuffer flush:
       Syscall param write(buf) points to uninitialised byte(s)
          at Log::flush_thread_main(void*)
          by LogBuffer::LogBuffer(LogConfig const*, LogObject*, ...)
    
    2. Cache test pwrite:
       Syscall param pwrite64(buf) points to uninitialised byte(s)
          at AIOThreadInfo::aio_thread_main(AIOThreadInfo*)
          by Stripe::Stripe(CacheDisk*, long, long, int, int)
---
 src/iocore/cache/CacheTest.cc  | 3 +++
 src/proxy/logging/LogBuffer.cc | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/src/iocore/cache/CacheTest.cc b/src/iocore/cache/CacheTest.cc
index 71b38738e3..cd86df6051 100644
--- a/src/iocore/cache/CacheTest.cc
+++ b/src/iocore/cache/CacheTest.cc
@@ -566,6 +566,7 @@ test_RamCache(RegressionTest *t, RamCache *cache, const 
char *name, int64_t cach
       CryptoHash    hash;
 
       d->alloc(BUFFER_SIZE_INDEX_16K);
+      memset(d->data(), 0, BUFFER_SIZE_FOR_INDEX(BUFFER_SIZE_INDEX_16K));
       data.push_back(make_ptr(d));
       hash.u64[0] = (static_cast<uint64_t>(i) << 32) + i;
       hash.u64[1] = (static_cast<uint64_t>(i) << 32) + i;
@@ -610,6 +611,7 @@ test_RamCache(RegressionTest *t, RamCache *cache, const 
char *name, int64_t cach
     if (!cache->get(&hash, &get_data)) {
       IOBufferData *d = THREAD_ALLOC(ioDataAllocator, this_thread());
       d->alloc(BUFFER_SIZE_INDEX_16K);
+      memset(d->data(), 0, d->block_size());
       data.push_back(make_ptr(d));
       cache->put(&hash, data.back().get(), 1 << 15);
       if (i >= sample_size / 2) {
@@ -630,6 +632,7 @@ test_RamCache(RegressionTest *t, RamCache *cache, const 
char *name, int64_t cach
     if (!cache->get(&hash, &get_data)) {
       IOBufferData *d = THREAD_ALLOC(ioDataAllocator, this_thread());
       d->alloc(BUFFER_SIZE_INDEX_8K + (r[i] % 3));
+      memset(d->data(), 0, d->block_size());
       data.push_back(make_ptr(d));
       cache->put(&hash, data.back().get(), d->block_size());
       if (i >= sample_size / 2) {
diff --git a/src/proxy/logging/LogBuffer.cc b/src/proxy/logging/LogBuffer.cc
index c183bede9e..eb69c37c1d 100644
--- a/src/proxy/logging/LogBuffer.cc
+++ b/src/proxy/logging/LogBuffer.cc
@@ -126,6 +126,8 @@ LogBuffer::LogBuffer(const LogConfig *cfg, LogObject 
*owner, size_t size, size_t
   }
   m_buffer = static_cast<char *>(align_pointer_forward(m_unaligned_buffer, 
buf_align));
 
+  memset(m_buffer, 0, size);
+
   // add the header
   hdr_size = _add_buffer_header(cfg);
 

Reply via email to