Skip to content

Commit

Permalink
WIP: rclpy interaction crashes.
Browse files Browse the repository at this point in the history
Current processes:

rebuild:
  reset ; rm -rf output/bld && pixi run generate-recipes && time pixi run -v rattler-build build --recipe recipes/ros-jazzy-rosidl-generator-py --recipe recipes/ros-jazzy-rclpy --recipe recipes/ros-jazzy-rcl-interfaces -m conda_build_config.yaml -c robostack-jazzy -c conda-forge --keep-build

test:
  mamba create -n ros-jazzy -c conda-forge -c file:///Users/jso/code/ros-jazzy/output python=3.11\* ros-jazzy-rclpy
  mamba run --live-stream -n ros-jazzy lldb python -- -c 'import rclpy; rclpy.init(); node = rclpy.create_node("test"); rclpy.spin(node)'

  Then run with the 'r' command:

The second line will run a simple python script that exhibits the crash.  The log looks like this:

  (lldb) target create "python"
  Current executable set to '/Users/jso/code/FreeCAD/FreeCAD/.conda/ros-jazzy/bin/python' (arm64).
  (lldb) settings set -- target.run-args  "-c" "import rclpy; rclpy.init(); node = rclpy.create_node(\"test\"); rclpy.spin(node)"
  (lldb) r
  Process 78922 launched: '/Users/jso/code/FreeCAD/FreeCAD/.conda/ros-jazzy/bin/python' (arm64)
  Process 78922 stopped
  * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x60)
      frame #0: 0x00000001027d6314 libpython3.11.dylib`set_attribute_error_context + 60
  libpython3.11.dylib`set_attribute_error_context:
  ->  0x1027d6314 <+60>: ldr    x0, [x8, #0x60]
      0x1027d6318 <+64>: bl     0x1028a0b0c    ; PyErr_GivenExceptionMatches
      0x1027d631c <+68>: cbz    w0, 0x1027d6384 ; <+172>
      0x1027d6320 <+72>: ldr    x8, [x21, #0x358]
  Target 0: (python) stopped.
  (lldb) bt
  * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x60)
    * frame #0: 0x00000001027d6314 libpython3.11.dylib`set_attribute_error_context + 60
      frame #1: 0x00000001027d68f0 libpython3.11.dylib`PyObject_GetAttr + 192
      frame #2: 0x00000001027d67e0 libpython3.11.dylib`PyObject_GetAttrString + 108
      frame #3: 0x0000000101a87b04 libbuiltin_interfaces__rosidl_generator_py.dylib`builtin_interfaces__msg__time__convert_from_py + 60
      frame #4: 0x000000010219c0a8 librcl_interfaces__rosidl_generator_py.dylib`rcl_interfaces__msg__parameter_event__convert_from_py + 356
      frame RoboStack#5: 0x0000000100e48250 _rclpy_pybind11.cpython-311-darwin.so`___lldb_unnamed_symbol2190 + 360
      frame RoboStack#6: 0x0000000100e2b844 _rclpy_pybind11.cpython-311-darwin.so`___lldb_unnamed_symbol1795 + 76
      frame RoboStack#7: 0x0000000100e2c1a0 _rclpy_pybind11.cpython-311-darwin.so`___lldb_unnamed_symbol1802 + 208
      frame RoboStack#8: 0x0000000100dc17c0 _rclpy_pybind11.cpython-311-darwin.so`___lldb_unnamed_symbol708 + 4556
      frame RoboStack#9: 0x00000001000b7f4c python`cfunction_call + 124
      frame RoboStack#10: 0x00000001000606f0 python`_PyObject_MakeTpCall + 332
      frame RoboStack#11: 0x0000000100162e3c python`_PyEval_EvalFrameDefault + 46484
      frame RoboStack#12: 0x00000001001674c8 python`_PyEval_Vector + 184
      frame RoboStack#13: 0x00000001000608b8 python`_PyObject_FastCallDictTstate + 156
      frame RoboStack#14: 0x00000001000617f0 python`_PyObject_Call_Prepend + 176
      frame RoboStack#15: 0x00000001000dc888 python`slot_tp_init + 196
      frame RoboStack#16: 0x00000001000d4de4 python`type_call + 464
      frame RoboStack#17: 0x00000001000606f0 python`_PyObject_MakeTpCall + 332
      frame RoboStack#18: 0x0000000100162e3c python`_PyEval_EvalFrameDefault + 46484
      frame RoboStack#19: 0x00000001001674c8 python`_PyEval_Vector + 184
      frame #20: 0x00000001000608b8 python`_PyObject_FastCallDictTstate + 156
      frame #21: 0x00000001000617f0 python`_PyObject_Call_Prepend + 176
      frame #22: 0x00000001000dc888 python`slot_tp_init + 196
      frame #23: 0x00000001000d4de4 python`type_call + 464
      frame #24: 0x00000001000606f0 python`_PyObject_MakeTpCall + 332
      frame #25: 0x0000000100162e3c python`_PyEval_EvalFrameDefault + 46484
      frame #26: 0x00000001001568f4 python`PyEval_EvalCode + 220
      frame #27: 0x00000001001bc970 python`run_mod + 144
      frame #28: 0x00000001001c04a4 python`PyRun_SimpleStringFlags + 272
      frame #29: 0x00000001001e1b3c python`Py_RunMain + 1396
      frame #30: 0x00000001001e3050 python`pymain_main + 1252
      frame #31: 0x0000000100003398 python`main + 56
      frame #32: 0x00000001921f0274 dyld`start + 2840
  • Loading branch information
