Skip to content

sway-lsp: deadlock via read-lock in hover_data #7711

Description

@scaspin

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()

Ok(capabilities::hover::hover_data(
state,
sync,
&state.engines.read(),
&uri,
position,
))

Inside hover_data, if there is no token identity, hover_format is called with &state.engines.read()

None => hover_format(
&state.engines.read(),
token,

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageThis issue was opened with a template and needs to be triaged by code owners.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions