Skip to content

[ros2param] get verb segfaults for string param values that contain non-ASCII characters #176

Closed

Description

@hidmic

Bug report

Required Info:

  • Operating System:
  • Installation type:
    • Binary (debs)
  • Version or commit hash:
    • Crystal pre-release.
  • DDS implementation:
    • ADLink OpenSplice 6.9
  • Client library (if applicable):
    • N/A

Steps to reproduce issue

On any node, set a parameter with a string value containing a non-ASCII character:

ros2 param set /talker value 'añd'

Now, attempt to retrieve that same parameter

ros2 param get /talker value

Expected behavior

Either ros2 param get succesfully retrieving the value or ros2 param set complaining about the invalid value. Since wstrings are not fully supported yet (see design proposal), I'm inclined for the latter.

Actual behavior

CLI segfaults.

Activity

  1. changed the title [-][ros2param] get verb segfaults for string parameters that contain non-ASCII characters[/-] [+][ros2param] get verb segfaults for string param values that contain non-ASCII characters[/+] on Dec 12, 2018
  2. added
    bug
    on Dec 19, 2018
  3. hidmic commented on Jan 3, 2019

    @hidmic
    Author

    Taking a look...

  4. hidmic commented on Jan 3, 2019

    @hidmic
    Author

    Alright, I tracked down the segfaut into Python typesupport C extensions. Backtrace is shown below:

    Thread 1 "python3" received signal SIGSEGV, Segmentation fault.                                                    
    0x00007fffeee6dd9d in rcl_interfaces__msg__parameter_value__convert_to_py (raw_ros_message=0xff68c0)               
        at /home/michel/Workspaces/ros2_ws/build/rcl_interfaces/rosidl_generator_py/rcl_interfaces/msg/_parameter_value
    _s.c:354                                                                                                           
    354           Py_DECREF(field);                                                                                    
    (gdb) bt                                                                                                           
    #0  0x00007fffeee6dd9d in rcl_interfaces__msg__parameter_value__convert_to_py (raw_ros_message=0xff68c0)
        at /home/michel/Workspaces/ros2_ws/build/rcl_interfaces/rosidl_generator_py/rcl_interfaces/msg/_parameter_valu$
    _s.c:354                                                                                                           #1  0x00007fffeee71e1d in rcl_interfaces__srv__get_parameters__response__convert_to_py (raw_ros_message=0xff0d70)  
        at /home/michel/Workspaces/ros2_ws/build/rcl_interfaces/rosidl_generator_py/rcl_interfaces/srv/_get_parameters$_response_s.c:121                                                                                                  
    #2  0x00007ffff38f7405 in rclpy_take_response (_unused_self=<module at remote 0x7ffff43b2ef8>,                         args=(<PyCapsule at remote 0x7fffed092a50>, <Metaclass(__module__='rcl_interfaces.srv._get_parameters__respons$
    ', __doc__="Message class 'GetParameters_Response'.", __slots__=['_values'], _fields_and_field_types={'values': 'r$l_interfaces/ParameterValue[]'}, __init__=<function at remote 0x7ffff47edea0>, __repr__=<function at remote 0x7fff$
    47edf28>, __eq__=<function at remote 0x7ffff47f6048>, get_fields_and_field_types=<classmethod at remote 0x7ffff47f$be0>, values=<property at remote 0x7ffff47ecbd8>, _values=<member_descriptor at remote 0x7ffff47f4948>, __hash__=N$
    ne) at remote 0xe48bf8>)) at /home/michel/Workspaces/ros2_ws/src/ros2/rclpy/rclpy/src/rclpy/_rclpy.c:2814
    ...
    (gdb) l
    349       {  // string_value
    350         PyObject * field = NULL;
    351         field = PyUnicode_FromString(ros_message->string_value.data);
    352         {
    353           int rc = PyObject_SetAttrString(_pymessage, "string_value", field);
    354           Py_DECREF(field);
    355           if (rc) {
    356             return NULL;
    357           }
    358         }
    (gdb) p field
    $1 = 0x0
    (gdb) p ros_message->string_value.data
    $2 = 0xff20f0 "a\361d"

    It looks like the incoming Unicode is broken. And it seems to me that's related to a Unicode size assumption also in Python typesupport code.

    IMHO since we do not fully support wstring yet, we should be signaling an error above if the string about to be converted to its Python counterpart cannot be handled (e.g. using Py_Unicode_KIND()). Also, we need better error handling in case the incoming string is garbage.

    Unless anyone disagrees with the approach, I'll write a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions