jsk-ros-pkg/jsk_roseus

Calling unadvertised service causes segmentation fault

furushchev opened this issue · 5 comments

Calling a service for wrong or unadvertised name causes segmentation fault rather than an error or nil.

1.irteusgl$ ros::roseus "AA"
t
2.irteusgl$ call-empty-service "dummy"
;; Segmentation Fault.
;; in (ros::service-call srvname (instance std_srvs::emptyrequest :init))
;; You are still in a signal handler.
;;Try reset or throw to upper level as soon as possible.
;; code=-470915024 x=e3ee6700 addr=7ffce3ee7160
Fatal: 

Is this problem already fixed?

Maybe no.
At this moment, we can avoid by checking the service is actually advertised.

(setq srv-name "service")
(setq req ...) ;; request
(setq res nil)
(if (ros::wait-for-service srv-name 1)
  (setq res (ros::service-call srv-name req)
  (ros::ros-error "~A not advertised" srv-name))

Thank you.
Temporarily, I deal with it by changing ROSEUS_SEVICE_CALL in roseus.cpp so that it checks existence of the service.

  if (!service::exists(service, true)) {
    ROS_ERROR("service  %s doesn't exist ",
              ros::names::resolve(service).c_str());
    if (persist) {
      // cleanup service_cache
      service_cache.erase(service_cache.find(service));
    }
    return (response._message);
  }

I made PR #588