sway-lsp: deadlock via read-lock in hover_data
Related Component
compiler
Problem
hover_data in sway-lsp contains a possible double read deadlock on state.engines
hover_data is called in handle_hover with &state.engines.read() https://github.com/FuelLabs/sway/blob/ac418ccf417ffe5b0c6bdacbd1b73058efdf6f51/sway-lsp/src/handlers/request.rs#L141-L147
Inside hover_data, if there is no token identity, hover_format is called with &state.engines.read() https://github.com/FuelLabs/sway/blob/ac418ccf417ffe5b0c6bdacbd1b73058efdf6f51/sway-lsp/src/capabilities/hover/mod.rs#L73-L75
Steps
While running hover_data with contents of type without an ident field (literals, etc...), a concurrent .write() on the engines lock will deadlock.
Possible Solution(s)
Delete the .read() inside the hover_format function call
Notes
Found through some static analysis, similar bug to #7145
Installed components
N/A
Source: FuelLabs/sway