Skip to content

Conversation

@royfengsss
Copy link
Contributor

Summary

Fix an assertion issue #9599.

lib_malloc is defined as macro and it will be expanded to kmm_alloc if __KERNEL__ is defined or malloc if __KERNEL__ is not defined.
lib_free is defined as macro and it will be expanded to kmm_free if __KERNEL__ is defined or free if __KERNEL__ is not defined.

For fs, it is a kernel module and build with __KERNEL__ defined. so the lib_free in this module is kmm_free in fact.
For libc is is only a library (not belong to kernel), it build without __KERNEL__ defined. so lib_malloc used in this modue is malloc in fact.

Think about a case like this:
in fs module, asprintf was used to alloc and initialize the memory, and this memory is freed via lib_free. This is the case #9599 addressed.

The fix use the flag of flat build mode. if under flat mode, the __KERNEL__ will not be consider. as it is not real kernel or user distinguished under this buils mode

Impact

Should no

Testing

The issue #9599 has been fixed.

Copy link
Contributor

@patacongo patacongo left a comment

Choose a reason for hiding this comment

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

LGTM

This does interact with CONFIG_MM_KERNEL_HEAP https://github.com/apache/nuttx/blob/master/include/nuttx/kmalloc.h#L84 but that should be fine because that should never be select in the FLAT build.

@xiaoxiang781216 xiaoxiang781216 linked an issue Jun 24, 2023 that may be closed by this pull request
@xiaoxiang781216 xiaoxiang781216 merged commit 10251f6 into apache:master Jun 24, 2023
@royfengsss royfengsss deleted the crash-issue-fix branch June 28, 2023 08:13
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.

ESP32 DevkitC: device crash found when run ls

4 participants