Blinkled memory leak? (Alix platform)



  • On my Alix2d3, I've noticed that blinkled appears to be leaking memory over time.

    I've got 2 PPPoE ADAL WANs and each linked to an LED. One of my ADSL PPPoE sessions has been dropping a bit (but not enough to report a fault), but this should just cause the blinkled package to restart more often.

    After 3 days uptime;

    
    [2.1-RELEASE][root@xxxxx]/root(2): ps axu | grep blink | grep -v grep
    root   42625  6.0  3.6 10468  8756  ??  SNs  10:03PM  75:00.95 /usr/local/bin/blinkled -i pppoe1 -l /dev/led/led2
    root   43044  5.0  3.6 10468  8756  ??  SNs  10:03PM  75:00.41 /usr/local/bin/blinkled -i pppoe0 -l /dev/led/led3
    
    

    Immediately after restarting the blinkled package via status_services.php

    
    [2.1-RELEASE][root@xxxxxx]/root(4): ps axu | grep blink | grep -v grep
    root   51248  7.0  0.4  3300  1048  ??  Ss    5:02PM   0:01.96 /usr/local/bin/blinkled -i pppoe1 -l /dev/led/led2
    root   51593  7.0  0.4  3300  1048  ??  Ss    5:02PM   0:01.96 /usr/local/bin/blinkled -i pppoe0 -l /dev/led/led3
    
    

    I've looked at the blinkled code, and it is dead simple. So why is the total memory for the process going up?

    The only thing I can think of is that the kvm_openfiles call is leaking handles somehow, or it isn't behaving nicely If the pppoe device does stuff under it.



  • I guess if you think it is actually leaking its going to be in something that is calling something and then not freeing it I guess. I had a look and I don't really see anything but its not like I have been doing much C in a long while.

    You should pkg_add -r valgrind and run it against the blinkled I guess. See what it says.



  • I think I've found a semi-reliable way to reproduce the leak. But as this is an alix2d3 with 256mb box running extra stuff pushes it's memory limits tight.

    If the interface goes away, the following code to never hit the cleanup path (can't find the source on the git repos, so from that post linked in the first post.):

    
       for(ifp = TAILQ_FIRST(&ifh); ifp; ifp = TAILQ_NEXT(&ifc, if_list))
       {
          n = kvm_read(kd, (u_long)ifp, &ifc, sizeof(ifc));
          if(n<0)
          {
             fprintf(stderr, "Error: kvm_read(element): %s\n", kvm_geterr(kd));
             kvm_close(kd);
             return -1;
          }
          if(strcmp(ifname, ifc.if_xname) == 0)
          {
             data->opackets = ifc.if_data.ifi_opackets;
             data->ipackets = ifc.if_data.ifi_ipackets;
             data->obytes = ifc.if_data.ifi_obytes;
             data->ibytes = ifc.if_data.ifi_ibytes;
             data->baudrate = ifc.if_data.ifi_baudrate;
             kvm_close(kd);
             return 0;
          }
       }
    }
    
    

    Note; there is no kvm_close(kd) if the interface isn't matched.

    I guess the package isn't being restarted in some conditions when the interface derps.


Log in to reply