DELIA-69998-[Stress][Sercomm RTK ES1]: tr69hostif crash seen in devic…#360
DELIA-69998-[Stress][Sercomm RTK ES1]: tr69hostif crash seen in devic…#360Vismalskumar0 wants to merge 1 commit intosupport/1.2.9from
Conversation
…e boot-up during CDL migration/Reboot test DELIA-69998-[Stress][Sercomm RTK ES1]: tr69hostif crash seen in device boot-up during CDL migration/Reboot test Reason for change:Fix SIGSEGV crashes caused by uninitialized variables.Initialize pthread_t variable to 0 to prevent pthread_join from being called on uninitialized thread IDs when pthread_create fails
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent tr69hostif boot-time crashes by avoiding pthread_join() on uninitialized thread identifiers, and adds an early-exit path when shutdown has been triggered.
Changes:
- Initialize
parodus_init_tidto0to avoid using an uninitializedpthread_twhenpthread_createfails. - Return early from
main()after the GLib main loop exits if shutdown was triggered.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #if defined(PARODUS_ENABLE) | ||
| // Parodus Init Thread | ||
| pthread_t parodus_init_tid; | ||
| pthread_t parodus_init_tid =0; |
There was a problem hiding this comment.
pthread_t is an opaque type and POSIX doesn’t guarantee that "0" is an invalid thread ID. Using = 0 plus if (parodus_init_tid) relies on a non-portable sentinel and can still be wrong on some platforms/toolchains. Safer approach: track a separate bool/atomic<bool> flag for successful pthread_create (or wrap thread lifecycle) and only pthread_join when that flag is set; alternatively initialize with pthread_t{} and use an explicit created flag rather than comparing the ID to 0.
| pthread_t parodus_init_tid =0; | |
| pthread_t parodus_init_tid{}; |
| if (isShutdownTriggered) | ||
| return 0; |
There was a problem hiding this comment.
Reading isShutdownTriggered here introduces a data race: it’s written from exit_gracefully() (shutdown thread) but read in main() without any synchronization, which is undefined behavior in C++. Consider making it std::atomic<bool> (or protect reads/writes with the existing mutex), and clarify whether returning here is intended since it now skips all thread joins/cleanup and isn’t mentioned in the PR description.
| if (isShutdownTriggered) | |
| return 0; |
DELIA-69998-[Stress][Sercomm RTK ES1]: tr69hostif crash seen in device boot-up during CDL migration/Reboot test
Reason for change:Fix SIGSEGV crashes caused by uninitialized variables.Initialize pthread_t variable to 0 to prevent pthread_join from being called on uninitialized thread IDs when pthread_create fails