Bug 342221 - socket connect produce false positive saying access to uninitialized memory area
Summary: socket connect produce false positive saying access to uninitialized memory ...
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: 3.10.0
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-26 14:31 UTC by hdun
Modified: 2014-12-29 22:40 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description hdun 2014-12-26 14:31:30 UTC
We add a new type of socket in Linux with a new address type sa->sa_family not listed in function pre_mem_read_sockaddr.
When the socket connecting, memcheck tool produce false positive saying access uninitialized memory area.

I check the code and find the salen in pre_mem_read_sockaddr  function should be "salen - sizeof(sa->sa_family)"
The salen is the total addr struct size, while the addr->sa_data length should be salen - sizeof(sa->sa_family)
static

void pre_mem_read_sockaddr ( ThreadId tid,
                             const HChar *description,
                             struct vki_sockaddr *sa, UInt salen )
{
   ...
      default:
         VG_(sprintf) ( outmsg, description, "sa_data" );
         PRE_MEM_READ( outmsg, (Addr)&sa->sa_family + sizeof(sa->sa_family), salen );  /* salen should be salen-sizeof(sa->sa_family)*/
         break;
   }
   ...
}

Reproducible: Always

Steps to Reproduce:
1.connect with a new type of socket addr
2.
3.

Actual Results:  
false positive saying access to uninitialized memory area
Comment 1 Philippe Waroquiers 2014-12-29 22:40:36 UTC
Fix Committed revision 14835.
Thanks for the analysis and fix suggestion