oursland committed Sep 20, 2024
1 parent ef93589 commit 8466bcd
Show file tree
Hide file tree
Showing 7 changed files with 741 additions and 608 deletions.
2 changes: 1 addition & 1 deletion conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cdt_name:
- ${{ "cos7" if linux }}

python:
- 3.12.* *_cpython
- 3.11.* *_cpython
python_impl:
- cpython

Expand Down
12 changes: 12 additions & 0 deletions patch/ros-jazzy-rosidl-generator-c.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/rosidl_generator_c-extras.cmake.in b/rosidl_generator_c-extras.cmake.in
index 48ff0d8f8..7239d26c0 100644
--- a/rosidl_generator_c-extras.cmake.in
+++ b/rosidl_generator_c-extras.cmake.in
@@ -6,6 +6,6 @@ set(rosidl_generator_c_LIBRARY_TYPE "@rosidl_generator_c_LIBRARY_TYPE@")
include("${CMAKE_CURRENT_LIST_DIR}/register_c.cmake")
rosidl_generator_c_extras(
"${rosidl_generator_c_DIR}/../../../lib/rosidl_generator_c/rosidl_generator_c"
- "${rosidl_generator_c_DIR}/../../../@PYTHON_INSTALL_DIR@/rosidl_generator_c/__init__.py"
+ "@CMAKE_INSTALL_PREFIX@/@PYTHON_INSTALL_DIR@/rosidl_generator_c/__init__.py"
"${rosidl_generator_c_DIR}/../resource"
)
12 changes: 12 additions & 0 deletions patch/ros-jazzy-rosidl-generator-cpp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/rosidl_generator_cpp-extras.cmake.in b/rosidl_generator_cpp-extras.cmake.in
index 703ced5e2..94360ccb9 100644
--- a/rosidl_generator_cpp-extras.cmake.in
+++ b/rosidl_generator_cpp-extras.cmake.in
@@ -3,6 +3,6 @@
include("${CMAKE_CURRENT_LIST_DIR}/register_cpp.cmake")
rosidl_generator_cpp_extras(
"${rosidl_generator_cpp_DIR}/../../../lib/rosidl_generator_cpp/rosidl_generator_cpp"
- "${rosidl_generator_cpp_DIR}/../../../@PYTHON_INSTALL_DIR@/rosidl_generator_cpp/__init__.py"
+ "@CMAKE_INSTALL_PREFIX@/@PYTHON_INSTALL_DIR@/rosidl_generator_cpp/__init__.py"
"${rosidl_generator_cpp_DIR}/../resource"
)
105 changes: 105 additions & 0 deletions patch/ros-jazzy-rosidl-generator-py.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
diff --git a/cmake/register_py.cmake b/cmake/register_py.cmake
index f31c534..170b0f9 100644
--- a/cmake/register_py.cmake
+++ b/cmake/register_py.cmake
@@ -23,6 +23,8 @@ macro(rosidl_generator_py_extras BIN GENERATOR_FILES TEMPLATE_DIR)
"rosidl_generator_py"
"rosidl_generator_py_generate_interfaces.cmake")

+ message(NOTICE "CMAKE_INSTALL_PREFIX/PYTHON_INSTALL_DIR = " ${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_DIR})
+
normalize_path(BIN "${BIN}")
set(rosidl_generator_py_BIN "${BIN}")

diff --git a/cmake/rosidl_generator_py_generate_interfaces.cmake b/cmake/rosidl_generator_py_generate_interfaces.cmake
index cfc424a..cddd23d 100644
--- a/cmake/rosidl_generator_py_generate_interfaces.cmake
+++ b/cmake/rosidl_generator_py_generate_interfaces.cmake
@@ -119,6 +119,7 @@ rosidl_write_generator_arguments(
TARGET_DEPENDENCIES ${target_dependencies}
)

