RTEMS | C++ std::mutex has no error checks (#5641)

Chris Johns (@chris) gitlab at rtems.org
Mon Jul 13 00:29:07 UTC 2026




Chris Johns commented on a discussion: https://gitlab.rtems.org/rtems/rtos/rtems/-/work_items/5641#note_154332


> Because `unlock()` is `noexcept`, libstdc++ cannot throw a `std::system_error` even if `__gthread_mutex_unlock` returned an error code (such as `EPERM`). If an exception were thrown, the runtime would immediately trigger `std::terminate()`.

I read https://en.cppreference.com/cpp/thread/mutex/lock differently:

> ### Exceptions
>
> Throws std::system_error when errors occur, including errors from the underlying operating system that would prevent `lock` from meeting its specifications. The mutex is not locked in the case of any exception being thrown.

Plus reading the code in C++ showed paths that could throw and path that did not. I was not sure if the different was based on options to the compiler.

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/work_items/5641#note_154332
You're receiving this email because of your account on gitlab.rtems.org. Unsubscribe from this thread: https://gitlab.rtems.org/-/sent_notifications/4-73ofh18tgzgjs923xul2zhi16-1d/unsubscribe | Manage all notifications: https://gitlab.rtems.org/-/profile/notifications | Help: https://gitlab.rtems.org/help


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20260713/8c989f8d/attachment.htm>


More information about the bugs mailing list