Skip to content

[N8266-18] espconn_gethostbyname returns ERR_MEM although there is more than enough free memory #198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kriegste opened this issue Dec 1, 2018 · 10 comments

Comments

@kriegste
Copy link

kriegste commented Dec 1, 2018

How do I debug espconn_gethostbyname? I call it to retrieve the IP of "api.openweathermap.org". Sometimes (for a few hours in a row) it returns ERR_MEM although there should be more than enough memory available. I print the amount of free heap in the log and it is always around 49264 bytes more or less.

Has anyone experienced a similar behavior?

I suspect there is a fixed buffer inside the espconn_gethostbyname function which is too small for some requests. Maybe Espressif can enlighten us.

Edit:
dns is part of lwip, so I enabled debugging there and will report back new findings.

@kriegste
Copy link
Author

kriegste commented Dec 2, 2018

The bug is here:
https://github.com/espressif/ESP8266_NONOS_SDK/blob/master/third_party/lwip/core/dns.c#L886

lseqi must not be initialized with 0, but with DNS_TABLE_SIZE. Compare the original code from the newest lwIP:
https://github.com/lwip-tcpip/lwip/blob/master/src/core/dns.c#L1440

The problem seems to be gone, but I need to monitor this for a few more days.

@kriegste
Copy link
Author

kriegste commented Dec 6, 2018

Works.

@kriegste kriegste closed this as completed Dec 6, 2018
@someburner
Copy link

@kriegste - shouldn't you leave this open until it makes it into the SDK?

@kriegste
Copy link
Author

kriegste commented Dec 8, 2018

No problem. Don't let me stop you (or Espressif).

Looking at the new lwIP there are more bugs that need to be fixed.

@kriegste kriegste reopened this Dec 8, 2018
@gilpinheiro
Copy link

It appears the SDK is compiled with DNS_TABLE_SIZE 0, which makes the issue moot. I base this on the latest SDK liblwip.a not containing a dns_table at all.

It'd be nice if the lwipopt.h actually reflected what options the SDK is using.

@kriegste
Copy link
Author

kriegste commented Mar 4, 2019

The problem did not reoccur. All fine after the fix.

DNS_TABLE_SIZE is mentioned only a few times, but it is defined as 4 in the source.
https://github.com/espressif/ESP8266_NONOS_SDK/blob/master/third_party/include/lwip/opt.h#L799
https://github.com/espressif/ESP8266_NONOS_SDK/blob/master/third_party/include/lwipopts.h#L808

@FayeY
Copy link
Collaborator

FayeY commented Mar 13, 2019

Is this issue solved? Could we close this issue now?

@kriegste
Copy link
Author

@xcguang xcguang changed the title espconn_gethostbyname returns ERR_MEM although there is more than enough free memory [N8266-18] espconn_gethostbyname returns ERR_MEM although there is more than enough free memory Mar 14, 2019
wujiangang pushed a commit that referenced this issue Mar 14, 2019
- Sync bug fix of dns_enqueue from RTOS SDK
- #198
- N8266-18
wujiangang pushed a commit that referenced this issue Mar 14, 2019
wujiangang pushed a commit that referenced this issue Mar 14, 2019
@xcguang
Copy link
Collaborator

xcguang commented Mar 14, 2019

15993bf & 89693b4 & 74358b7 fix it, please try it again.

@kriegste
Copy link
Author

Thanks.

davydnorris pushed a commit to davydnorris/ESP8266_NONOS_SDK that referenced this issue Mar 14, 2019
- Sync bug fix of dns_enqueue from RTOS SDK
- espressif#198
- N8266-18
davydnorris pushed a commit to davydnorris/ESP8266_NONOS_SDK that referenced this issue May 3, 2019
- Sync bug fix of dns_enqueue from RTOS SDK
- espressif#198
- N8266-18
davydnorris pushed a commit to davydnorris/ESP8266_NONOS_SDK that referenced this issue May 3, 2019
- Sync bug fix of dns_enqueue from RTOS SDK
- espressif#198
- N8266-18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants