Skip to content

Commit

Permalink
fix segmentation fault reported
Browse files Browse the repository at this point in the history
  • Loading branch information
knorth55 committed Dec 6, 2022
1 parent 6d49525 commit 1e482f9
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions roseus_smach/src/state-machine-ros.l
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
(defclass state-machine-inspector
:super propertied-object
:slots (sm root-name srv-name init-tm state-counter structure-counter
groupname exit-state))
groupname exit-state exit-signal-hook))
(defmethod state-machine-inspector
(:init
(sm-obj &key ((:root-name rn) "SM_ROOT") ((:srv-name sn) "/server_name") ((:groupname gp)))
Expand Down Expand Up @@ -142,21 +142,26 @@
(setq init-tm (ros::time-now))
))
(:exit-state () exit-state)
(:exit-signal-hook () exit-signal-hook)
(:register-exit-signal-hook
(es userdata exit-signal-hook-func)
(if (null (derivedp es state))
(setq es (send self :state-machine :node es)))
;; update exit-state slot
(setq exit-state es)
(send self :put 'userdata userdata)
(let ((exit-signal-hook
`(lambda-closure nil 0 0 (sig code)
(ros::ros-warn " Signal ~A called.~%" (unix:signal unix::sigint))
(ros::ros-error "Calling exit-signal-hook.~%")
(funcall ',exit-signal-hook-func (send ,self :get 'userdata))
(ros::ros-warn " Forcing transition to ~A.~%" ,es)
(send ,self :exit-signal-hook sig code ,es (send ,self :get 'userdata)))))
(unix:signal unix::sigint exit-signal-hook)))
;; we need to set exit-signal-hook in slot
;; to avoid memory error, GC causes this error?
(setq exit-signal-hook
`(lambda-closure nil 0 0 (sig code)
(ros::ros-warn " Signal ~A called." unix::sigint)
(ros::ros-warn "Calling exit-signal-hook.")
(funcall ',exit-signal-hook-func (send ,self :get 'userdata))
(ros::ros-warn " Forcing transition to ~A." ,es)
(send ,self :exit-signal-hook sig code ,es (send ,self :get 'userdata))
))
(unix:signal unix::sigint exit-signal-hook)
)
(:exit-signal-hook (sig code &optional es userdata)
(if (null es) (return-from :exit-signal-hook (exit sig)))
(send sm :active-state es)
Expand Down

0 comments on commit 1e482f9

Please sign in to comment.