Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Blinkled memory leak? (Alix platform)

    Scheduled Pinned Locked Moved pfSense Packages
    3 Posts 2 Posters 1.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • X Offline
      Xon
      last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • B Offline
        bryan.paradis
        last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • X Offline
          Xon
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.