Skip to content

Custom logging allocator not passed to rcutils_logging_initialize_with_allocator #1036

@jrutgeer

Description

@jrutgeer

Logging is initialized by a call to rcl_logging_configure_with_output_handler() (e.g. from rclcpp::init()).

This calls RCUTILS_LOGGING_AUTOINIT and then sets the logger allocator:

RCUTILS_LOGGING_AUTOINIT;
g_logging_allocator = *allocator;

I think this is a bug, as RCUTILS_LOGGING_AUTOINIT resolves to rcutils_logging_initialize() which calls rcutils_logging_initialize_with_allocator(rcutils_get_default_allocator());, i.e. with the default allocator (malloc) instead of the provided one. So the logging hash table gets the default allocator and not the provided one (and probably all other allocations as well as, since this seems the only place where g_rcutils_logging_allocator is set).

https://github.com/ros2/rcutils/blob/61018b2f88e55ac81edda4a45a02634493c999ed/include/rcutils/logging.h#L560-L572

https://github.com/ros2/rcutils/blob/61018b2f88e55ac81edda4a45a02634493c999ed/src/logging.c#L129-L132

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions