Skip to content

Commit

Permalink
fix timing issue
Browse files Browse the repository at this point in the history
Before setting `@lock_file`, remote client can send stop request
to the parent process and it can cause data race issue.
  • Loading branch information
ko1 committed Sep 16, 2022
1 parent 2cb4448 commit 19b4dde
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/debug/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1893,9 +1893,11 @@ def multi_process!

def after_fork child: true
if child || !@lock_file
@m = Mutex.new
@lock_level = 0
@lock_file = open(@lock_tempfile.path, 'w')
@m = Mutex.new unless @m
@m.synchronize do
@lock_level = 0
@lock_file = open(@lock_tempfile.path, 'w')
end
end
end

Expand Down

0 comments on commit 19b4dde

Please sign in to comment.