Go to file
anjiahao 80ea8c3cc7 mempool:fix bug when free a alignment address
The mempool mistakenly considers the heap memory as its own

The recurring scenario only occurs in mempool_deinit
test code in hello_main:

int main(int argc, FAR char *argv[])
{
  void *a = malloc(1024*64);
  void *d[16];
  void *heap = mm_initialize("123", a, 1024 * 64);
  for (int i = 0; i < 16; i++)
    {
        d[i] = mm_malloc(heap,32);
    }

  for (int i = 0; i < 16; i++)
    {
      if (d[i] != NULL)
        mm_free(heap,d[i]);
    }

  mm_uninitialize(heap);
  free(a);
  return 0;
}

and crash backtrace

0  _assert (filename=0x4ea20 "mempool/mempool.c", linenum=373, msg=0x0 <up_perf_convert>, regs=0x0 <up_perf_convert>)
   at misc/assert.c:551
1  0x0000a32c in __assert (filename=0x4ea20 "mempool/mempool.c", linenum=373, msg=0x0 <mempool_multiple_foreach>)
   at assert/lib_assert.c:36
2  0x0000f92c in mempool_release (pool=0x100e7a0, blk=0x100ff80) at mempool/mempool.c:373
3  0x000109ce in mempool_multiple_free (mpool=0x100e6f8, blk=0x100ff80) at mempool/mempool_multiple.c:648
4  0x0000deac in mm_delayfree (heap=0x100e090, mem=0x1010000, delay=false) at mm_heap/mm_free.c:83
5  0x0000e21c in mm_free (heap=0x100e090, mem=0x1010000) at mm_heap/mm_free.c:242
6  0x0001021c in mempool_multiple_free_chunk (mpool=0x100e6f8, ptr=0x1010000) at mempool/mempool_multiple.c:222
7  0x0001048e in mempool_multiple_free_callback (pool=0x100e7a0, addr=0x1010080) at mempool/mempool_multiple.c:291
8  0x0000ff6e in mempool_deinit (pool=0x100e7a0) at mempool/mempool.c:644
9  0x00010cba in mempool_multiple_deinit (mpool=0x100e6f8) at mempool/mempool_multiple.c:883
10 0x0000dd0c in mm_uninitialize (heap=0x100e090) at mm_heap/mm_initialize.c:326
11 0x0002c742 in hello_main (argc=1, argv=0x100d050) at hello_main.c:54
12 0x0000a83e in nxtask_startup (entrypt=0x2c6a5 <hello_main>, argc=1, argv=0x100d050) at sched/task_startup.c:70
13 0x00005272 in nxtask_start () at task/task_start.c:112

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-08-21 18:01:24 +08:00
.github ISSUE_TEMPLATE: Fixed incorrect links for issue forms 2024-08-05 15:35:48 -03:00
arch nuttx/audio: add offload buffer size config 2024-08-21 17:59:28 +08:00
audio Documentation: remove all migrated READMEs 2023-10-29 21:03:54 -03:00
binfmt nuttx/boards:Uniform initialization format for init_array. 2024-08-19 19:48:32 +08:00
boards defconfig: add SYSTEM_TELNETD related config 2024-08-21 10:51:20 +08:00
cmake cmake:bugfix fix CMake post_build phase time orderless 2024-08-21 01:53:09 +08:00
crypto fix(Kconfig): spellcheck "randon" to "random" 2024-06-15 17:40:18 +08:00
Documentation Documentation:update gdbserver Documentation 2024-08-21 18:01:06 +08:00
drivers pm_runtime: fix header missing, up_interrupt_context may undeclared 2024-08-21 13:38:50 +08:00
dummy build: add initial cmake build system 2023-07-08 13:50:48 +08:00
fs inode:call inode_release when close success 2024-08-21 13:31:25 +08:00
graphics video/vnc: add vnc_fb_register 2024-04-12 17:42:49 +08:00
include mempool: safe memdump for smp, if syslog will switch context 2024-08-21 18:01:24 +08:00
libs libc:Add macro restrictions to code that uses floating point numbers 2024-08-21 13:33:45 +08:00
mm mempool:fix bug when free a alignment address 2024-08-21 18:01:24 +08:00
net net/tcp: reset the dupack counter. 2024-08-21 02:12:55 +08:00
openamp libmetal/atomic: enable 64-bit atomic by toolchain builtin flags 2024-06-29 22:38:48 +08:00
pass1
sched docs: fix typo in nx_smpstart.c 2024-08-21 17:07:19 +08:00
syscall build: fix syscall instrumentation in flat build 2024-08-21 10:50:30 +08:00
tools gdbserver:minidumpserver is powerful, so change name to gdbserver 2024-08-21 18:01:06 +08:00
video build: add initial cmake build system 2023-07-08 13:50:48 +08:00
wireless Remove the back slash from long literal string 2024-02-19 16:43:15 +01:00
.asf.yaml
.gitignore build: untracked these two types of files 2024-08-18 19:38:44 +08:00
.pre-commit-config.yaml Created pre-commit config file 2024-08-19 21:40:56 +02:00
.yamllint
AUTHORS
CMakeLists.txt cmake:bugfix fix CMake post_build phase time orderless 2024-08-21 01:53:09 +08:00
CONTRIBUTING.md
INVIOLABLES.md
Kconfig make/disassembly: generate disassembly file 2024-08-16 15:22:25 +08:00
LICENSE libc/x86_64: port string functions from bionic 2024-07-02 23:59:18 +08:00
Makefile
NOTICE
README.md Gathering community recommendations 2023-10-28 13:55:56 +08:00
ReleaseNotes Documentation: move ReleaseNotes 2023-09-26 20:41:00 +08:00

POSIX Badge License Issues Tracking Badge Contributors GitHub Build Badge Documentation Badge

Apache NuttX is a real-time operating system (RTOS) with an emphasis on standards compliance and small footprint. Scalable from 8-bit to 64-bit microcontroller environments, the primary governing standards in NuttX are POSIX and ANSI standards. Additional standard APIs from Unix and other common RTOSs (such as VxWorks) are adopted for functionality not available under these standards, or for functionality that is not appropriate for deeply-embedded environments (such as fork()).

For brevity, many parts of the documentation will refer to Apache NuttX as simply NuttX.

Getting Started

First time on NuttX? Read the Getting Started guide! If you don't have a board available, NuttX has its own simulator that you can run on terminal.

Documentation

You can find the current NuttX documentation on the Documentation Page.

Alternatively, you can build the documentation yourself by following the Documentation Build Instructions.

The old NuttX documentation is still available in the Apache wiki.

Supported Boards

NuttX supports a wide variety of platforms. See the full list on the Supported Platforms page.

Contributing

If you wish to contribute to the NuttX project, read the Contributing guidelines for information on Git usage, coding standard, workflow and the NuttX principles.

License

The code in this repository is under either the Apache 2 license, or a license compatible with the Apache 2 license. See the License Page for more information.