Skip to content

[WIP] Fix segmentation fault in mission loading code#8

Draft
msirobot with Copilot wants to merge 1 commit into
masterfrom
copilot/fix-mission-loading-segfault
Draft

[WIP] Fix segmentation fault in mission loading code#8
msirobot with Copilot wants to merge 1 commit into
masterfrom
copilot/fix-mission-loading-segfault

Conversation

Copilot AI commented Nov 14, 2025

Copy link
Copy Markdown

Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.

Original prompt

Problem

The prioritized_traj_planner node crashes with exit code -11 (segmentation fault) immediately after launch:

[prioritized_traj_planner-3] process has died [pid 115885, exit code -11, cmd /home/ali/catkin_ws/devel/lib/multi_robot_traj_planner/prioritized_traj_planner __name:=prioritized_traj_planner __log:=/home/ali/.ros/log/185ef506-c16b-11f0-8af5-91ce2fac54a4/prioritized_traj_planner-3.log].

Root Cause Analysis

The crash occurs in the mission loading code in multi_robot_traj_planner/include/mission.hpp. The code accesses JSON/document fields without proper null checking or validation, leading to segmentation faults when:

  1. Mission file doesn't exist or is malformed
  2. Required JSON fields are missing
  3. Array indices are out of bounds
  4. The mission file path is incorrect

Specifically, around lines 80-95 in mission.hpp, the code:

  • Calls FindMember() but doesn't check if the result is valid before dereferencing
  • Accesses array elements without bounds checking
  • Doesn't validate JSON structure before accessing nested fields

Required Fix

Add proper error handling and validation to the mission loading code:

  1. Add null checks after FindMember() calls before dereferencing
  2. Validate array sizes before accessing elements
  3. Add try-catch blocks around JSON parsing operations
  4. Provide clear error messages when mission file is invalid or missing required fields
  5. Validate mission file path exists before attempting to parse
  6. Check document structure before accessing nested fields

Files to Fix

  • multi_robot_traj_planner/include/mission.hpp - Add error handling in setMission() method
  • multi_robot_traj_planner/src/prioritized_traj_planner.cpp - Already has error checking that calls return -1, but the crash happens before that

Expected Behavior After Fix

  • The node should start successfully without segfault
  • If mission file is missing or invalid, print clear error message and exit gracefully
  • All JSON field access should be protected with null/bounds checks
  • The node should handle edge cases without crashing

Testing

After the fix, the following should work without crashes:

roslaunch multi_robot_traj_planner prioritized_plan_warehouse.launch

The fix should prevent segmentation faults and provide helpful error messages when configuration issues occur.

This pull request was created as a result of the following prompt from Copilot chat.

Problem

The prioritized_traj_planner node crashes with exit code -11 (segmentation fault) immediately after launch:

[prioritized_traj_planner-3] process has died [pid 115885, exit code -11, cmd /home/ali/catkin_ws/devel/lib/multi_robot_traj_planner/prioritized_traj_planner __name:=prioritized_traj_planner __log:=/home/ali/.ros/log/185ef506-c16b-11f0-8af5-91ce2fac54a4/prioritized_traj_planner-3.log].

Root Cause Analysis

The crash occurs in the mission loading code in multi_robot_traj_planner/include/mission.hpp. The code accesses JSON/document fields without proper null checking or validation, leading to segmentation faults when:

  1. Mission file doesn't exist or is malformed
  2. Required JSON fields are missing
  3. Array indices are out of bounds
  4. The mission file path is incorrect

Specifically, around lines 80-95 in mission.hpp, the code:

  • Calls FindMember() but doesn't check if the result is valid before dereferencing
  • Accesses array elements without bounds checking
  • Doesn't validate JSON structure before accessing nested fields

Required Fix

Add proper error handling and validation to the mission loading code:

  1. Add null checks after FindMember() calls before dereferencing
  2. Validate array sizes before accessing elements
  3. Add try-catch blocks around JSON parsing operations
  4. Provide clear error messages when mission file is invalid or missing required fields
  5. Validate mission file path exists before attempting to parse
  6. Check document structure before accessing nested fields

Files to Fix

  • multi_robot_traj_planner/include/mission.hpp - Add error handling in setMission() method
  • multi_robot_traj_planner/src/prioritized_traj_planner.cpp - Already has error checking that calls return -1, but the crash happens before that

Expected Behavior After Fix

  • The node should start successfully without segfault
  • If mission file is missing or invalid, print clear error message and exit gracefully
  • All JSON field access should be protected with null/bounds checks
  • The node should handle edge cases without crashing

Testing

After the fix, the following should work without crashes:

roslaunch multi_robot_traj_planner prioritized_plan_warehouse.launch

The fix should prevent segmentation faults and provide helpful error messages when configuration issues occur.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Nov 14, 2025
Copilot stopped work on behalf of msirobot due to an error November 14, 2025 15:06
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

Successfully merging this pull request may close these issues.

1 participant