-
Notifications
You must be signed in to change notification settings - Fork 3k
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
GCC - hardfault in mktime with irq disabled #2647
Comments
An update to add that the problem happen on mbed 5 and mbed 2 + RTOS but not on mbed 2. So the problem must come from the RTOS. |
@c1728p9 I think we looked at this previously. Mind sharing what our thoughts were here? |
ARM Internal Ref: IOTMORF-461 |
Hi @svastm, a hardfault occurs because the gcc standard library (newlib) is internally using a mutex to protect global information. This causes a hardfault because a mutex is not allowed to be used inside a critical section. There should be no need for a critical section around mktime. |
Hello, We could consider to check the PRIMASK before using mutex.
/// Wait until a Mutex becomes available
osStatus osMutexWait (osMutexId mutex_id, uint32_t millisec) {
if (__get_IPSR() != 0U || __get_PRIMASK() != 0U) {
return osErrorISR; // Not allowed in ISR and with interrupt disabled
}
return __svcMutexWait(mutex_id, millisec);
}
/// Release a Mutex that was obtained with osMutexWait
osStatus osMutexRelease (osMutexId mutex_id) {
if (__get_IPSR() != 0U || __get_PRIMASK() != 0U) {
return osErrorISR; // Not allowed in ISR and with interrupt disabled
}
return __svcMutexRelease(mutex_id);
} I have no more error in |
Hi @svastm, a changes similar to that is being discussed here: The problem with that is that it will mask errors. Since the mutex is never acquired, thread safety isn't provided. Even though the current thread will complete the call to mktime without being interrupted there could be another thread using the same global data that is not in a critical section. Since the second thread is relying on the mutex to protect this data, the first thread could interrupt an operation at any time since it won't block on any mutexes. |
After the merge of #2391, I am able to run the small test code on a DISCO_F469NI. |
…..4a3c5c5 4a3c5c5 Merge remote-tracking branch 'origin/release_internal' into release_external 2b8d2e1 Do not reset radio when MAC data request timeouts (ARMmbed#2647) 95c506a Frame counters for nw keys are now stored to NVM only after send key is set (ARMmbed#2641) 3b3010a Adjusted stagger random to [min,min+max] and for small nw set the stagger value to 10 seconds 02bc33a Adjusted security protocol (EAP-TLS,4WH,2WH) retry timers eb26726 High Priority timestamp compare overflow support fix. 928723a FHSS WS: Initialize broadcast channel count when enabling FHSS (ARMmbed#2642) 6040d70 Updated change log 667b191 Changed initial EAPOL-key retries from trickle to exponential backup d925145 Add RTT calculation for DHCP Time calculation 0b82953 Traceroute bug fix. 04de6e2 Merge pull request ARMmbed#2638 from PelionIoT/mbed_os_fix_ufsi_calculation 2012347 Fixed FHSS UFSI calculation unit tests 436f16e Handle timer rollover in calculate_ufsi 411cf5c coding style d6f4421 Correct ufsi timing calculation 560619d Add network time vendor data element to DHCPv6 reply message 6d290dc System time read/write callbacks (ARMmbed#2637) 7905df6 Restart or remove transmission when MAC data request timeouts (ARMmbed#2636) c97695c Bug fix: EAPOL parent compare fix e283e62 Fixed channel mask usage with OFDM configurations (ARMmbed#2633) 24168f8 Do not send too old packets (ARMmbed#2632) dbd83be Fix copyrights (ARMmbed#2631) 7f0cffd Merge pull request ARMmbed#2630 from PelionIoT/use_pelion_copyright 511bd5a Corrected coding style 57ec028 Corrected comparison 7d853de When EAPOL waiting queue is full oldest entry is removed acf580f Update copyright in changed MDNS files 933c0bb Update copyright 3aeb2af Statistics for data request latencies (ARMmbed#2629) 3f7eae6 EAPOL FHSS temp entry discover 5200b66 DHCP time elapsed time write fix. 0536874 Removed empty EAPOL-key message send after 4WH completion to nodes on relay 8a2a683 Fixed DHCP wrong time elapsed value write. 283f2ee DHCPv6 update: 99be778 EAPOL temp neighbour update 4f9e3d1 Adaptation layer to remove oldest packet first 20f1f64 Added ignoring of retry messages from RADIUS server when waiting EAP-TLS 8a8b407 Add RSL check for ETX Calculation for RPL parent selection c05e1da Fix DHCP server Uninitialized memory read 77229ee Fix CPP error from domain prefix check 7e47889 support filtering of EAPOL parents based device-min-sens configuration 618a191 Wi-SUN Expedite forward state update 4371462 Fix NULL read from RPL header addition 7802c7e Update CHANGELOG.md b2c8104 CHANGELOG for Nanostack v13.0.0 (ARMmbed#2615) git-subtree-dir: features/nanostack/sal-stack-nanostack git-subtree-split: 4a3c5c5
…903b81..4a3c5c5 4a3c5c5 Merge remote-tracking branch 'origin/release_internal' into release_external 2b8d2e1 Do not reset radio when MAC data request timeouts (ARMmbed#2647) 95c506a Frame counters for nw keys are now stored to NVM only after send key is set (ARMmbed#2641) 3b3010a Adjusted stagger random to [min,min+max] and for small nw set the stagger value to 10 seconds 02bc33a Adjusted security protocol (EAP-TLS,4WH,2WH) retry timers eb26726 High Priority timestamp compare overflow support fix. 928723a FHSS WS: Initialize broadcast channel count when enabling FHSS (ARMmbed#2642) 6040d70 Updated change log 667b191 Changed initial EAPOL-key retries from trickle to exponential backup d925145 Add RTT calculation for DHCP Time calculation 0b82953 Traceroute bug fix. 04de6e2 Merge pull request ARMmbed#2638 from PelionIoT/mbed_os_fix_ufsi_calculation 2012347 Fixed FHSS UFSI calculation unit tests 436f16e Handle timer rollover in calculate_ufsi 411cf5c coding style d6f4421 Correct ufsi timing calculation 560619d Add network time vendor data element to DHCPv6 reply message 6d290dc System time read/write callbacks (ARMmbed#2637) 7905df6 Restart or remove transmission when MAC data request timeouts (ARMmbed#2636) c97695c Bug fix: EAPOL parent compare fix e283e62 Fixed channel mask usage with OFDM configurations (ARMmbed#2633) 24168f8 Do not send too old packets (ARMmbed#2632) dbd83be Fix copyrights (ARMmbed#2631) 7f0cffd Merge pull request ARMmbed#2630 from PelionIoT/use_pelion_copyright 511bd5a Corrected coding style 57ec028 Corrected comparison 7d853de When EAPOL waiting queue is full oldest entry is removed acf580f Update copyright in changed MDNS files 933c0bb Update copyright 3aeb2af Statistics for data request latencies (ARMmbed#2629) 3f7eae6 EAPOL FHSS temp entry discover 5200b66 DHCP time elapsed time write fix. 0536874 Removed empty EAPOL-key message send after 4WH completion to nodes on relay 8a2a683 Fixed DHCP wrong time elapsed value write. 283f2ee DHCPv6 update: 99be778 EAPOL temp neighbour update 4f9e3d1 Adaptation layer to remove oldest packet first 20f1f64 Added ignoring of retry messages from RADIUS server when waiting EAP-TLS 8a8b407 Add RSL check for ETX Calculation for RPL parent selection c05e1da Fix DHCP server Uninitialized memory read 77229ee Fix CPP error from domain prefix check 7e47889 support filtering of EAPOL parents based device-min-sens configuration 618a191 Wi-SUN Expedite forward state update 4371462 Fix NULL read from RPL header addition 7802c7e Update CHANGELOG.md b2c8104 CHANGELOG for Nanostack v13.0.0 (ARMmbed#2615) git-subtree-dir: connectivity/nanostack/sal-stack-nanostack git-subtree-split: 4a3c5c5
…903b81..4a3c5c5 4a3c5c5 Merge remote-tracking branch 'origin/release_internal' into release_external 2b8d2e1 Do not reset radio when MAC data request timeouts (ARMmbed#2647) 95c506a Frame counters for nw keys are now stored to NVM only after send key is set (ARMmbed#2641) 3b3010a Adjusted stagger random to [min,min+max] and for small nw set the stagger value to 10 seconds 02bc33a Adjusted security protocol (EAP-TLS,4WH,2WH) retry timers eb26726 High Priority timestamp compare overflow support fix. 928723a FHSS WS: Initialize broadcast channel count when enabling FHSS (ARMmbed#2642) 6040d70 Updated change log 667b191 Changed initial EAPOL-key retries from trickle to exponential backup d925145 Add RTT calculation for DHCP Time calculation 0b82953 Traceroute bug fix. 04de6e2 Merge pull request ARMmbed#2638 from PelionIoT/mbed_os_fix_ufsi_calculation 2012347 Fixed FHSS UFSI calculation unit tests 436f16e Handle timer rollover in calculate_ufsi 411cf5c coding style d6f4421 Correct ufsi timing calculation 560619d Add network time vendor data element to DHCPv6 reply message 6d290dc System time read/write callbacks (ARMmbed#2637) 7905df6 Restart or remove transmission when MAC data request timeouts (ARMmbed#2636) c97695c Bug fix: EAPOL parent compare fix e283e62 Fixed channel mask usage with OFDM configurations (ARMmbed#2633) 24168f8 Do not send too old packets (ARMmbed#2632) dbd83be Fix copyrights (ARMmbed#2631) 7f0cffd Merge pull request ARMmbed#2630 from PelionIoT/use_pelion_copyright 511bd5a Corrected coding style 57ec028 Corrected comparison 7d853de When EAPOL waiting queue is full oldest entry is removed acf580f Update copyright in changed MDNS files 933c0bb Update copyright 3aeb2af Statistics for data request latencies (ARMmbed#2629) 3f7eae6 EAPOL FHSS temp entry discover 5200b66 DHCP time elapsed time write fix. 0536874 Removed empty EAPOL-key message send after 4WH completion to nodes on relay 8a2a683 Fixed DHCP wrong time elapsed value write. 283f2ee DHCPv6 update: 99be778 EAPOL temp neighbour update 4f9e3d1 Adaptation layer to remove oldest packet first 20f1f64 Added ignoring of retry messages from RADIUS server when waiting EAP-TLS 8a8b407 Add RSL check for ETX Calculation for RPL parent selection c05e1da Fix DHCP server Uninitialized memory read 77229ee Fix CPP error from domain prefix check 7e47889 support filtering of EAPOL parents based device-min-sens configuration 618a191 Wi-SUN Expedite forward state update 4371462 Fix NULL read from RPL header addition 7802c7e Update CHANGELOG.md b2c8104 CHANGELOG for Nanostack v13.0.0 (ARMmbed#2615) git-subtree-dir: connectivity/nanostack/sal-stack-nanostack git-subtree-split: 4a3c5c5
…..4a3c5c5 4a3c5c5 Merge remote-tracking branch 'origin/release_internal' into release_external 2b8d2e1 Do not reset radio when MAC data request timeouts (ARMmbed#2647) 95c506a Frame counters for nw keys are now stored to NVM only after send key is set (ARMmbed#2641) 3b3010a Adjusted stagger random to [min,min+max] and for small nw set the stagger value to 10 seconds 02bc33a Adjusted security protocol (EAP-TLS,4WH,2WH) retry timers eb26726 High Priority timestamp compare overflow support fix. 928723a FHSS WS: Initialize broadcast channel count when enabling FHSS (ARMmbed#2642) 6040d70 Updated change log 667b191 Changed initial EAPOL-key retries from trickle to exponential backup d925145 Add RTT calculation for DHCP Time calculation 0b82953 Traceroute bug fix. 04de6e2 Merge pull request ARMmbed#2638 from PelionIoT/mbed_os_fix_ufsi_calculation 2012347 Fixed FHSS UFSI calculation unit tests 436f16e Handle timer rollover in calculate_ufsi 411cf5c coding style d6f4421 Correct ufsi timing calculation 560619d Add network time vendor data element to DHCPv6 reply message 6d290dc System time read/write callbacks (ARMmbed#2637) 7905df6 Restart or remove transmission when MAC data request timeouts (ARMmbed#2636) c97695c Bug fix: EAPOL parent compare fix e283e62 Fixed channel mask usage with OFDM configurations (ARMmbed#2633) 24168f8 Do not send too old packets (ARMmbed#2632) dbd83be Fix copyrights (ARMmbed#2631) 7f0cffd Merge pull request ARMmbed#2630 from PelionIoT/use_pelion_copyright 511bd5a Corrected coding style 57ec028 Corrected comparison 7d853de When EAPOL waiting queue is full oldest entry is removed acf580f Update copyright in changed MDNS files 933c0bb Update copyright 3aeb2af Statistics for data request latencies (ARMmbed#2629) 3f7eae6 EAPOL FHSS temp entry discover 5200b66 DHCP time elapsed time write fix. 0536874 Removed empty EAPOL-key message send after 4WH completion to nodes on relay 8a2a683 Fixed DHCP wrong time elapsed value write. 283f2ee DHCPv6 update: 99be778 EAPOL temp neighbour update 4f9e3d1 Adaptation layer to remove oldest packet first 20f1f64 Added ignoring of retry messages from RADIUS server when waiting EAP-TLS 8a8b407 Add RSL check for ETX Calculation for RPL parent selection c05e1da Fix DHCP server Uninitialized memory read 77229ee Fix CPP error from domain prefix check 7e47889 support filtering of EAPOL parents based device-min-sens configuration 618a191 Wi-SUN Expedite forward state update 4371462 Fix NULL read from RPL header addition 7802c7e Update CHANGELOG.md b2c8104 CHANGELOG for Nanostack v13.0.0 (ARMmbed#2615) git-subtree-dir: features/nanostack/sal-stack-nanostack git-subtree-split: 4a3c5c5
I don't know if some other standard function are affected but it seems that every time we call
mktime()
in a critical section, with GCC only, an hardfault is fired. Both standard and nano libs seems to be affected. I tried with the NUCLEO_F303RE and NUCLEO_F429ZI and the mbed-cli to compile the tests.with this main.cpp
and the output, same result on GCC v5.3 and v4.9.
An other thing that can be related, with ARM and IAR compilers, we can't use printf() in critical section (which should be the normal behaviour, the serial_api use interrupts) but with GCC the text is printed.
The text was updated successfully, but these errors were encountered: