{"action":"created","issue":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/5563","repository_url":"https://api.github.com/repos/RIOT-OS/RIOT","labels_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/5563/labels{/name}","comments_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/5563/comments","events_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/5563/events","html_url":"https://github.com/RIOT-OS/RIOT/issues/5563","id":161468263,"number":5563,"title":"Hard fault with C++ and ARM","user":{"login":"jia200x","id":1260616,"avatar_url":"https://avatars.githubusercontent.com/u/1260616?v=3","gravatar_id":"","url":"https://api.github.com/users/jia200x","html_url":"https://github.com/jia200x","followers_url":"https://api.github.com/users/jia200x/followers","following_url":"https://api.github.com/users/jia200x/following{/other_user}","gists_url":"https://api.github.com/users/jia200x/gists{/gist_id}","starred_url":"https://api.github.com/users/jia200x/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jia200x/subscriptions","organizations_url":"https://api.github.com/users/jia200x/orgs","repos_url":"https://api.github.com/users/jia200x/repos","events_url":"https://api.github.com/users/jia200x/events{/privacy}","received_events_url":"https://api.github.com/users/jia200x/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/RIOT-OS/RIOT/labels/arm","name":"arm","color":"dddddd"},{"url":"https://api.github.com/repos/RIOT-OS/RIOT/labels/C++","name":"C++","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2016-06-21T15:30:06Z","updated_at":"2016-06-22T15:35:54Z","closed_at":null,"body":"Hi community,\r\n\r\nI'm porting the OpenThread stack to RIOT. As I wrote in devel, I'm having a hard fault when I link RIOT with the core of OT. This error is happening with all ARM boards. I have been using a SAMR21-xpro.\r\n\r\nRIOT is crashing in this line [[1]], function libc_init_array(). Here's the content of hardfault:\r\n\r\n```\r\n2016-06-17 13:40:42,716 - INFO # Context before hardfault:\r\n2016-06-17 13:40:42,718 - INFO #    r0: 0x00000000\r\n2016-06-17 13:40:42,719 - INFO #    r1: 0x00000655\r\n2016-06-17 13:40:42,721 - INFO #    r2: 0x00000000\r\n2016-06-17 13:40:42,722 - INFO #    r3: 0x000058c4\r\n2016-06-17 13:40:42,724 - INFO #   r12: 0x00000000\r\n2016-06-17 13:40:42,726 - INFO #    lr: 0x00021ea7\r\n2016-06-17 13:40:42,727 - INFO #    pc: 0x000058c4\r\n2016-06-17 13:40:42,729 - INFO #   psr: 0x40000000\r\n2016-06-17 13:40:42,729 - INFO # \r\n2016-06-17 13:40:42,729 - INFO # Misc\r\n2016-06-17 13:40:42,731 - INFO # EXC_RET: 0xfffffff9\r\n2016-06-17 13:40:42,735 - INFO # Attempting to reconstruct state for debugging...\r\n2016-06-17 13:40:42,736 - INFO # In GDB:\r\n2016-06-17 13:40:42,737 - INFO #   set $pc=0x58c4\r\n2016-06-17 13:40:42,738 - INFO #   frame 0\r\n2016-06-17 13:40:42,739 - INFO #   bt\r\n```\r\n\r\nTo reproduce the error, try the example in [[2]] (it's still in development phase, sorry for the mess):\r\n\r\n1. Run `make BOARD=samr21-xpro all`. It will through an error due to unfinished Makefile\r\n2. Go to bin/pkg/samr21-xpro/openthread\r\n3. Run ./bootstrap\r\n4. run ./configure --enable-cli --host=arm-none-eabi\r\n5. Run `make BOARD=samr21-xpro clean all flash term`\r\n\r\n\r\nI have been searching on internet and it seems I'm not the only one who has problem with libc_init_array and C++. Might be something like [[3]]?\r\n\r\nThe example is running on RIOT's native, so I think is not a problem of the port itself. Also, here in [[4]] is the .map file.\r\n\r\n\r\n[1]: https://github.com/RIOT-OS/RIOT/blob/b5497c3be43bdfecb0fb10e84bffbbd76d7a1ca1/cpu/cortexm_common/vectors_cortexm.c#L113\r\n[2]: https://github.com/jia200x/RIOT/tree/openthread/examples/openthread_example\r\n[3]: https://sourceware.org/bugzilla/show_bug.cgi?id=15302\r\n[4]: https://gist.github.com/jia200x/55f87ac2d966bafb604fb17ff577a7d8"},"comment":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/comments/227783428","html_url":"https://github.com/RIOT-OS/RIOT/issues/5563#issuecomment-227783428","issue_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/5563","id":227783428,"user":{"login":"josephnoir","id":2156518,"avatar_url":"https://avatars.githubusercontent.com/u/2156518?v=3","gravatar_id":"","url":"https://api.github.com/users/josephnoir","html_url":"https://github.com/josephnoir","followers_url":"https://api.github.com/users/josephnoir/followers","following_url":"https://api.github.com/users/josephnoir/following{/other_user}","gists_url":"https://api.github.com/users/josephnoir/gists{/gist_id}","starred_url":"https://api.github.com/users/josephnoir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josephnoir/subscriptions","organizations_url":"https://api.github.com/users/josephnoir/orgs","repos_url":"https://api.github.com/users/josephnoir/repos","events_url":"https://api.github.com/users/josephnoir/events{/privacy}","received_events_url":"https://api.github.com/users/josephnoir/received_events","type":"User","site_admin":false},"created_at":"2016-06-22T15:35:54Z","updated_at":"2016-06-22T15:35:54Z","body":"Yep. If I am not mistaken it allows static initialization for classes in C++. When first trying to get static initialization on the stm32f4discovery, we called the [init_array](http://newlib.sourcearchive.com/documentation/1.18.0/init_8c-source.html) functions by hand in a startup file.\r\n\r\nWhen I append the implementation of `__libc_init_array` to the `syscalls.c` file I can step into it and it crashes in the second loop. The function should morally be provided by the newlib, right?"}}
{"actor":{"display_login":"josephnoir"}}