Skip to content

Commit 19b4dde

Browse files
committed
fix timing issue
Before setting `@lock_file`, remote client can send stop request to the parent process and it can cause data race issue.
1 parent 2cb4448 commit 19b4dde

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/debug/session.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -1893,9 +1893,11 @@ def multi_process!
18931893

18941894
def after_fork child: true
18951895
if child || !@lock_file
1896-
@m = Mutex.new
1897-
@lock_level = 0
1898-
@lock_file = open(@lock_tempfile.path, 'w')
1896+
@m = Mutex.new unless @m
1897+
@m.synchronize do
1898+
@lock_level = 0
1899+
@lock_file = open(@lock_tempfile.path, 'w')
1900+
end
18991901
end
19001902
end
19011903

0 commit comments

Comments
 (0)