+message(NOTICE "rosidl_generate_interfaces_SKIP_INSTALL = " ${rosidl_generate_interfaces_SKIP_INSTALL})
if(NOT rosidl_generate_interfaces_SKIP_INSTALL)
ament_python_install_package(${PROJECT_NAME} PACKAGE_DIR "${_output_path}")
endif()
@@ -138,7 +139,7 @@ set_property(

set(_target_name_lib "${rosidl_generate_interfaces_TARGET}__rosidl_generator_py")
add_library(${_target_name_lib} SHARED ${_generated_c_files})
-target_link_libraries(${_target_name_lib} PRIVATE
+target_link_libraries(${_target_name_lib} PUBLIC
${rosidl_generate_interfaces_TARGET}__rosidl_generator_c)
add_dependencies(
${_target_name_lib}
@@ -146,11 +147,6 @@ add_dependencies(
${rosidl_generate_interfaces_TARGET}__rosidl_typesupport_c
)

-target_link_libraries(
- ${_target_name_lib} PRIVATE
- Python3::NumPy
- Python3::Python
-)
target_include_directories(${_target_name_lib}
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/rosidl_generator_c
@@ -162,8 +158,15 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(_extension_compile_flags -Wall -Wextra)
endif()

+if(APPLE)
+ set_target_properties(${_target_name_lib} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
+ target_include_directories(${_target_name_lib} PUBLIC ${Python3_INCLUDE_DIRS} ${Python3_NumPy_INCLUDE_DIRS})
+else()
+ target_link_libraries(${_target_name_lib} PUBLIC Python3::NumPy Python3::Python)
+endif()
+
rosidl_get_typesupport_target(c_typesupport_target "${rosidl_generate_interfaces_TARGET}" "rosidl_typesupport_c")
-target_link_libraries(${_target_name_lib} PRIVATE ${c_typesupport_target})
+target_link_libraries(${_target_name_lib} PUBLIC ${c_typesupport_target})

foreach(_typesupport_impl ${_typesupport_impls})
find_package(${_typesupport_impl} REQUIRED)
@@ -194,7 +197,7 @@ foreach(_typesupport_impl ${_typesupport_impls})
RUNTIME_OUTPUT_DIRECTORY ${_output_path})

target_link_libraries(
- ${_target_name} PRIVATE
+ ${_target_name} PUBLIC
${_target_name_lib}
${rosidl_generate_interfaces_TARGET}__${_typesupport_impl}
${c_typesupport_target}
@@ -210,7 +213,7 @@ foreach(_typesupport_impl ${_typesupport_impls})
)

foreach(_pkg_name ${rosidl_generate_interfaces_DEPENDENCY_PACKAGE_NAMES})
- target_link_libraries(${_target_name} PRIVATE ${${_pkg_name}__TARGETS})
+ target_link_libraries(${_target_name} PUBLIC ${${_pkg_name}__TARGETS})
endforeach()

add_dependencies(${_target_name}
@@ -231,7 +234,7 @@ endforeach()

# Depend on rosidl_generator_py generated targets from our dependencies
foreach(_pkg_name ${rosidl_generate_interfaces_DEPENDENCY_PACKAGE_NAMES})
- target_link_libraries(${_target_name_lib} PRIVATE ${${_pkg_name}_TARGETS${rosidl_generator_py_suffix}})
+ target_link_libraries(${_target_name_lib} PUBLIC ${${_pkg_name}_TARGETS${rosidl_generator_py_suffix}})
endforeach()

set_target_properties(${_target_name_lib} PROPERTIES COMPILE_OPTIONS "${_extension_compile_flags}")
diff --git a/rosidl_generator_py-extras.cmake.in b/rosidl_generator_py-extras.cmake.in
index 80bed29..db4add3 100644
--- a/rosidl_generator_py-extras.cmake.in
+++ b/rosidl_generator_py-extras.cmake.in
@@ -1,7 +1,9 @@
# generated from rosidl_generator_py/rosidl_generator_py-extras.cmake
+find_package(Python3 REQUIRED COMPONENTS Development NumPy)
+
include("${CMAKE_CURRENT_LIST_DIR}/register_py.cmake")
rosidl_generator_py_extras(
"${rosidl_generator_py_DIR}/../../../lib/rosidl_generator_py/rosidl_generator_py"
- "${rosidl_generator_py_DIR}/../../../@PYTHON_INSTALL_DIR@/rosidl_generator_py/__init__.py;${rosidl_generator_py_DIR}/../../../@PYTHON_INSTALL_DIR@/rosidl_generator_py/generate_py_impl.py"
+ "@CMAKE_INSTALL_PREFIX@/@PYTHON_INSTALL_DIR@/rosidl_generator_py/__init__.py;@CMAKE_INSTALL_PREFIX@/@PYTHON_INSTALL_DIR@/rosidl_generator_py/generate_py_impl.py"
"${rosidl_generator_py_DIR}/../resource"
)
Loading

0 comments on commit 8466bcd

Please sign in to comment.