Comments (7)
yes, it worked!!
Thank you @anchao for the quick action.👍
Let me close the issue~
from nuttx.
Hi, @HongxiaWangSSSS
Do you have other test cases that can reproduce this issue?
joininfo will not be released until the task group is destroyed:
https://github.com/apache/nuttx/blob/master/sched/pthread/pthread_release.c#L60-L80
from nuttx.
I tried to run the test code in the C native, the test case works as expected:
- replace the test code:
$ git status
HEAD detached at origin/master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: examples/hello/hello_main.c
no changes added to commit (use "git add" and/or "git commit -a")
- remove the wasi api:
- run the test demo:
./tools/configure.sh sabre-6quad/nsh
$ qemu-system-arm -semihosting -M sabrelite -m 1024 -smp 4 -nographic -kernel ./nuttx
NuttShell (NSH) NuttX-10.4.0
nsh> hello
Spawning stress test is 10% finished
Spawning stress test is 20% finished
Spawning stress test is 30% finished
Spawning stress test is 40% finished
Spawning stress test is 50% finished
Spawning stress test is 60% finished
Spawning stress test is 70% finished
Spawning stress test is 80% finished
Spawning stress test is 89% finished
Spawning stress test finished successfully executed 50000 threads with retry ratio 1.000160
nsh> free
total used free maxused maxfree nused nfree
Umem: 1065190036 10132 1065179904 1247684 1065166264 24 3
nsh> hello
Spawning stress test is 10% finished
Spawning stress test is 20% finished
Spawning stress test is 30% finished
Spawning stress test is 40% finished
Spawning stress test is 50% finished
Spawning stress test is 60% finished
Spawning stress test is 70% finished
Spawning stress test is 80% finished
Spawning stress test is 89% finished
Spawning stress test finished successfully executed 100000 threads with retry ratio 1.000120
nsh> free
total used free maxused maxfree nused nfree
Umem: 1065190036 10132 1065179904 1247684 1065166264 24 3
nsh>
from nuttx.
Hi,
Thank you for the test !!!🙇
Yes, I also found the exit and memory leak only occurs when built this sample into WASM/AOT, and during the run time, it continued malloc until exited and never released.
Maybe I should investigate the pthread_join's implementation in WASI-LIBC side.
Anyway, thank you for your explanation~ If there is any progress I will update.
BR,
Hongxia
from nuttx.
I probably know the root cause. after the introduction of #11898, the detached thread will not destroy the joininfo. In your test case, a large number of pthreads will be created with detached attribute, so there will be many joininfo pending in the task group,each of joininfo is to ensure that pthread_join() could gets the correct return value:
joining a detached/canceled thread should return EINVAL, not ESRCH
https://github.com/apache/nuttx/blob/master/sched/pthread/pthread_join.c#L92-L102
since many of joininfo will consume too much memory, I think this is not friendly to embedded MCU devices,maybe we can keep the semantics before #11898 was introduced, @xiaoxiang781216 how do you think?
from nuttx.
thread should release joininfo after detaching, since nobody will call pthread_join.
from nuttx.
@HongxiaWangSSSS please try PR #12106
from nuttx.
Related Issues (20)
- docs: "copy" button mangles content of Makefile snippet HOT 2
- docs: confusing duplication for Kconfig in custom app HOT 7
- NSH: startup script crash HOT 1
- riscv/cmake: protected mode issue HOT 3
- refresh.sh script generating warning messages if riscv64-unknown-elf-gcc is not installed HOT 1
- build error with kernel mode HOT 5
- Apr 05, 2024 : GitHub Status
- when i start nuttx (sim:nsh), it throw a signal which is SIGSEGV HOT 3
- NUVOTON MA35H0, MA35D1 processors HOT 4
- esp32: Compile error regarding assert statement in esp-hal-3rdparty code HOT 8
- Can't build custom board HOT 5
- rv-virt/knsh32 crashes after runing ELF app HOT 1
- When i use cmake to build sim:libcxxtest, it display undefined reference to `NXpthread_setspecific' HOT 9
- Inconsistency in function headers style HOT 3
- Our nxstyle.c checker is not validation single line "if ()" without brackets
- How does I2C support various types of slave devices? HOT 3
- tools/nuttx-gdbinit: No such file or directory HOT 3
- usbtrace causes crash HOT 3
- RNDIS is not working with ping HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nuttx.