[Live-devel] Valgrind uninitialised values inside live555

Ulrich Teichert ulrich.teichert at luminator.com
Tue Aug 17 23:25:42 PDT 2021


Hi,

while you may consider valgrind very picky (as it should be, that was one of the goals during its
development, I believe ;-), I've run into that issue as well. It results from this call, i.e.:

groupsock/GroupsockHelper.cpp:
...
static Boolean getSourcePort0(int socket, portNumBits& resultPortNum/*host order*/) {
  sockaddr_storage testAddr;
  setPortNum(testAddr, 0);

  SOCKLEN_T len = sizeof testAddr;
  if (getsockname(socket, (struct sockaddr*)&testAddr, &len) < 0) return False;
...

In setPortNum, testAddr.ss_family is read to find out if an IP4 or IP6 address is being
dealt with:

groupsock/NetAddress.cpp
void setPortNum(struct sockaddr_storage& address, portNumBits portNum/*in network order*/) {
  switch (address.ss_family) {
    case AF_INET: {

So, after all, I think valgrind is right and a simple change fixes that warning:

...
static Boolean getSourcePort0(int socket, portNumBits& resultPortNum/*host order*/) {
  sockaddr_storage testAddr;
  testAddr.ss_family = AF_INET;
  setPortNum(testAddr, 0);
...

Just my 2 Cent,
CU,
Uli

Ulrich Teichert
Sr. Software Engineer, Technology Development Center VSS
Luminator Technology Group 
P: +49 (4321) 539895-13
ulrich.teichert at luminator.com
https://www.luminator.com

LTG Rastatt GmbH | Office Neumünster Oderstrasse 47 | DE - 24539 Neumünster 
Geschäftsführer: Franz Foth, Hans-Joachim Reich | Sitz der Gesellschaft: D-76437 Rastatt, Amtsgericht: Mannheim, HRB 521501 
USt.-IdNr: DE144752608, Steuer-Nr: 39487/30502
________________________________________
From: live-devel <live-devel-bounces at us.live555.com> on behalf of Ba Jinsheng <bajinsheng at u.nus.edu>
Sent: Wednesday, August 18, 2021 02:29
To: LIVE555 Streaming Media - development & use
Subject: Re: [Live-devel] Valgrind uninitialised values inside live555

Hi,

I think a possible reason is the compilation optimization.

Try to use "-O0" instead of "-O2" to compile the Live555. It may reduce the uninitialized errors.

Best regards,
Jinsheng Ba

-----Original Message-----
From: live-devel <live-devel-bounces at us.live555.com> On Behalf Of Ross Finlayson
Sent: Wednesday, August 18, 2021 2:20 AM
To: LIVE555 Streaming Media - development & use <live-devel at us.live555.com>
Subject: Re: [Live-devel] Valgrind uninitialised values inside live555

        - External Email -



Not everything that ‘valgrind’ reports is actually an error.  In each case, you need to look at the code to see if there’s really an error there.


> For example I found this code inside GroupsockHelper.cpp:
>
>
> static Boolean getSourcePort0(int socket, portNumBits& resultPortNum/*host order*/) {
>   sockaddr_storage testAddr;
>   setPortNum(testAddr, 0);
>
>   SOCKLEN_T len = sizeof testAddr;
>   if (getsockname(socket, (struct sockaddr*)&testAddr, &len) < 0) return False;
>
>   resultPortNum = ntohs(portNum(testAddr));
>   return True;
> }

I’m not really sure if there’s anything really wrong here.  “getsockname()” fills in (i.e., returns) the value of “testAddr”; it doesn’t read it.  And the subsequent call to “portNum(testAddr)” shouldn't read an uninitialized value, because the port number should have been filled in by the earlier (successful) call to "getsockname()”.

What is, perhaps, strange, is the call to “setPortNum()”, which probably isn’t really needed.  And the implementation of “setPortNum()” does, indeed, rely upon the “ss_family” field, which, in this case, will be uninitialized.  So perhaps that’s what upset ‘valgrind’ here??  So I’ve gone ahead and installed a new version (2021.08.17) of the LIVE555 code that changes the implementation of "setPortNum()” to not rely upon “ss_family”.  This might make ‘valgrind’ happier in this case.


Ross Finlayson
Live Networks, Inc.
http://www.live555.com/


_______________________________________________
live-devel mailing list
live-devel at lists.live555.com
http://lists.live555.com/mailman/listinfo/live-devel

_______________________________________________
live-devel mailing list
live-devel at lists.live555.com
http://lists.live555.com/mailman/listinfo/live-devel



More information about the live-devel mailing list