<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>__weak void _exit(int status) not overridden despite trying</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/97535/__weak-void-_exit-int-status-not-overridden-despite-trying</link><description>I&amp;#39;m using Windows 11, WSL2, NCS 2. 
 I had a program crash due to using an uninitialized function&amp;lt;&amp;gt; object, and end up at _exit in libc-hooks.c 
 
 
 Unfortunately this locks up the main thread and doesn&amp;#39;t reset the whole system, which is a problem. </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 10 Mar 2023 14:18:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/97535/__weak-void-_exit-int-status-not-overridden-despite-trying" /><item><title>RE: __weak void _exit(int status) not overridden despite trying</title><link>https://devzone.nordicsemi.com/thread/414681?ContentTypeID=1</link><pubDate>Fri, 10 Mar 2023 14:18:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b47d262c-e084-4680-aeb4-37836d6df3e4</guid><dc:creator>douglas.malnati</dc:creator><description>&lt;p&gt;It is C++ as you noticed.&lt;/p&gt;
&lt;p&gt;I googled how to handle this and found an SO article&lt;/p&gt;
&lt;p&gt;&lt;a id="" href="https://stackoverflow.com/questions/1041866/what-is-the-effect-of-extern-c-in-c"&gt;https://stackoverflow.com/questions/1041866/what-is-the-effect-of-extern-c-in-c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I changed my implementation to this&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;.h file
...
extern &amp;quot;C&amp;quot; {
extern void _exit(int);
}
...

.cpp file
...
extern &amp;quot;C&amp;quot; {
void _exit(int status)
{
    // do stuff
}
}
...&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But now I&amp;#39;m getting a system crash saying BUS FAULT.&amp;nbsp; Any thoughts on what might be going wrong here?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;[00:00:10.730,529] &amp;lt;err&amp;gt; os: bus_fault: ***** BUS FAULT *****
[00:00:10.807,891] &amp;lt;err&amp;gt; os: bus_fault:   Precise data bus error
[00:00:10.888,427] &amp;lt;err&amp;gt; os: bus_fault:   BFAR Address: 0xfffffff5
[00:00:10.971,069] &amp;lt;err&amp;gt; os: esf_dump: r0/a1:  0x00000001  r1/a2:  0xfffffff5  r2/a3:  0x00000000
[00:00:11.086,090] &amp;lt;err&amp;gt; os: esf_dump: r3/a4:  0xfffffff5 r12/ip:  0x20007325 r14/lr:  0x000214a5
[00:00:11.201,110] &amp;lt;err&amp;gt; os: esf_dump:  xpsr:  0x21000000
[00:00:11.274,353] &amp;lt;err&amp;gt; os: esf_dump: Faulting instruction address (r15/pc): 0x000214b2
[00:00:11.379,913] &amp;lt;err&amp;gt; os: z_fatal_error: &amp;gt;&amp;gt;&amp;gt; ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
[00:00:11.489,624] &amp;lt;err&amp;gt; os: z_fatal_error: Current thread: 0x200026c0 (shell_uart)
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: __weak void _exit(int status) not overridden despite trying</title><link>https://devzone.nordicsemi.com/thread/414515?ContentTypeID=1</link><pubDate>Fri, 10 Mar 2023 03:05:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97cc095a-dde1-493b-a262-4fe6572d7bd7</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;C vs. C++? The override would only work in a .c file and not if the compiler thinks its C++ (via .C or .cpp file extension).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>