Skip to content
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

Fix for 06-Mutex Challenge Solution #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

morgoob
Copy link

@morgoob morgoob commented Jan 21, 2024

Pull Request Description

Issue

The blinkLED task calls xSemaphoreGive(mutex) without having acquired the mutex using xSemaphoreTake(mutex, portMAX_DELAY) first, causing a system reboot (due to failed assertion) after the delay value is entered by a user.

Output

Here is the output of the original solution:

---FreeRTOS Mutex Solution---
Enter a number for delay (milliseconds)
Sending: 50

assert failed: xQueueGenericSend queue.c:832 (pxQueue->pcHead != ((void *)0) || pxQueue->u.xSemaphore.xMutexHolder == ((void *)0) || pxQueue->u.xSemaphore.xMutexHolder == xTaskGetCurrentTaskHandle())

assert failed: xQueueGenericSend queue.c:832 (pxQueue->pcHead != ((void *)0) || pxQueue->u.xSemaphore.xMutexHolder == ((void *)0) || pxQueue->u.xSemaphore.xMutexHolder == xTaskGetCurrentTaskHandle())


Backtrace: 0x400881a7:0x3ffbb0a0 0x400833dc:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 0x400881a7:0x3ffbb160 0x400881a7:0x3ffbb180 0x400881a7:0x3ffbb1f0 0x4008007d:0x3ffbb0a0 0x40082ff1:0x3ffbb0c0 0x400881a7:0x3ffbb0e0 0x400881a7:0x3ffbb110 0x400881a7:0x3ffbb140 |<-CONTINUES

ELF file SHA256: 42aaf96fb649f818

Rebooting...
ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1184
load:0x40078000,len:13260
load:0x40080400,len:3028
entry 0x400805e4

Here is the output with my fix:

---FreeRTOS Mutex Solution---
Enter a number for delay (milliseconds)
Sending: 250
Received: 250
Done!

…D task tries to release the mutex without ever acquiring it. Causes system to reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant