gazebosim / gz-common

An audio-visual library supports processing audio and video files, a graphics library can load a variety 3D mesh file formats into a generic in-memory representation, and the core library of Gazebo Common contains functionality that spans Base64 encoding/decoding to thread pools.
https://gazebosim.org
Apache License 2.0
11 stars 36 forks source link

Crash with stack trace gz::common::absPath #614

Open zhileiren opened 4 days ago

zhileiren commented 4 days ago

Environment

Description

Steps to reproduce:

  1. run gz sim with any sdf file
  2. gz service --timeout 10000 -s /gazebo/resource_paths/resolve --reptype gz.msgs.StringMsg --reqtype gz.msgs.StringMsg --req ''

Output

a.log

zhileiren commented 3 days ago

https://github.com/gazebosim/gz-common/blob/gz-common5/src/Filesystem.cc#L136

std::string common::absPath(const std::string &_path)
{
  return fs::absolute(_path).string();
}

The root cause seems to be here, no empty check for _path, or shall it be fixed in the gz-sim repository?

https://github.com/gazebosim/gz-sim/blob/gz-sim8/src/ServerPrivate.cc#L489

bool ServerPrivate::ResourcePathsResolveService(
    const msgs::StringMsg &_req,
    msgs::StringMsg &_res)
{
  // Get the request
  std::string req = _req.data();
  // return false for empty req?

  // Handle the case where the request is already a valid path
  if (common::exists(common::absPath(req)))
  {
    _res.set_data(common::absPath(req));
    return true;
  }
  ...
}