[BUG] Rust: libc::PTHREAD_MUTEX_INITIALIZER is incorrect
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Active
- Domain
- embedded-iot, operating-systems
Research direction
Compare Rust libc's definition in src/unix/nuttx/mod.rs with NuttX's PTHREAD_MUTEX_INITIALIZER in include/pthread.h and NXSEM_NO_MHOLDER in include/nuttx/semaphore.h. Then inspect Rust std's use in library/std/src/sys/pal/unix/sync/mutex.rs. Done means an agreed approach produces a valid mutex initializer across the relevant NuttX configurations.
Written by the indexing model from the issue text.
Description
Description / Steps to reproduce the issue
Rust libc initializes PTHREAD_MUTEX_INITIALIZER to 0: https://github.com/rust-lang/libc/blob/c2744242b816317ea8b5c8e306eb829c080cb2b9/src/unix/nuttx/mod.rs#L310
But in NuttX this is generally not 0.
For example, defined here: https://github.com/apache/nuttx/blob/master/include/pthread.h#L359
Going into https://github.com/apache/nuttx/blob/master/include/pthread.h#L353
Which makes use of NXSEM_NO_MHOLDER, defined here: https://github.com/apache/nuttx/blob/master/include/nuttx/semaphore.h#L70
Furthermore, the initialization also depends on the configuration.
In Rust, std makes use of the constant to init mutexes, e.g. here: https://github.com/rust-lang/rust/blob/7d2cd0fbc092625ea371da704f15f80216d2220e/library/std/src/sys/pal/unix/sync/mutex.rs#L12
I'm not sure what the best solution is, I see some options:
- remove the symbol definition from Rust (and update std to use
pthread_mutex_initinstead) - init the Rust definition to a matching value and either require a certain config or make sure the position of the non-zero values is independent from the config
- update NuttX so the definition is always 0 (in addition to requiring a specific config)
On which OS does this issue occur?
[OS: Linux], [OS: BSD], [OS: Mac], [OS: Windows]
What is the version of your OS?
Irrelevant
NuttX Version
master
Issue Architecture
[Arch: all]
Issue Area
[Area: Posix], [Area: Applications]
Host information
No response
Verification
- I have verified before submitting the report.
- Dominant language
- C
- Stars
- 4.1k
- Forks
- 1.8k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 833
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/nuttx
-
Arch: all Arch: arm Area: Build system OS: Linux Type: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
apache/nuttx#19435 · 9 comments ·
Maintainers usually reply within 1 day
-
Arch: all OS: Linux Type: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
apache/nuttx#16249 · 7 comments ·
Maintainers usually reply within 1 day
-
Arch: all Area: Networking OS: Linux
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Maintainers usually reply within 1 day
-
Type: Enhancement
Difficulty 4/5 3-5 days Newbie friendliness 22/100
apache/nuttx#21581 · 1 comment ·
Maintainers usually reply within 1 day
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
SPIDevice selects an active-high device as soon as it is createdPossibly taken @mikeysklar claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
adafruit/circuitpython#11869 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
gnif/LookingGlass#1352 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
kovidgoyal/kitty#10862 ·
Maintainers usually reply within 1 day