mirror of
https://github.com/esphome/esphome.git
synced 2025-09-22 21:22:22 +01:00
Always abort on allocation when out-of-memory (#2129)
Co-authored-by: Otto winter <otto@otto-winter.com>
This commit is contained in:
@@ -344,6 +344,15 @@ async def to_code(config):
|
||||
else:
|
||||
cg.add_library(lib, None)
|
||||
|
||||
if CORE.is_esp8266:
|
||||
# Arduino 2 has a non-standards conformant new that returns a nullptr instead of failing when
|
||||
# out of memory and exceptions are disabled. Since Arduino 2.6.0, this flag can be used to make
|
||||
# new abort instead. Use it so that OOM fails early (on allocation) instead of on dereference of
|
||||
# a NULL pointer (so the stacktrace makes more sense), and for consistency with Arduino 3,
|
||||
# which always aborts if exceptions are disabled.
|
||||
# For cases where nullptrs can be handled, use nothrow: `new (std::nothrow) T;`
|
||||
cg.add_build_flag("-DNEW_OOM_ABORT")
|
||||
|
||||
cg.add_build_flag("-Wno-unused-variable")
|
||||
cg.add_build_flag("-Wno-unused-but-set-variable")
|
||||
cg.add_build_flag("-Wno-sign-compare")
|
||||
|
Reference in New Issue
Block a user