nightt5879 opened a new pull request, #3500:
URL: https://github.com/apache/nuttx-apps/pull/3500
## Summary
Fixes #3105.
This PR fixes the settings deadlock that can happen when
`CONFIG_SYSTEM_SETTINGS_CACHED_SAVES` is disabled.
Commit structure:
- Commit 1 (`system/settings: Avoid recursive save locking`) is the strict
#3105 fix. The immediate save path now writes pending settings through a helper
that assumes `g_settings.mtx` is already held, instead of calling the timer
callback that locks the same mutex again. The cached-save timer callback still
takes the mutex before using the same helper.
- Commit 2 (`system/settings: Drop unused recursive mutex type`) is a small
related cleanup. Since the settings save path no longer re-enters
`g_settings.mtx`, the mutex no longer needs `PTHREAD_MUTEX_RECURSIVE`; this
also keeps the fix independent of `CONFIG_PTHREAD_MUTEX_TYPES`. It also
destroys the temporary mutex attribute object after initialization.
The second commit is logically separable and I am happy to drop it if
maintainers consider it out of scope for #3105.
Out of scope:
- This does not change the public settings API.
- This does not change the storage file formats.
- This does not include the separate safer string handling work requested in
#3109.
## Impact
With cached saves disabled, settings operations that save immediately no
longer try to lock `g_settings.mtx` recursively via `dump_cache()`.
- New feature: NO
- User adaptation required: NO
- Build process change: NO
- Hardware/architecture/board change: NO
- Documentation update required: NO
- Security impact: NO intended security impact
- Compatibility impact: NO intended compatibility impact
## Testing
Host:
- Windows with WSL Ubuntu 24.04
- CPU: x86_64
- Compiler: GCC 13.3.0
Checks:
- `git diff --check upstream/master..HEAD`: pass
- `checkpatch.sh -c -u -m -g HEAD~2..HEAD`: pass
- `sim:nsh` build: pass
- `CONFIG_SYSTEM_SETTINGS=y`
- `# CONFIG_SYSTEM_SETTINGS_CACHED_SAVES is not set`
- `# CONFIG_PTHREAD_MUTEX_TYPES is not set`
- confirmed `CC: settings.c`
- result: `SIM elf with dynamic libs archive in nuttx.tgz`
Note: the temporary test build appended config overrides after configuring
`sim:nsh`, so `.config` printed expected override warnings for the settings and
pthread mutex options.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]