-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Infinite Reboot loop in Constructor C++ #23998
Comments
@hakkimakki could you enable |
@vanwinkeljan do you have any suggestions here? |
@carlescufi Not really except to step through the code with gdb Actually a complete prj.conf would be welcome, is the bug seen with newlibc or minallibc, ... |
Thanks for your responses my proj.conf is: CONFIG_SERIAL=y CONFIG_NEWLIB_LIBC=y |
However I just found the problem. The reboot loop is caused by the two variable declarations before the declaration of the array of objects (see code below). If the two other variables are commentet out the ctor works fine. This is my main.cpp file:
|
Looks like a potential stack issue, could you create the object on the heap? |
It looks like the object is allocated on the heap because i can step through the whole ctor just fine. However while leaving the main thread there is an assert failure. I just figured out by enabling CONFIG_DEBUG=y resolves the issue aswell. So maybee its related to optimaziations (see: https://docs.zephyrproject.org/latest/reference/kconfig/CONFIG_DEBUG.html?highlight=config_debug#cmdoption-arg-config-debug) |
@hakkimakki if you think this is solved, please close the issue. If you need more information let us know. |
I can't reproduce this with either the referenced ARM-Embedded toolchain or the Zephyr 0.11.1. It may be specific to the NCS fork. |
Sorry for the delay. I could create the object on the heap with and it worked fine:
so @vanwinkeljan I guess you are right. However I just setup a pure zephyr enviroment without the ncs fork and it looks like the same behavior. The code stucks after done and doesnt reboot like in the ncs fork (@pabigot) .
however i could get along by changeing the ctor to not loop over for initializing the channels instead hard coding the channels. For me its fine but the issue stays somewhere in the stack. |
I remain unable to reproduce this at the specified Zephyr commit and toolchains using nrf52840dk_nrf52840. https://gist.github.com/pabigot/8057774cc407f5e7b6d04801c4c4743d contains the sample code, showing that the main routine continues after the object has been constructed, and confirms successful construction. |
sorry I made a mistake by testing the code. The stuck mentoined above means that it worked. So it is the nRFConnect SDK fork causing this issue. I will close this one. Thanks anyway guys. |
Dear Zephyr Community
I discovered a stange behavior within the code in a C++ Constructor. The below initialisation works if it is placed outside the ctor in a seperate function. But if included in the ctor it ends up in an infinite reboot of zephyr.
The class is included in the main.cpp and after calling the constructor with:
The nRF52840 keeps on rebooting infinitly:
Enviroment used for reproduction:
nRF52840 (PCA10056) Board
cmake version 3.16.2
arm-none-eabi-c++ (GNU Tools for Arm Embedded Processors 8-2019-q3-update) 8.3.1 2019070 (release) [gcc-8-branch revision 273027]
However if the critical code is included in a seperate function it works fine:
Could somebody help me with this behavoir if this is my fault or the fault of the Zephyr RTOS somehow.
Thanks a lot.
The text was updated successfully, but these errors were encountered: