Skip to content

Threading causes loss of variable when 'Refresh All' #895

@brta-jc

Description

@brta-jc

We've had a bug appear a few times which occurs when pressing the 'Refresh All' button in the file menu. 'Refresh libraries' works fine.
This will happen reliably ever time we hit refresh, even after closing and reopening the GUI and SM. Vanilla new state machines are fine, so something seems to be corrupting the state machines we are authoring.

2024-05-14 11:51:48:  VERBOSE - rafcon.utils.timer:  Profiler: __init__ (args: (<rafcon.gui.models.state_machine.StateMachineModel object at 0x782e3c0388b0>, <rafcon.core.state_machine.StateMachine object at 0x782e3743e020>); kwargs: {}); duration: 0.00923s
2024-05-14 11:51:48:    DEBUG - rafcon.gui.controllers.state_machines_editor:  Create new graphical editor for state machine with id 8
2024-05-14 11:51:48:  VERBOSE - rafcon.gui.controllers.graphical_editor_gaphas:  Time spent in init 0.0002772808074951172 seconds for state machine 8
2024-05-14 11:51:48:  VERBOSE - rafcon.gui.models.state_machine_manager:  Number of created state models 25
2024-05-14 11:51:48:  VERBOSE - rafcon.gui.controllers.graphical_editor_gaphas:  start setup canvas
2024-05-14 11:51:48:  VERBOSE - rafcon.gui.controllers.graphical_editor_gaphas:  Time spent in setup canvas 0.004022359848022461 state machine 8
2024-05-14 11:51:49:    DEBUG - rafcon.core.state_machine_manager:  Remove state machine with id 1
2024-05-14 11:51:49:    DEBUG - rafcon.gui.models.state_machine_manager:  Delete state machine model for state machine with id 1
TypeError: MenuBarController.on_refresh_libraries_activate() takes 0 positional arguments but 1 was given
2024-05-14 11:51:55:    DEBUG - rafcon.gui.views.utils.editor:  The editor style 'rafcon-dark' is not supported. Using the default 'classic'
2024-05-14 11:51:55:    DEBUG - rafcon.gui.views.utils.editor:  The editor style 'rafcon-dark' is not supported. Using the default 'classic'
2024-05-14 11:51:57:    DEBUG - rafcon.core.library_manager:  Initializing LibraryManager: Loading libraries ... 
2024-05-14 11:51:57:  WARNING - rafcon.core.library_manager:  Configured path for library root key 'advanced_examples' does not exist: /home/jason/.config/rafcon/examples/functionality_examples
2024-05-14 11:51:57:  WARNING - rafcon.core.library_manager:  Configured path for library root key 'generic' does not exist: /home/jason/.config/rafcon/${RAFCON_LIB_PATH}/generic
2024-05-14 11:51:57:  WARNING - rafcon.core.library_manager:  Configured path for library root key 'ros' does not exist: /home/jason/.config/rafcon/examples/libraries/ros_libraries
2024-05-14 11:51:57:  WARNING - rafcon.core.library_manager:  Configured path for library root key 'turtle_libraries' does not exist: /home/jason/.config/rafcon/examples/libraries/turtle_libraries
2024-05-14 11:51:57:  WARNING - rafcon.core.library_manager:  Configured path for library root key 'tutorials' does not exist: /home/jason/.config/rafcon/examples/tutorials
2024-05-14 11:51:57:    DEBUG - rafcon.core.library_manager:  Adding library 'ros_libraries' from /home/jason/.local/lib/python3.10/site-packages/rafcon/share/rafcon/examples/libraries/ros_libraries
2024-05-14 11:51:57:    DEBUG - rafcon.core.library_manager:  Adding library 'bmt_cc_state' from /home/jason/ros2/src/bmt/cooperative-cell/ros/bmt_cc_state
2024-05-14 11:51:57:    DEBUG - rafcon.core.library_manager:  Adding library 'libraries' from /home/jason/.local/lib/python3.10/site-packages/rafcon/share/rafcon/libraries
2024-05-14 11:51:57:    DEBUG - rafcon.core.library_manager:  Adding library 'bmt_common_skills' from /home/jason/ros2/src/bmt/bmt_common_skills
2024-05-14 11:51:57:    DEBUG - rafcon.core.library_manager:  Initialization of LibraryManager done
2024-05-14 11:51:57:     INFO - rafcon.gui.controllers.library_tree:  Libraries have been updated
2024-05-14 11:51:57:     INFO - rafcon.gui.controllers.library_tree:  Libraries have been updated
2024-05-14 11:51:57:    DEBUG - rafcon.core.state_machine_manager:  Remove state machine with id 8
2024-05-14 11:51:57:    DEBUG - rafcon.core.storage.storage:  Loading state machine from path /home/jason/ros2/src/bmt/bmt_common_skills/states/rf_bmt_init_core...
2024-05-14 11:51:57:    DEBUG - rafcon.core.storage.storage:  Load state recursively: /home/jason/ros2/src/bmt/bmt_common_skills/states/rf_bmt_init_core/rf_bmt_init_core_KBXCPG
2024-05-14 11:51:57:    DEBUG - rafcon.core.storage.storage:  Load state recursively: /home/jason/ros2/src/bmt/bmt_common_skills/states/rf_bmt_init_core/rf_bmt_init_core_KBXCPG/rf_init_ros_JXYWDD
2024-05-14 11:51:57:    DEBUG - rafcon.core.storage.storage:  Loading state machine from path /home/jason/ros2/src/bmt/bmt_common_skills/states/common/rf_init_ros...
2024-05-14 11:51:57:    DEBUG - rafcon.core.storage.storage:  Load state recursively: /home/jason/ros2/src/bmt/bmt_common_skills/states/common/rf_init_ros/rf_init_ros_ZWPLGJ
2024-05-14 11:51:57:    DEBUG - rafcon.core.storage.storage:  Loaded state machine (/home/jason/ros2/src/bmt/bmt_common_skills/states/common/rf_init_ros) has 1 states. (Max hierarchy level 1)
2024-05-14 11:51:57:    DEBUG - rafcon.core.storage.storage:  Loaded state machine (/home/jason/ros2/src/bmt/bmt_common_skills/states/common/rf_init_ros) has 0 transitions.
2024-05-14 11:51:57:    DEBUG - rafcon.core.storage.storage:  Loaded state machine (/home/jason/ros2/src/bmt/bmt_common_skills/states/common/rf_init_ros) has 0 data flows.
2024-05-14 11:51:57:  VERBOSE - rafcon.utils.timer:  Profiler: load_state_machine_from_path (args: ('/home/jason/ros2/src/bmt/bmt_common_skills/states/common/rf_init_ros',); kwargs: {}); duration: 0.00101s
2024-05-14 11:51:57:    DEBUG - rafcon.core.storage.storage:  Loaded state machine (/home/jason/ros2/src/bmt/bmt_common_skills/states/rf_bmt_init_core) has 2 states. (Max hierarchy level 2)
2024-05-14 11:51:57:    DEBUG - rafcon.core.storage.storage:  Loaded state machine (/home/jason/ros2/src/bmt/bmt_common_skills/states/rf_bmt_init_core) has 2 transitions.
2024-05-14 11:51:57:    DEBUG - rafcon.core.storage.storage:  Loaded state machine (/home/jason/ros2/src/bmt/bmt_common_skills/states/rf_bmt_init_core) has 1 data flows.
2024-05-14 11:51:57:  VERBOSE - rafcon.utils.timer:  Profiler: load_state_machine_from_path (args: ('/home/jason/ros2/src/bmt/bmt_common_skills/states/rf_bmt_init_core', 8); kwargs: {}); duration: 0.0031s
2024-05-14 11:51:57:    DEBUG - rafcon.core.state_machine_manager:  Add new state machine with id 8
2024-05-14 11:51:57:    DEBUG - rafcon.gui.models.state_machine_manager:  Delete state machine model for state machine with id 8
2024-05-14 11:51:57:    DEBUG - rafcon.gui.models.state_machine_manager:  Add new state machine model ... 
2024-05-14 11:51:57:    DEBUG - rafcon.gui.models.state_machine_manager:  Create new state machine model for state machine with id 8
2024-05-14 11:51:57:    DEBUG - rafcon.gui.models.auto_backup:  The auto-backup for state-machine 8 is ENABLED and set to 'dynamic interval mode'
2024-05-14 11:51:57:    DEBUG - rafcon.gui.models.auto_backup:  Performing auto backup of state machine 8 to temp folder
2024-05-14 11:51:57:    DEBUG - rafcon.core.storage.storage:  State machine with id 8 was saved at /tmp/rafcon-jason/15849/runtime_backup/home/jason/ros2/src/bmt/bmt_common_skills/bmt_common_skills/states/rf_bmt_init_core
2024-05-14 11:51:57:  VERBOSE - rafcon.utils.timer:  Profiler: __init__ (args: (<rafcon.gui.models.state_machine.StateMachineModel object at 0x782e3743e800>, <rafcon.core.state_machine.StateMachine object at 0x782e57bcc100>); kwargs: {}); duration: 0.00736s
2024-05-14 11:51:57:  VERBOSE - rafcon.gui.models.state_machine_manager:  Number of created state models 28
Traceback (most recent call last):
  File "/home/jason/.local/lib/python3.10/site-packages/rafcon/gui/controllers/menu_bar.py", line 439, in on_refresh_all_activate
    gui_helper_state_machine.refresh_all(force=force)
  File "/home/jason/.local/lib/python3.10/site-packages/rafcon/gui/helpers/state_machine.py", line 948, in refresh_all
    state_machines_editor_ctrl.refresh_all_state_machines()
  File "/home/jason/.local/lib/python3.10/site-packages/rafcon/gui/controllers/state_machines_editor.py", line 499, in refresh_all_state_machines
    self.refresh_state_machines(list(self.model.state_machine_manager.state_machines.keys()))
  File "/home/jason/.local/lib/python3.10/site-packages/rafcon/gui/controllers/state_machines_editor.py", line 481, in refresh_state_machines
    self.rearrange_state_machines(page_num_by_sm_id)
  File "/home/jason/.local/lib/python3.10/site-packages/rafcon/gui/controllers/state_machines_editor.py", line 173, in rearrange_state_machines
    set_tab_label_texts(tab_label, state_machine_m, state_machine_m.state_machine.marked_dirty)
AttributeError: 'NoneType' object has no attribute 'marked_dirty'
^CException ignored in: <module 'threading' from '/usr/lib/python3.10/threading.py'>
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1567, in _shutdown
    lock.acquire()

Any help diagnosing and preventing further corruption of our SM's would be very helpful!
Many thanks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions