-
Notifications
You must be signed in to change notification settings - Fork 1.3k
list.c: improve code comments to point to official documentation about problems which may cause code to get stuck inside of list.c #1051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -184,6 +184,15 @@ void vListInsert( List_t * const pxList, | |
* 4) Using a queue or semaphore before it has been initialised or | ||
* before the scheduler has been started (are interrupts firing | ||
* before vTaskStartScheduler() has been called?). | ||
* - This includes initializing binary semaphores before taking them. If | ||
* you create one with `xSemaphoreCreateBinary()` or | ||
* `xSemaphoreCreateBinaryStatic()`, you must call `xSemaphoreGive()` | ||
* before calling `xSemaphoreTake(). See: | ||
* https://freertos.org/xSemaphoreCreateBinaryStatic.html: | ||
* > The semaphore is created in the 'empty' state, meaning the | ||
* > semaphore must first be given using the xSemaphoreGive() API | ||
* > function before it can subsequently be taken (obtained) using the | ||
* > xSemaphoreTake() function. | ||
* 5) If the FreeRTOS port supports interrupt nesting then ensure that | ||
* the priority of the tick interrupt is at or below | ||
* configMAX_SYSCALL_INTERRUPT_PRIORITY. | ||
|
@@ -192,7 +201,9 @@ void vListInsert( List_t * const pxList, | |
for( pxIterator = ( ListItem_t * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) | ||
{ | ||
/* There is nothing to do here, just iterating to the wanted | ||
* insertion position. */ | ||
* insertion position. | ||
* IF YOU FIND YOUR CODE STUCK HERE, SEE THE NOTE JUST ABOVE. | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's remove this. It's 10 lines from the comment block above explaining common causes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's my logic: Here's the view from the MPLAB X IDE while debugging and halting on this for loop, on which the code is stuck. My eyes naturally focus on the contents of the for loop, in yellow: The purpose of this line:
Is to tell me to look at the notes above, or else I won't, because I'm looking inside the for loop in which the debugger is stuck, instead. |
||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to expand this comment so much. Maybe point 4 could be changed to...
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see the only part you recommend adding then is this:
That doesn't add anything at all in my opinion. I've already been reading the respective object documentation for years, and actively reading it recently for months.
The scenario is this:
I'm in a several million line codebase.
I did a 1.2 million line (400+ files changed) merge, where there were dozens of files with significant conflicts and in which it took me days to resolve them.
I have no idea why the code no longer runs, but I keep getting stuck in this for loop now and don't know why. What "respective object documentation" should I read in such a situation!? We are using half of the FreeRTOS objects in the kernel and I don't know why my code won't run after a 1.2 million line merge, and which of these objects is now being misused.
By adding my two comments here, when debugging, I'd see this in my debugger, where the green line indicates where the debugger is stuck:
Except in the yellow area I'd then see this:
...and then I'd read above. And when I read above, I'd then see this:
and then I'd go search my merge commit for changes to semaphores, see we converted a mutex to a binary semaphore, and add the
xSemaphoreGive()
call after creating it (which calls got botched and removed in the merge). Boom done. Would have saved me 2 weeks of non-stop debugging.