Page 2 of 2

Re: LwIP pbuf/memp corruption

Posted: Tue May 07, 2019 10:50 pm
by aleo
Giovanni,

I noticed that in the bug tracking for this issue it was marked as resolved with a comment from you "Fixed by lwIP 2.0 merge" (https://sourceforge.net/p/chibios/bugs/729/), but your last comment on this thread was half a year later and seems to imply the issue may not have been resolved.

I wanted to see if this was successfully patched in one of the stable releases, as it may be causing a problem I'm having.

Re: LwIP pbuf/memp corruption

Posted: Wed May 08, 2019 7:37 am
by Giovanni
Hi,

On the tracker there is another issue not yet resolved: https://sourceforge.net/p/chibios/bugs/1009/

Could this be causing your problem? anyway, if you have a better understanding of the problem could you suggest a fix?

Giovanni

Re: LwIP pbuf/memp corruption

Posted: Wed May 08, 2019 8:52 pm
by steved
Having re-read this thread, I would say that the originally reported problem has been fixed. The relevant bit of code is:

Code: Select all

    if (mask & FRAME_RECEIVED_ID) {
      struct pbuf *p;
      while (low_level_input(&thisif, &p)) {
        if (p != NULL) {
          struct eth_hdr *ethhdr = p->payload;
          switch (htons(ethhdr->type)) {
            /* IP or ARP packet? */
            case ETHTYPE_IP:
            case ETHTYPE_ARP:
              /* full packet send to tcpip_thread to process */
              if (thisif.input(p, &thisif) == ERR_OK)
                break;
              LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
          /* Falls through */
            default:
              pbuf_free(p);
          }
        }
      }
    }

So buffer is allocated in low_level_input().
It's then either passed to thisif.input() (which presumably frees it after processing) or its released in the above loop.

I think I've now used lwip sufficiently that any problem would have shown by now.