Skip to content

testing/sched/spawnattr: Add a test of a failing spawn attribute. - #4060

Draft
casaroli wants to merge 1 commit into
apache:masterfrom
casaroli:spawnattr-errout-test-up
Draft

casaroli wants to merge 1 commit into
apache:masterfrom
casaroli:spawnattr-errout-test-up

Conversation

@casaroli

Copy link
Copy Markdown
Contributor

depends-on: apache/nuttx/pull/21898

Summary

Add testing/sched/spawnattr, a test of a spawn attribute that the kernel refuses after it made the new task. posix_spawn() with POSIX_SPAWN_SETSCHEDPARAM and priority 0 must return EINVAL. The test does it 100 times and checks that the heap of the caller stays intact: a pattern in new blocks after each error, and mallinfo() before and after. Then a normal posix_spawn() must work. The child is the test program again.

A kernel build crashed in this error path of exec_module(); apache/nuttx#21898 fixes it.

Impact

A new test program, default n. Its Kconfig option depends on LIBC_EXECFUNCS and SCHED_WAITPID. No other app changes.

Testing

Configuration nuttx master nuttx with #21898
qemu-armv8a:knsh (kernel, QEMU with HVF), test compiled against the export Assertion failed : at file: mm_heap/mm_malloc_size.c:73 at the first posix_spawn(), then a kernel panic 4 of 4 PASS (100 times EINVAL, pattern intact, mallinfo() the same, the good posix_spawn() exits with 7)
qemu-armv8a:nsh (flat, Make build) 3 PASS, mallinfo FAIL (see below) the same: #21898 does not change the flat build

ostest exits with status 0 on qemu-armv8a:knsh and qemu-armv8a:nsh with #21898.

TBD (Marco): in the flat build the heap grows by about 30 bytes for each failed posix_spawn() (608 bytes for 20, and 32 bytes for 20 good ones). The child status that nxtask_setup_scheduler() adds to the parent with CONFIG_SCHED_CHILD_STATUS is not removed by nxtask_uninit(). This is a separate bug.

tools/checkpatch.sh -c -u -m -g of nuttx passes on the commit.

posix_spawn() with POSIX_SPAWN_SETSCHEDPARAM and priority 0 must fail
with EINVAL: the kernel refuses the attribute after it made the new
task.  The test does it 100 times and checks that the heap of the caller
stays intact (a pattern in new blocks after each error, and mallinfo()
before and after), then that a normal posix_spawn() works.  The child is
the test program again.

A kernel build crashed in this error path of exec_module() (the copies
of the arguments were freed twice).

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant