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

Fix MDNS crash on S2 #6193

Merged
merged 1 commit into from
Mar 26, 2022
Merged

Fix MDNS crash on S2 #6193

merged 1 commit into from
Mar 26, 2022

Conversation

tannewt
Copy link
Member

@tannewt tannewt commented Mar 24, 2022

Fixes #6186

@tannewt tannewt requested a review from jepler March 24, 2022 00:20
@@ -117,6 +117,11 @@ mp_obj_t common_hal_mdns_server_find(mdns_server_obj_t *self, const char *servic
next = next->next;
}
mp_obj_tuple_t *tuple = MP_OBJ_TO_PTR(mp_obj_new_tuple(num_results, NULL));
// The empty tuple object is shared and stored in flash so return early if
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mp_obj_new_tuple already sets the length to n, so instead of special casing num_results == 0, you can remove the assignment of len below.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I set it to added below in case we can make the wrapper objects for all of the results. So, it may be different than the value at alloc time. Want me to make it compare the current len vs added and then set it if different?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

urp .. tuples are meant to be static in size, I'm not sure of the impact of truncating one after initial allocation. but the tuple at this point is not seen by python code, so it doesn't matter.

Copy link
Member

@jepler jepler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@@ -117,6 +117,11 @@ mp_obj_t common_hal_mdns_server_find(mdns_server_obj_t *self, const char *servic
next = next->next;
}
mp_obj_tuple_t *tuple = MP_OBJ_TO_PTR(mp_obj_new_tuple(num_results, NULL));
// The empty tuple object is shared and stored in flash so return early if
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

urp .. tuples are meant to be static in size, I'm not sure of the impact of truncating one after initial allocation. but the tuple at this point is not seen by python code, so it doesn't matter.

@jepler jepler merged commit 35aa32b into adafruit:main Mar 26, 2022
@jepler
Copy link
Member

jepler commented Mar 27, 2022

If memory is at a premium, it would be better to change this into an iterator object, even if it's a bit more work. doing this before the next 7.x.0 would be good so that it wasn't an incompatible API change.

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

Successfully merging this pull request may close these issues.

mDNS safe mode - find
2 participants