<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en" style="--code-editor-font: var(--default-mono-font, "GitLab Mono"), JetBrains Mono, Menlo, DejaVu Sans Mono, Liberation Mono, Consolas, Ubuntu Mono, Courier New, andale mono, lucida console, monospace;">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>
GitLab
</title>
<style data-premailer="ignore" type="text/css">
a { color: #1068bf; }
</style>
<style>img {
max-width: 100%; height: auto;
}
body {
font-size: .875rem;
}
body {
-webkit-text-shadow: rgba(255,255,255,.01) 0 0 1px;
}
body {
font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"; font-size: inherit;
}
</style>
</head>
<body style="font-size: inherit; -webkit-text-shadow: rgba(255,255,255,.01) 0 0 1px; font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";">
<div class="content">
<p class="details" style="font-style: italic; color: #626168;">
<a href="https://gitlab.rtems.org/mlueck">Martin Lück</a> created an issue: <a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5535">#5535</a>
</p>
<div class="md" style="position: relative; z-index: 1; color: #3a383f; word-wrap: break-word;">
<h2 id="user-content-summary" dir="auto" style="margin-top: 0; margin-bottom: 10px;" align="initial">Summary<a href="#summary" aria-label="Link to heading 'Summary'" data-heading-content="Summary" class="anchor" style="margin-top: 0;"></a>
</h2>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">Configuration: RTEMS 6.0.0, PowerPC e500v2 CPU with qoriq BSP. However, the issue seems to be also present in the current main.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">There seems to be an issue in the function BSP_printStackTrace(). In a loop the function follows the stack pointers until it hits <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">f->frameLink == 0</code>:</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial"><a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/blob/main/bsps/powerpc/shared/exceptions/ppc_exc_print.c#L87" style="margin-top: 0;">https://gitlab.rtems.org/rtems/rtos/rtems/-/blob/main/bsps/powerpc/shared/exceptions/ppc_exc_print.c#L87</a></p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">However, when stack protection is enabled with <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">#define CONFIGURE_STACK_CHECKER_ENABLED</code>, the pointer does not hit 0, but instead the last frameLink becomes 0xa5a5a5a5. This is the stack protection pattern which is set up here:</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial"><a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/blob/main/cpukit/libmisc/stackchk/check.c#L80" style="margin-top: 0;">https://gitlab.rtems.org/rtems/rtos/rtems/-/blob/main/cpukit/libmisc/stackchk/check.c#L80</a></p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">In GDB, the issue manifests as the error message "Cannot access memory at address 0xa5a5a5a9":</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-plaintext" v-pre="true" style="display: block; font-size: 14px; color: #3a383f; line-height: 1.6em; overflow-x: auto; border-radius: .25rem; position: relative; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0 0 1rem; padding: 12px; border: 1px solid #dcdcde;"><code style="font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: .25rem; white-space: pre; margin-top: 0; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; overflow-wrap: normal; padding: unset;"><span id="LC1" class="line" lang="plaintext" style="margin-top: 0;">(gdb) x/100a _ISR_Stack_area_end-256</span>
<span id="LC2" class="line" lang="plaintext">0x813f40 <_ISR_Stack_area_begin+7936>: 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5</span>
<span id="LC3" class="line" lang="plaintext">0x813f50 <_ISR_Stack_area_begin+7952>: 0xa5a5a5a5 0xa5a5a5a5 0x813f80 <_ISR_Stack_area_begin+8000> 0xa5a5a5a5</span>
<span id="LC4" class="line" lang="plaintext">0x813f60 <_ISR_Stack_area_begin+7968>: 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5</span>
<span id="LC5" class="line" lang="plaintext">0x813f70 <_ISR_Stack_area_begin+7984>: 0x12010001 0x0 0x813fe0 <_ISR_Stack_area_begin+8096> 0x816830 <_Timer_Objects+16></span>
<span id="LC6" class="line" lang="plaintext">0x813f80 <_ISR_Stack_area_begin+8000>: 0x813fa8 <_ISR_Stack_area_begin+8040> 0x30cf24 <_Watchdog_Do_tickle+132> 0xffffdf73 0x0</span>
<span id="LC7" class="line" lang="plaintext">0x813f90 <_ISR_Stack_area_begin+8016>: 0x0 0x0 0x811554 <bsp_interrupt_dispatch_table> 0x2021200</span>
<span id="LC8" class="line" lang="plaintext">0x813fa0 <_ISR_Stack_area_begin+8032>: 0x810668 <_Per_CPU_Information+200> 0x8105a0 <_Per_CPU_Information> 0x813fe0 <_ISR_Stack_area_begin+8096> 0x30d020 <_Watchdog_Tick+120></span>
<span id="LC9" class="line" lang="plaintext">0x813fb0 <_ISR_Stack_area_begin+8048>: 0x0 0x0 0x0 0x0</span>
<span id="LC10" class="line" lang="plaintext">0x813fc0 <_ISR_Stack_area_begin+8064>: 0x2029200 0x811554 <bsp_interrupt_dispatch_table> 0x0 0x2021200</span>
<span id="LC11" class="line" lang="plaintext">0x813fd0 <_ISR_Stack_area_begin+8080>: 0x0 0x2021200 0xffe40000 0x8105a0 <_Per_CPU_Information></span>
<span id="LC12" class="line" lang="plaintext">0x813fe0 <_ISR_Stack_area_begin+8096>: 0x814000 <_ISR_Stack_area_begin+8128> 0x307140 <_Timecounter_Tick+96> 0x2029200 0xa5a5a5a5</span>
<span id="LC13" class="line" lang="plaintext">0x813ff0 <_ISR_Stack_area_begin+8112>: 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0x811b24 <qoriq_clock_entry></span>
<span id="LC14" class="line" lang="plaintext">0x814000 <_ISR_Stack_area_begin+8128>: 0x814020 <_ISR_Stack_area_begin+8160> 0x303458 <bsp_interrupt_dispatch+136> 0xa5a5a5a5 0x816040 <_RTEMS_tasks_Objects></span>
<span id="LC15" class="line" lang="plaintext">0x814010 <_ISR_Stack_area_begin+8144>: 0x8105a0 <_Per_CPU_Information> 0x8003ac <_User_extensions_Switches_list+4> 0x8003ac <_User_extensions_Switches_list+4> 0x816430 <_Thread_Objects></span>
<span id="LC16" class="line" lang="plaintext">0x814020 <_ISR_Stack_area_begin+8160>: 0xa5a5a5a5 0x3039e8 <ppc_exc_interrupt+184> 0xa5a5a5a5 0xa5a5a5a5</span>
<span id="LC17" class="line" lang="plaintext">0x814030 <_ISR_Stack_area_begin+8176>: 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5</span>
<span id="LC18" class="line" lang="plaintext">0x814040: 0x0 0x0 0x0 0x0</span>
<span id="LC19" class="line" lang="plaintext">0x814050: 0x0 0x0 0x0 0x0</span>
<span id="LC20" class="line" lang="plaintext">0x814060: 0x0 0x0 0x0 0x0</span>
<span id="LC21" class="line" lang="plaintext">0x814070: 0x0 0x0 0x0 0x0</span>
<span id="LC22" class="line" lang="plaintext">0x814080: 0x0 0x0 0x0 0x0</span>
<span id="LC23" class="line" lang="plaintext">0x814090: 0x0 0x0 0x0 0x0</span>
<span id="LC24" class="line" lang="plaintext">0x8140a0: 0x0 0x0 0x0 0x0</span>
<span id="LC25" class="line" lang="plaintext">0x8140b0: 0x0 0x0 0x0 0x0</span>
<span id="LC26" class="line" lang="plaintext">0x8140c0: 0x0 0x0 0x0 0x0</span>
<span id="LC27" class="line" lang="plaintext">(gdb) i s</span>
<span id="LC28" class="line" lang="plaintext">#0 0x003009f8 in timer_isr ()</span>
<span id="LC29" class="line" lang="plaintext">#1 0x0030cf24 in _Watchdog_Do_tickle (header=header@entry=0x810678 <_Per_CPU_Information+216>, first=0x816830 <_Timer_Objects+16>, now=<optimized out>, lock=lock@entry=0x810668 <_Per_CPU_Information+200>, </span>
<span id="LC30" class="line" lang="plaintext"> lock_context=lock_context@entry=0x813fc0 <_ISR_Stack_area_begin+8064>) at ../../../../src/rtems/cpukit/score/src/watchdogtick.c:66</span>
<span id="LC31" class="line" lang="plaintext">#2 0x0030d020 in _Watchdog_Tick (cpu=cpu@entry=0x8105a0 <_Per_CPU_Information>) at ../../../../src/rtems/cpukit/score/src/watchdogtick.c:105</span>
<span id="LC32" class="line" lang="plaintext">#3 0x00307140 in _Timecounter_Tick () at ../../../../src/rtems/cpukit/score/src/kern_tc.c:2355</span>
<span id="LC33" class="line" lang="plaintext">#4 0x00303458 in bsp_interrupt_dispatch_entries (entry=0x811b24 <qoriq_clock_entry>) at ../../../../src/rtems/bsps/include/bsp/irq-generic.h:571</span>
<span id="LC34" class="line" lang="plaintext">#5 bsp_interrupt_handler_dispatch_unchecked (vector=<optimized out>) at ../../../../src/rtems/bsps/include/bsp/irq-generic.h:627</span>
<span id="LC35" class="line" lang="plaintext">#6 bsp_interrupt_dispatch (exception_number=<optimized out>) at ../../../../src/rtems/bsps/powerpc/qoriq/irq/irq.c:663</span>
<span id="LC36" class="line" lang="plaintext">#7 0x003039e8 in ppc_exc_interrupt ()</span>
<span id="LC37" class="line" lang="plaintext">Backtrace stopped: Cannot access memory at address 0xa5a5a5a9</span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">At runtime, this results in an access violation.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">Compare the same stacktrace without stack checking enabled:</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-plaintext" v-pre="true" style="display: block; font-size: 14px; color: #3a383f; line-height: 1.6em; overflow-x: auto; border-radius: .25rem; position: relative; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0 0 1rem; padding: 12px; border: 1px solid #dcdcde;"><code style="font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: .25rem; white-space: pre; margin-top: 0; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; overflow-wrap: normal; padding: unset;"><span id="LC1" class="line" lang="plaintext" style="margin-top: 0;">(gdb) x/100a _ISR_Stack_area_end-256</span>
<span id="LC2" class="line" lang="plaintext">0x813e20 <_ISR_Stack_area_begin+7936>: 0x2021200 0x20200484 0x813df8 <_ISR_Stack_area_begin+7896> 0x30c474</span>
<span id="LC3" class="line" lang="plaintext">0x813e30 <_ISR_Stack_area_begin+7952>: 0x0 0x2021200 0x813e60 <_ISR_Stack_area_begin+8000> 0x813f20</span>
<span id="LC4" class="line" lang="plaintext">0x813e40 <_ISR_Stack_area_begin+7968>: 0x0 0x30017c <bsp_section_start_begin+380> 0x0 0x20000000</span>
<span id="LC5" class="line" lang="plaintext">0x813e50 <_ISR_Stack_area_begin+7984>: 0x12010001 0x0 0x813ec0 <_ISR_Stack_area_begin+8096> 0x816710 <_Timer_Objects+16></span>
<span id="LC6" class="line" lang="plaintext">0x813e60 <_ISR_Stack_area_begin+8000>: 0x813e88 <_ISR_Stack_area_begin+8040> 0x30cf34 <_Watchdog_Do_tickle+132> 0xffffdf73 0x0</span>
<span id="LC7" class="line" lang="plaintext">0x813e70 <_ISR_Stack_area_begin+8016>: 0x0 0x0 0x811534 <bsp_interrupt_dispatch_table> 0x2021200</span>
<span id="LC8" class="line" lang="plaintext">0x813e80 <_ISR_Stack_area_begin+8032>: 0x810648 <_Per_CPU_Information+200> 0x810580 <_Per_CPU_Information> 0x813ec0 <_ISR_Stack_area_begin+8096> 0x30d030 <_Watchdog_Tick+120></span>
<span id="LC9" class="line" lang="plaintext">0x813e90 <_ISR_Stack_area_begin+8048>: 0x0 0x0 0x0 0x0</span>
<span id="LC10" class="line" lang="plaintext">0x813ea0 <_ISR_Stack_area_begin+8064>: 0x2029200 0x811534 <bsp_interrupt_dispatch_table> 0x0 0x2021200</span>
<span id="LC11" class="line" lang="plaintext">0x813eb0 <_ISR_Stack_area_begin+8080>: 0x0 0x2021200 0xffe40000 0x810580 <_Per_CPU_Information></span>
<span id="LC12" class="line" lang="plaintext">0x813ec0 <_ISR_Stack_area_begin+8096>: 0x813ee0 <_ISR_Stack_area_begin+8128> 0x307150 <_Timecounter_Tick+96> 0x2029200 0x0</span>
<span id="LC13" class="line" lang="plaintext">0x813ed0 <_ISR_Stack_area_begin+8112>: 0x0 0x0 0x4427e4 <_Copyright_Notice> 0x811b04 <qoriq_clock_entry></span>
<span id="LC14" class="line" lang="plaintext">0x813ee0 <_ISR_Stack_area_begin+8128>: 0x813f00 <_ISR_Stack_area_begin+8160> 0x303468 <bsp_interrupt_dispatch+136> 0x813ef8 <_ISR_Stack_area_begin+8152> 0x0</span>
<span id="LC15" class="line" lang="plaintext">0x813ef0 <_ISR_Stack_area_begin+8144>: 0x0 0x800000 <_Thread_Information> 0x8003ac <_User_extensions_Switches_list+4> 0x816310 <_Thread_Objects></span>
<span id="LC16" class="line" lang="plaintext">0x813f00 <_ISR_Stack_area_begin+8160>: 0x0 0x3039f8 <ppc_exc_interrupt+184> 0x0 0x0</span>
<span id="LC17" class="line" lang="plaintext">0x813f10 <_ISR_Stack_area_begin+8176>: 0x0 0x0 0x0 0x0</span>
<span id="LC18" class="line" lang="plaintext">0x813f20: 0x0 0x0 0x0 0x0</span>
<span id="LC19" class="line" lang="plaintext">0x813f30: 0x0 0x0 0x0 0x0</span>
<span id="LC20" class="line" lang="plaintext">0x813f40: 0x0 0x0 0x0 0x0</span>
<span id="LC21" class="line" lang="plaintext">0x813f50: 0x0 0x0 0x0 0x0</span>
<span id="LC22" class="line" lang="plaintext">0x813f60: 0x0 0x0 0x0 0x0</span>
<span id="LC23" class="line" lang="plaintext">0x813f70: 0x0 0x0 0x0 0x0</span>
<span id="LC24" class="line" lang="plaintext">0x813f80: 0x0 0x0 0x0 0x0</span>
<span id="LC25" class="line" lang="plaintext">0x813f90: 0x0 0x0 0x0 0x0</span>
<span id="LC26" class="line" lang="plaintext">0x813fa0: 0x0 0x0 0x0 0x0</span>
<span id="LC27" class="line" lang="plaintext">(gdb) i s</span>
<span id="LC28" class="line" lang="plaintext">#0 0x00300a10 in timer_isr ()</span>
<span id="LC29" class="line" lang="plaintext">#1 0x0030cf34 in _Watchdog_Do_tickle (header=header@entry=0x810658 <_Per_CPU_Information+216>, first=0x816710 <_Timer_Objects+16>, now=<optimized out>, lock=lock@entry=0x810648 <_Per_CPU_Information+200>, </span>
<span id="LC30" class="line" lang="plaintext"> lock_context=lock_context@entry=0x813ea0 <_ISR_Stack_area_begin+8064>) at ../../../../src/rtems/cpukit/score/src/watchdogtick.c:66</span>
<span id="LC31" class="line" lang="plaintext">#2 0x0030d030 in _Watchdog_Tick (cpu=cpu@entry=0x810580 <_Per_CPU_Information>) at ../../../../src/rtems/cpukit/score/src/watchdogtick.c:105</span>
<span id="LC32" class="line" lang="plaintext">#3 0x00307150 in _Timecounter_Tick () at ../../../../src/rtems/cpukit/score/src/kern_tc.c:2355</span>
<span id="LC33" class="line" lang="plaintext">#4 0x00303468 in bsp_interrupt_dispatch_entries (entry=0x811b04 <qoriq_clock_entry>) at ../../../../src/rtems/bsps/include/bsp/irq-generic.h:571</span>
<span id="LC34" class="line" lang="plaintext">#5 bsp_interrupt_handler_dispatch_unchecked (vector=<optimized out>) at ../../../../src/rtems/bsps/include/bsp/irq-generic.h:627</span>
<span id="LC35" class="line" lang="plaintext">#6 bsp_interrupt_dispatch (exception_number=<optimized out>) at ../../../../src/rtems/bsps/powerpc/qoriq/irq/irq.c:663</span>
<span id="LC36" class="line" lang="plaintext">#7 0x003039f8 in ppc_exc_interrupt ()</span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<h2 id="user-content-steps-to-reproduce" dir="auto" style="margin-top: 20px; margin-bottom: 10px;" align="initial">Steps to reproduce<a href="#steps-to-reproduce" aria-label="Link to heading 'Steps to reproduce'" data-heading-content="Steps to reproduce" class="anchor" style="margin-top: 0;"></a>
</h2>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">The following program can reproduce the issue:</p>
<div class="gl-relative markdown-code-block js-markdown-code" style="margin-bottom: 0;">
<pre data-canonical-lang="c" class="code highlight js-syntax-highlight language-c" v-pre="true" style="display: block; font-size: 14px; color: #3a383f; line-height: 1.6em; overflow-x: auto; border-radius: .25rem; position: relative; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0 0 1rem; padding: 12px; border: 1px solid #dcdcde;"><code style="font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: .25rem; white-space: pre; margin-top: 0; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; overflow-wrap: normal; padding: unset;"><span id="LC1" class="line" lang="c" style="margin-top: 0;"><span class="c1" style="margin-top: 0;">// If removing this, the issue disappears</span></span>
<span id="LC2" class="line" lang="c"><span class="cp" style="margin-top: 0;">#define CONFIGURE_STACK_CHECKER_ENABLED</span></span>
<span id="LC3" class="line" lang="c"></span>
<span id="LC4" class="line" lang="c"></span>
<span id="LC5" class="line" lang="c"></span>
<span id="LC6" class="line" lang="c"><span class="cp" style="margin-top: 0;">#define CONFIGURE_INIT</span></span>
<span id="LC7" class="line" lang="c"><span class="cp" style="margin-top: 0;">#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER</span></span>
<span id="LC8" class="line" lang="c"><span class="cp" style="margin-top: 0;">#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER</span></span>
<span id="LC9" class="line" lang="c"><span class="cp" style="margin-top: 0;">#define CONFIGURE_MAXIMUM_TIMERS 3</span></span>
<span id="LC10" class="line" lang="c"><span class="cp" style="margin-top: 0;">#define CONFIGURE_MAXIMUM_TASKS 1</span></span>
<span id="LC11" class="line" lang="c"><span class="cp" style="margin-top: 0;">#define CONFIGURE_RTEMS_INIT_TASKS_TABLE</span></span>
<span id="LC12" class="line" lang="c"><span class="cp" style="margin-top: 0;">#define CONFIGURE_INIT_TASK_PRIORITY 1</span></span>
<span id="LC13" class="line" lang="c"><span class="cp" style="margin-top: 0;">#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_DEFAULT_MODES)</span></span>
<span id="LC14" class="line" lang="c"><span class="cp" style="margin-top: 0;">#define CONFIGURE_INIT_TASK_STACK_SIZE (RTEMS_MINIMUM_STACK_SIZE * 4)</span></span>
<span id="LC15" class="line" lang="c"></span>
<span id="LC16" class="line" lang="c"><span class="cp" style="margin-top: 0;">#include</span> <span class="cpf"><rtems.h></span></span>
<span id="LC17" class="line" lang="c"><span class="cp" style="margin-top: 0;">#include</span> <span class="cpf"><rtems/bspIo.h></span></span>
<span id="LC18" class="line" lang="c"><span class="cp" style="margin-top: 0;">#include</span> <span class="cpf"><rtems/confdefs.h></span></span>
<span id="LC19" class="line" lang="c"></span>
<span id="LC20" class="line" lang="c"><span class="k" style="margin-top: 0;">static</span> <span class="kt">void</span> <span class="nf">timer_isr</span><span class="p">(</span><span class="n">rtems_id</span> <span class="n">id</span><span class="p">,</span> <span class="kt">void</span><span class="o">*</span> <span class="n">arg</span><span class="p">)</span></span>
<span id="LC21" class="line" lang="c"><span class="p" style="margin-top: 0;">{</span></span>
<span id="LC22" class="line" lang="c"> <span class="p" style="margin-top: 0;">(</span><span class="kt">void</span><span class="p">)</span><span class="n">id</span><span class="p">;</span></span>
<span id="LC23" class="line" lang="c"> <span class="p" style="margin-top: 0;">(</span><span class="kt">void</span><span class="p">)</span><span class="n">arg</span><span class="p">;</span></span>
<span id="LC24" class="line" lang="c"> <span class="n" style="margin-top: 0;">printk</span><span class="p">(</span><span class="s">"Timer ISR fired</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span></span>
<span id="LC25" class="line" lang="c"></span>
<span id="LC26" class="line" lang="c"> <span class="kt" style="margin-top: 0;">void</span> <span class="p">(</span><span class="o">*</span><span class="n">function_ptr</span><span class="p">)()</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span></span>
<span id="LC27" class="line" lang="c"></span>
<span id="LC28" class="line" lang="c"> <span class="c1" style="margin-top: 0;">// Provoke an exception from inside an ISR</span></span>
<span id="LC29" class="line" lang="c"> <span class="n" style="margin-top: 0;">function_ptr</span><span class="p">();</span></span>
<span id="LC30" class="line" lang="c"><span class="p" style="margin-top: 0;">}</span></span>
<span id="LC31" class="line" lang="c"></span>
<span id="LC32" class="line" lang="c"><span class="n" style="margin-top: 0;">rtems_task</span> <span class="nf">Init</span><span class="p">(</span><span class="n">rtems_task_argument</span> <span class="n">arg</span><span class="p">)</span></span>
<span id="LC33" class="line" lang="c"><span class="p" style="margin-top: 0;">{</span></span>
<span id="LC34" class="line" lang="c"> <span class="n" style="margin-top: 0;">rtems_id</span> <span class="n">timerid</span><span class="p">;</span></span>
<span id="LC35" class="line" lang="c"></span>
<span id="LC36" class="line" lang="c"> <span class="n" style="margin-top: 0;">rtems_status_code</span> <span class="n">status</span><span class="p">;</span></span>
<span id="LC37" class="line" lang="c"></span>
<span id="LC38" class="line" lang="c"> <span class="n" style="margin-top: 0;">printk</span><span class="p">(</span><span class="s">"RTEMS version: %s</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">RTEMS_VERSION</span><span class="p">);</span></span>
<span id="LC39" class="line" lang="c"></span>
<span id="LC40" class="line" lang="c"> <span class="n" style="margin-top: 0;">status</span> <span class="o">=</span> <span class="n">rtems_timer_create</span><span class="p">(</span><span class="n">rtems_build_name</span><span class="p">(</span><span class="sc">'T'</span><span class="p">,</span> <span class="sc">'M'</span><span class="p">,</span> <span class="sc">'R'</span><span class="p">,</span> <span class="sc">'x'</span><span class="p">),</span> <span class="o">&</span><span class="n">timerid</span><span class="p">);</span></span>
<span id="LC41" class="line" lang="c"> <span class="n" style="margin-top: 0;">printk</span><span class="p">(</span><span class="s">"rtems_timer_create() = %s</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">rtems_status_text</span><span class="p">(</span><span class="n">status</span><span class="p">));</span></span>
<span id="LC42" class="line" lang="c"></span>
<span id="LC43" class="line" lang="c"> <span class="n" style="margin-top: 0;">status</span> <span class="o">=</span> <span class="n">rtems_timer_fire_after</span><span class="p">(</span><span class="n">timerid</span><span class="p">,</span> <span class="n">RTEMS_MILLISECONDS_TO_TICKS</span><span class="p">(</span><span class="mi">1000</span><span class="p">),</span> <span class="n">timer_isr</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">);</span></span>
<span id="LC44" class="line" lang="c"> <span class="n" style="margin-top: 0;">printk</span><span class="p">(</span><span class="s">"rtems_timer_fire_after() = %s</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">rtems_status_text</span><span class="p">(</span><span class="n">status</span><span class="p">));</span></span>
<span id="LC45" class="line" lang="c"></span>
<span id="LC46" class="line" lang="c"> <span class="k" style="margin-top: 0;">while</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span></span>
<span id="LC47" class="line" lang="c"> <span class="p" style="margin-top: 0;">{</span></span>
<span id="LC48" class="line" lang="c"> <span class="n" style="margin-top: 0;">rtems_task_wake_after</span><span class="p">(</span><span class="n">RTEMS_MILLISECONDS_TO_TICKS</span><span class="p">(</span><span class="mi">1000</span><span class="p">));</span></span>
<span id="LC49" class="line" lang="c"> <span class="p" style="margin-top: 0;">}</span></span>
<span id="LC50" class="line" lang="c"><span class="p" style="margin-top: 0;">}</span></span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
</div>
</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #626168;">
—
<br>
<a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5535">View it on GitLab</a>.
<br>
You're receiving this email because of your account on <a target="_blank" rel="noopener noreferrer" href="https://gitlab.rtems.org">gitlab.rtems.org</a>. <a href="https://gitlab.rtems.org/-/sent_notifications/2-3mlr2r2ylqqtwvsgstcp053eg/unsubscribe" target="_blank" rel="noopener noreferrer">Unsubscribe</a> from this thread · <a href="https://gitlab.rtems.org/-/profile/notifications" target="_blank" rel="noopener noreferrer" class="mng-notif-link">Manage all notifications</a> · <a href="https://gitlab.rtems.org/help" target="_blank" rel="noopener noreferrer" class="help-link">Help</a>
<span style="color: transparent; font-size: 0; display: none; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0;">
Notification message regarding https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5535 at 1774516819
</span>
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Issue","url":"https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5535"}}</script>
</p>
</div>
</body>
</html>