acts-project / vecmem

Vectorised data model base and helper classes.
https://acts-project.github.io/vecmem/
Mozilla Public License 2.0
19 stars 13 forks source link

Memory Resources Shouldn't Return `nullptr` (2024.08.08.) #290

Open krasznaa opened 3 months ago

krasznaa commented 3 months ago

@stephenswat brought this up in the past, at which point I admittedly didn't pay maybe enough attention to it. But now, at least with a recent oneAPI / clang version, I bumped into this error:

[ RUN      ] core_memory_resource_tests/memory_resource_test_basic.allocations/host_resource
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/memory_resource:122:7: runtime error: null pointer returned from function declared to never return null
/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/memory_resource:121:20: note: returns_nonnull attribute specified here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/memory_resource:122:7 
[       OK ] core_memory_resource_tests/memory_resource_test_basic.allocations/host_resource (0 ms)

We'll need to go through all memory resources, and make sure that they consistently throw std::bad_alloc when something goes wrong... :thinking: