Commit Graph

11 Commits (05b5b4095d1a735a6ef7cf3e4bf89cf714d9db3d)

Author SHA1 Message Date
Lingkai Dong 48cf1c9c80 rtos: Thread: Make stack allocation failure runtime catchable
When a Thread object's stack memory is not provided, its `start()`
member function dynamically allocates its stack from the heap. If
allocation fails, there is no way to catch it because
* `std::nothrow` is missing after the `new` keyword. As Mbed OS
is built with `-fno-exceptions` (C++ exceptions disabled), failed
allocation results in an unrecoverable fault.
* The attempted `nullptr` check, which doesn't work anyway due to
the first point, is an assertion instead of error returning.
Assertions should be used as a development tool to ensure code
behaves correctly. But out-of-memory is a completely valid runtime
situation.

This commit adds the missing `std::nothrow`, and makes `Thread::start()`
return `osErrorNoMemory` if allocation fails so the caller can handle
it.

Note: A case when a thread should never fail due to lack of memory
is the main thread. But the main thread's stack is a pre-allocated
array in the static memory, passed to the `Thread()` constructor
during thread creation, so it's not impacted by this change.
2021-09-08 14:17:58 +01:00
pea-pod 507181d262 Change MBED_STATIC_ASSERTs version for built-in 2020-10-27 08:30:40 -05:00
Martin Kojtal 2e7fa8ba6b rtos: fix SPDX identifiers 2020-02-21 07:00:57 +00:00
Martin Kojtal aa4e7b17aa rtos: add SPDX identifiers 2020-02-21 07:00:56 +00:00
Martin Kojtal 5165559a2c
Merge pull request #12142 from kjbracey-arm/thread_rm510
Thread: remove methods deprecated in 5.10
2020-02-03 15:09:34 +00:00
Kevin Bracey 8b02c4ed1c Add missing <string.h> includes 2020-01-09 14:52:54 +02:00
Kevin Bracey a0197dba49 Thread: remove methods deprecated in 5.10 2020-01-08 16:47:18 +02:00
Kevin Bracey 077c6aa78d Thread: remove constructors deprecated in 5.1 2019-12-19 14:27:37 +02:00
Hugues Kamba a562841992 Cast void pointer before deallocating with delete[]
The stack memory is a `void*` which creates a warning when using
the `delete[]` operator because it is unable to call the destructor of
of an unknown object type.
2019-09-03 10:52:31 +01:00
int_szyk 6467f56abf Fix Coverity uninitialized pointer field Thread.h
Changed _obj_mem to be initialized with constructor of new thread.
2019-08-21 13:07:48 +02:00
Hugues Kamba bfa1b4dd84 Drivers/Events/RTOS Public and internal APIs cleanup (#10955)
Separate drivers, events, and rtos internal APIs from public APIs.

* Move source files to source subdirs
* Move internal headers to internal subdirs
* Add Doxygen comments for documenting internal and public APIs
* Remove source code from header files in order to remove include pre-processor directives
that included header files not directly used by said header files
* Explicitly include header files instead of implicit inclusions via third-party header files.

Release Notes

This will break user code that was using an internal API as the internal header files have been moved.
This will only break if the user was including the header file using a namespace (i.e #include "foo/bar.h" instead of #include "bar.h"
2019-08-02 12:23:47 +01:00