rclcpp warnings not showing as expected
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
Línea de trabajo
Empieza reproduciendo el comportamiento de las advertencias con una imagen nueva de ros:rolling y colcon build, y compáralo después con el resultado de pixi + robotstack en macOS. Inspecciona rclcpp/logging.hpp, node_impl.hpp y any_subscription_callback.hpp junto con los ejemplos y el historial citados. Se considera terminado cuando se haya identificado por qué difieren las advertencias posteriores y se haya documentado o corregido la causa confirmada.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Background
To my best knowledge, there are some "bad patterns" we try to avoid when using rclcpp. Two examples that come to my mind:
1. Using rclcpp logging macros without format arguments:
std::string my_std_string = "Foo";
RCLCPP_DEBUG(get_logger(), my_std_string);
This is documented in the galactic changelog: https://docs.ros.org/en/rolling/Releases/Release-Galactic-Geochelone.html#change-in-rclcpp-s-logging-macros
2. Using non-const shared_ptr in subscription callbacks:
sub_ = this->create_subscription(
input,
10,
[](std::shared_ptr msg) { ... }
);
This is documented in the Jazzy changelog: https://docs.ros.org/en/rolling/Releases/Release-Jazzy-Jalisco.html#deprecated-subscription-callback-signatures-were-removed
Problem
When using these "bad patterns", I believe the expected behavior is a compiler warning/error like:
/Users/maurice/nav2_projects/nav2_ws/src/navigation2/nav2_behaviors/plugins/spin.cpp:66:27: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
66 | RCLCPP_ERROR(logger_, error_msg.c_str());
| ^~~~~~~~~~~~~~~~~
/Users/maurice/nav2_projects/nav2_ws/.pixi/envs/default/include/rclcpp/rclcpp/logging.hpp:753:82: note: expanded from macro 'RCLCPP_ERROR'
753 | #define RCLCPP_ERROR(logger, ...) RCLCPP_LOG(RCUTILS_LOG_SEVERITY_ERROR, logger, __VA_ARGS__)
| ^~~~~~~~~~~
/Users/maurice/nav2_projects/nav2_ws/.pixi/envs/default/include/rclcpp/rclcpp/logging.hpp:48:54: note: expanded from macro 'RCLCPP_LOG'
48 | RCUTILS_LOG_NAMED(severity, (logger).get_name(), __VA_ARGS__); \
| ^~~~~~~~~~~
/Users/maurice/nav2_projects/nav2_ws/.pixi/envs/default/include/rcutils/rcutils/logging_macros.h:56:73: note: expanded from macro 'RCUTILS_LOG_NAMED'
56 | rcutils_log_internal(&__rcutils_logging_location, severity, name, __VA_ARGS__); \
or
/Users/maurice/nav2_projects/nav2_ws/.pixi/envs/default/include/rclcpp/rclcpp/node_impl.hpp:100:18: note: in instantiation of function template specialization 'rclcpp::create_subscription<tf2_msgs::msg::TFMessage_<std::allocator<void>>, (lambda at /Users/maurice/nav2_projects/nav2_ws/src/navigation2/nav2_loopback_sim/test/test_loopback_simulator.cpp:157:5), std::allocator<void>, rclcpp::Subscription<tf2_msgs::msg::TFMessage_<std::allocator<void>>>, rclcpp::message_memory_strategy::MessageMemoryStrategy<tf2_msgs::msg::TFMessage_<std::allocator<void>>>, rclcpp::Node>' requested here
100 | return rclcpp::create_subscription<MessageT>(
| ^
/Users/maurice/nav2_projects/nav2_ws/src/navigation2/nav2_loopback_sim/test/test_loopback_simulator.cpp:155:31: note: in instantiation of function template specialization 'rclcpp::Node::create_subscription<tf2_msgs::msg::TFMessage_<std::allocator<void>>, (lambda at /Users/maurice/nav2_projects/nav2_ws/src/navigation2/nav2_loopback_sim/test/test_loopback_simulator.cpp:157:5), std::allocator<void>, rclcpp::Subscription<tf2_msgs::msg::TFMessage_<std::allocator<void>>>, rclcpp::message_memory_strategy::MessageMemoryStrategy<tf2_msgs::msg::TFMessage_<std::allocator<void>>>>' requested here
155 | auto tf_sub = helper_node_->create_subscription<tf2_msgs::msg::TFMessage>(
| ^
/Users/maurice/nav2_projects/nav2_ws/.pixi/envs/default/include/rclcpp/rclcpp/any_subscription_callback.hpp:456:5: note: 'set_deprecated<tf2_msgs::msg::TFMessage_<std::allocator<void>>>' has been explicitly marked deprecated here
456 | [[deprecated("use 'void(std::shared_ptr<const MessageT>)' instead")]]
However, these warnings/errors only showed up yesterday when I compiled on macOS (pixi + robotstack), and not in my usual workflow (e.g. pulling a fresh ros:rolling image and doing a colcon build), even with -Wall.
I also quickly searched for ::SharedPtr msg across ros2 repos and found that the pattern is still being used : https://docs.ros.org/en/rolling/Tutorials/Advanced/Writing-a-Buffer-Compatible-Conversions-Package.html#publish-and-subscribe, which makes me think CI also doesn't report the warning, same as what I see on Ubuntu.
Additional Information
I would also like to share some of my findings:
- Jun 6 2022: @clalancette reported that the warnings are not shown: https://github.com/ros2/rclcpp/pull/1918#issuecomment-1147564462
- The
shared_ptrcallback deprecation history:- Deprecated in #1598 (Apr 2021)
- Accidentally removed in #2431 (Feb 2024)
- Reintroduced in #2975 (Dec 2025)
My guess (not validated yet) is that the warnings introduced in 2021 were visible at the time, but then something happened between 2021 and 2022 that accidentally hid them, and the problem persists until today.
- When I worked on #2975, I first used
static_assertto block the bad pattern, I also found the packages using it and fixed them. Then, we agreed to deprecate for one distribution first, so I switched fromstatic_assertto[[deprecated]]. If I remember correctly, I could see the warnings on Ubuntu at that point, which is why I added:
#define RCLCPP_AVOID_DEPRECATIONS_FOR_UNIT_TESTS 1
But I admittedly didn't carefully recheck everything after switching to [[deprecated]], e.g. testing in downstream packages. So my guess (not validated yet) is that the warning shows up inside rclcpp itself but not in downstream packages consuming it.
I am using macOS (warnings visible) and Ubuntu (no warnings at all) to refer to these two cases, but my best guess is that it might be related to compiler differences or compiler flags. I don't have much time to dig deeper right now, but I am documenting this here so I don't forget, and I hope to get some insights from the community or the PMCs :)
This issue was originally written by hand, assisted by Claude Sonnet 4.6 for formatting the logs, code blocks, and organizing the content more clearly, and finally edited by the author.
- Lenguaje dominante
- C++
- Estrellas
- 815
- Forks
- 572
- Merge medio
- 6 d 8 h
- PR fusionados (30 d)
- 20
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de ros2/rclcpp
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
EventsCBGExecutor timers on ROS time stall after a backward /clock jumpPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertobug
Dificultad 4/5 3-5 días Aptitud para principiantes 30/100
Los mantenedores suelen responder en 1 día
-
Late /clock delivery under use_sim_time stalls node now() for ~0.33 s (found via ros2_control controller time)Posiblemente ocupada @JeremiahM37 la tomó hoy. Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 10/100
ros2/rclcpp#3329 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
:farmer: Flaky EventsCBGExecutor test: reentrant callback group fails to run callbacks concurrentlyAbiertobug
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
Copy constructor exception leaks intra-process message allocationPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
Todos los issues de ros2/rclcpp
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
accessibility good first issue hacktoberfest help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
OpenChemistry/avogadrolibs#3184 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Tracktion/tracktion_engine#475 ·
Los mantenedores suelen responder en 1 día
-
CB name typo in LMAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 62/100
orbiternassp/NASSP#1701 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
redis/memtier_benchmark#732 ·
Los mantenedores suelen responder en 1 día