Skip to content
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

Stack overflow when IOT_DEBUG is enabled #63

Closed
lkaino opened this issue Dec 21, 2016 · 2 comments
Closed

Stack overflow when IOT_DEBUG is enabled #63

lkaino opened this issue Dec 21, 2016 · 2 comments
Labels

Comments

@lkaino
Copy link
Contributor

lkaino commented Dec 21, 2016

When IOT_DEBUG is enabled, iot_tls_connect declares a stack variable of 16 kB:

#ifdef IOT_DEBUG
	unsigned char buf[MBEDTLS_SSL_MAX_CONTENT_LEN + 1];
#endif

This will easily cause stack overflow on many embedded devices.

I suggest to declare the buf global instead.

@lkaino
Copy link
Contributor Author

lkaino commented Dec 21, 2016

In addition, I think above should be wrapped inside

#ifdef ENABLE_IOT_DEBUG
instead of
#ifdef IOT_DEBUG
as IOT_DEBUG is always defined.

@chaurah
Copy link
Contributor

chaurah commented Dec 21, 2016

Hi @lkaino,
Thank you for the suggestion. We are looking into optimizing the SDK so it can be used on smaller devices. I have made a note of this suggestion in our internal tracker. We will definitely look into optimizing the debug memory allocations as well for the next release.

Please do let us know if you have further suggestions.

Rahul

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants