Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom logging allocator not passed to rcutils_logging_initialize_with_allocator #1036

Closed
jrutgeer opened this issue Mar 1, 2023 · 4 comments
Assignees

Comments

@jrutgeer
Copy link

jrutgeer commented Mar 1, 2023

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

@fujitatomoya
Copy link
Collaborator

@jrutgeer
Copy link
Author

jrutgeer commented Mar 16, 2023

Haven't had a chance to look at it in detail, but on first sight I don't think this will fix it as each log call calls RCUTILS_LOGGING_AUTOINIT and there are log calls before rcl_logging_configure_with_output_handler()

See also #1037 (comment)

@fujitatomoya
Copy link
Collaborator

Ah yeah, that is true, i was focusing on rclcpp. but if application calls rcl or rcutils directly to initialize the logger, that is gonna be the problem.

See also #1037 (comment)

thanks, i will take a look at it.

@fujitatomoya
Copy link
Collaborator

@jrutgeer as you mentioned #1036 (comment), this is related to #1037. So i will keep that on #1037 instead, closing this issue since [Custom logging allocator not passed to rcutils_logging_initialize_with_allocator](https://github.com/ros2/rcl/issues/1036#top) is addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants