<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to bugs</title><link>https://sourceforge.net/p/chibios/bugs/</link><description>Recent changes to bugs</description><atom:link href="https://sourceforge.net/p/chibios/bugs/feed.rss" rel="self"/><language>en</language><lastBuildDate>Tue, 14 Apr 2026 18:43:33 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/chibios/bugs/feed.rss" rel="self" type="application/rss+xml"/><item><title>#1305 SIMIA32: port_lock/port_unlock boolean flag breaks lock nesting, corrupts scheduler</title><link>https://sourceforge.net/p/chibios/bugs/1305/?limit=25#778c</link><description>&lt;div class="markdown_content"&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;status&lt;/strong&gt;: open --&amp;gt; closed-invalid&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;assigned_to&lt;/strong&gt;: Giovanni Di Sirio&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Giovanni Di Sirio</dc:creator><pubDate>Tue, 14 Apr 2026 18:43:33 -0000</pubDate><guid>https://sourceforge.net76caf05ea1a49c9a660e67b9e6d3eb8182ae46cb</guid></item><item><title>#1305 SIMIA32: port_lock/port_unlock boolean flag breaks lock nesting, corrupts scheduler</title><link>https://sourceforge.net/p/chibios/bugs/1305/?limit=25#efcd</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;• Thanks for the report and for the clear write-up.&lt;/p&gt;
&lt;p&gt;I don’t think this is a SIMIA32 port bug. The important detail is that virtual&lt;br/&gt;
  timer callbacks are still invoked in interrupt context, even though&lt;br/&gt;
  chVTDoTickI() temporarily releases the kernel lock before calling the callback&lt;br/&gt;
  and reacquires it afterward. That unlock/relock is only about reducing lock&lt;br/&gt;
  hold time and jitter; it does not turn the callback into thread context.&lt;/p&gt;
&lt;p&gt;Because of that, calling chSysLock() / chSysUnlock() from a virtual timer&lt;br/&gt;
  callback is not valid. In that context the allowed forms are the I-class/X-&lt;br/&gt;
  class APIs, not the S-class ones. With CH_DBG_SYSTEM_STATE_CHECK enabled,&lt;br/&gt;
  tripping a state violation there is expected and is actually the debug checker&lt;br/&gt;
  doing its job.&lt;/p&gt;
&lt;p&gt;So the proposed change from a boolean port_irq_sts to a nesting counter would&lt;br/&gt;
  be masking an API misuse rather than fixing the underlying issue. In this&lt;br/&gt;
  port, that variable represents the current interrupt-enable state, not a&lt;br/&gt;
  recursive lock depth.&lt;/p&gt;
&lt;p&gt;The practical fix on the application side is to make sure code reached from a&lt;br/&gt;
  virtual timer callback does not use S-class locking. If your logging path&lt;br/&gt;
  currently wraps itself in something like CriticalSectionLocker based on&lt;br/&gt;
  chSysLock() / chSysUnlock(), that wrapper is not suitable from a VT callback.&lt;br/&gt;
  It should either use the ISR-safe variant for that path, or avoid calling that&lt;br/&gt;
  code from timer callback context.&lt;/p&gt;
&lt;p&gt;If useful, I can help review the specific callback/logging path and suggest&lt;br/&gt;
  the right API substitutions.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Giovanni Di Sirio</dc:creator><pubDate>Tue, 14 Apr 2026 18:42:53 -0000</pubDate><guid>https://sourceforge.net764b496bca21dea06409c7a1cedf9a4718e03759</guid></item><item><title>SIMIA32: port_lock/port_unlock boolean flag breaks lock nesting, corrupts scheduler</title><link>https://sourceforge.net/p/chibios/bugs/1305/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;hey!, first bug report over here so i hope this is the correct place:&lt;/p&gt;
&lt;p&gt;SIMIA32 port implements &lt;code&gt;port_lock()&lt;/code&gt; / &lt;code&gt;port_unlock()&lt;/code&gt; as boolean:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;static&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kr"&gt;inline&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;port_lock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;port_irq_sts&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;syssts_t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;static&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kr"&gt;inline&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;port_unlock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;port_irq_sts&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;syssts_t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This breaks when S-class and I-class locks are nested. ChibiOS virtual timer callbacks run with the lock released (&lt;code&gt;chVTDoTickI&lt;/code&gt; calls &lt;code&gt;chSysUnlockFromISR()&lt;/code&gt; before the callback and &lt;code&gt;chSysLockFromISR()&lt;/code&gt; after). If the callback code uses &lt;code&gt;chSysLock()&lt;/code&gt; / &lt;code&gt;chSysUnlock()&lt;/code&gt; (S-class), the &lt;code&gt;chSysUnlock()&lt;/code&gt; resets &lt;code&gt;port_irq_sts&lt;/code&gt; to 0. When &lt;code&gt;chVTDoTickI&lt;/code&gt; then calls &lt;code&gt;chSysLockFromISR()&lt;/code&gt;, the state appears correct (0 -&amp;gt; 1), but the intermediate unlock corrupted the scheduler's view of the lock state.&lt;/p&gt;
&lt;p&gt;Enabling &lt;code&gt;CH_DBG_SYSTEM_STATE_CHECK&lt;/code&gt; catches the issue early as SV#6 (misplaced &lt;code&gt;chSysLockFromISR&lt;/code&gt;)(at least on windows on our testing)&lt;/p&gt;
&lt;h4 id="h-reproduction"&gt;Reproduction&lt;/h4&gt;
&lt;p&gt;Any code that calls &lt;code&gt;chSysLock()&lt;/code&gt; / &lt;code&gt;chSysUnlock()&lt;/code&gt; from a virtual timer callback triggers this. In our case, a logging function uses &lt;code&gt;CriticalSectionLocker&lt;/code&gt; (S-class) and is called from a timer callback via &lt;code&gt;chVTDoTickI&lt;/code&gt;. (here: &lt;a href="https://github.com/rusefi/rusefi/pull/9357" rel="nofollow"&gt;https://github.com/rusefi/rusefi/pull/9357&lt;/a&gt;)&lt;/p&gt;
&lt;h4 id="h-proposed-fix"&gt;Proposed fix&lt;/h4&gt;
&lt;p&gt;Use a nesting counter instead of a boolean:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;static&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kr"&gt;inline&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;port_lock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;port_irq_sts&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;static&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kr"&gt;inline&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;port_unlock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;port_irq_sts&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;static&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kr"&gt;inline&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;port_lock_from_isr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;port_irq_sts&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;static&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kr"&gt;inline&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;port_unlock_from_isr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;port_irq_sts&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;we have this on our mirror of ChibiOs: &lt;a href="https://github.com/rusefi/ChibiOS/pull/66" rel="nofollow"&gt;https://github.com/rusefi/ChibiOS/pull/66&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Diego Frenoux</dc:creator><pubDate>Mon, 13 Apr 2026 18:58:32 -0000</pubDate><guid>https://sourceforge.nete3e2f61ebf75b3b9d59e4cb909d1514b967d22e3</guid></item><item><title>SIMIA32: port_lock/port_unlock boolean flag breaks lock nesting, corrupts scheduler</title><link>https://sourceforge.net/p/chibios/bugs/1305/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Ticket 1305 has been modified: SIMIA32: port_lock/port_unlock boolean flag breaks lock nesting, corrupts scheduler&lt;br/&gt;
Edited By: Giovanni Di Sirio (gdisirio)&lt;br/&gt;
Status updated: 'open' =&amp;gt; 'closed-invalid'&lt;br/&gt;
Owner updated: None =&amp;gt; 'gdisirio'&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Diego Frenoux</dc:creator><pubDate>Mon, 13 Apr 2026 18:58:32 -0000</pubDate><guid>https://sourceforge.netbeda4dc39f5c815207ca33d2abfb55a41114b2b6</guid></item><item><title>OSLIB Jobs Queues: return JOB_NULL descriptors to the free pool</title><link>https://sourceforge.net/p/chibios/bugs/1304/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;The OSLIB jobs dispatcher was leaking job descriptors on the JOB_NULL control&lt;br/&gt;
  path.&lt;/p&gt;
&lt;p&gt;In both chJobDispatch() and chJobDispatchTimeout(), a fetched descriptor was&lt;br/&gt;
  returned to the guarded pool only when jobfunc != NULL. When a null job was&lt;br/&gt;
  used as the documented worker shutdown signal, the dispatcher returned&lt;br/&gt;
  MSG_JOB_NULL but did not release the descriptor back to the free pool.&lt;/p&gt;
&lt;p&gt;Impact:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;each null shutdown job permanently consumed one descriptor&lt;/li&gt;
&lt;li&gt;repeated worker shutdown cycles could exhaust the queue&lt;/li&gt;
&lt;li&gt;disposal-time checks did not detect the loss because the queue could still&lt;br/&gt;
    appear idle&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The fix:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;always return the fetched descriptor to the guarded pool, including the&lt;br/&gt;
    MSG_JOB_NULL path&lt;/li&gt;
&lt;li&gt;add a regression test that posts null shutdown jobs, waits for the workers&lt;br/&gt;
    to exit, then verifies:&lt;ul&gt;
&lt;li&gt;the guarded pool counter is back to JOBS_QUEUE_SIZE&lt;/li&gt;
&lt;li&gt;the mailbox has no pending jobs&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Giovanni Di Sirio</dc:creator><pubDate>Wed, 18 Mar 2026 18:27:20 -0000</pubDate><guid>https://sourceforge.net35fe552c7dd3cfe186254a73a55494c6363aa602</guid></item><item><title>serialize ref duplication and harden dynamic object size calculations</title><link>https://sourceforge.net/p/chibios/bugs/1303/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;The OSLIB factory needed two safety fixes.&lt;/p&gt;
&lt;p&gt;First, chFactoryDuplicateReference() was incrementing object reference&lt;br/&gt;
  counters without using the factory lock, while create/find/release paths were&lt;br/&gt;
  serialized. This created a race against final release and object reclamation.&lt;/p&gt;
&lt;p&gt;Second, the heap-backed factory creators (Buffer, Mailbox, ObjectsFIFO, Pipe)&lt;br/&gt;
  were performing unchecked add/multiply/alignment arithmetic when computing&lt;br/&gt;
  allocation sizes. Extreme input values could overflow those calculations&lt;br/&gt;
  before allocation, leading to undersized objects and out-of-bounds&lt;br/&gt;
  initialization.&lt;/p&gt;
&lt;p&gt;The fix:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;makes chFactoryDuplicateReference() a locked API&lt;/li&gt;
&lt;li&gt;adds checked size helpers for add/multiply/alignment operations&lt;/li&gt;
&lt;li&gt;rejects overflowing size requests before allocation&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Giovanni Di Sirio</dc:creator><pubDate>Wed, 18 Mar 2026 14:57:35 -0000</pubDate><guid>https://sourceforge.net9916a06407df3fa549135317caec0fe0b7baffd8</guid></item><item><title>harden memcore/heap boundary checks against arithmetic overflow</title><link>https://sourceforge.net/p/chibios/bugs/1302/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;The OSLIB allocators need stronger bounds handling on arithmetic edge cases.&lt;/p&gt;
&lt;p&gt;Two issues were addressed:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;chCoreAllocFromBaseI() and chCoreAllocFromTopI() in chmemcore.c were&lt;br/&gt;
     performing derived-address arithmetic before validating the request. With&lt;br/&gt;
     extreme size or offset values, this could rely on out-of-range pointer&lt;br/&gt;
     arithmetic before the guard code rejected the allocation.&lt;/li&gt;
&lt;li&gt;chHeapAllocAligned() in chmemheaps.c rounded size with MEM_ALIGN_NEXT()&lt;br/&gt;
     before checking for overflow. Near-SIZE_MAX requests could wrap during&lt;br/&gt;
     rounding, derive an invalid pages count, and corrupt heap metadata during&lt;br/&gt;
     block splitting.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The fix moves memcore calculations into integer space (uintptr_t) until bounds&lt;br/&gt;
  are verified, and adds an explicit overflow check before converting heap&lt;br/&gt;
  request size into allocation pages.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Giovanni Di Sirio</dc:creator><pubDate>Wed, 18 Mar 2026 14:43:22 -0000</pubDate><guid>https://sourceforge.netb8ffc31475b2bbf7e847ebe8b6cb40095baf81d6</guid></item><item><title>Fix priority inheritance through prioritized message queues</title><link>https://sourceforge.net/p/chibios/bugs/1301/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;When CH_CFG_USE_MESSAGES_PRIORITY is enabled, the PI walk in chMtxLockS() boosts the priority of a thread blocked in CH_STATE_SNDMSGQ but does not re-enqueue it in the receiver's msgqueue, preserving the priority inversion.&lt;/p&gt;
&lt;p&gt;Root cause: u.sentmsg and u.wtobjp alias in the u union, so there is nowhere to store the back-pointer to the receiver's queue while the sender is waiting.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Giovanni Di Sirio</dc:creator><pubDate>Wed, 18 Mar 2026 13:10:28 -0000</pubDate><guid>https://sourceforge.net36346c95e291118602d8b6a6b16353a16c623c5f</guid></item><item><title>chMsgSend missing rdymsg assignment causes spurious NULL return from chMsgWaitTimeoutS</title><link>https://sourceforge.net/p/chibios/bugs/1300/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;chMsgSend wakes a receiver thread blocked in CH_STATE_WTMSG via chSchReadyI without first setting tp-&amp;gt;u.rdymsg = MSG_OK. This leaves a stale value in rdymsg from a previous operation.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Giovanni Di Sirio</dc:creator><pubDate>Wed, 18 Mar 2026 11:45:35 -0000</pubDate><guid>https://sourceforge.net3c82ae5c1206e0e61d8a5d9b38138d64c2734e24</guid></item><item><title>#1297 CMSIS osMessage const buffer</title><link>https://sourceforge.net/p/chibios/bugs/1297/?limit=25#3fa5</link><description>&lt;div class="markdown_content"&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Fixed in Repository&lt;/strong&gt;: False --&amp;gt; True&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Giovanni Di Sirio</dc:creator><pubDate>Wed, 18 Mar 2026 11:10:39 -0000</pubDate><guid>https://sourceforge.net6245578e337ed1695247ec5744e344c92cbcd8b9</guid></item></channel></rss>