-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When the system re2 library gets updated, it's often difficult and time-consuming to determine that a `gem pristine re2` is needed. This `gdk doctor` diagnostic attempts to reproduce the seg fault that occurs as a result of mudge/re2#43.
- Loading branch information
1 parent
e32d090
commit ba32ef4
Showing
3 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'open3' | ||
|
||
module GDK | ||
module Diagnostic | ||
class Re2 < Base | ||
TITLE = 're2' | ||
SCRIPT = "require 're2'; regexp = RE2::Regexp.new('{', log_errors: false); regexp.error unless regexp.ok?" | ||
|
||
def diagnose | ||
# When re2 and libre2 are out of sync, a seg fault can occur due | ||
# to some memory corruption (https://github.com/mudge/re2/issues/43). | ||
# This test doesn't always fail the first time, so repeat the test | ||
# several times to be sure. | ||
5.times do | ||
@stdout, @stderr, @status = Open3.capture3('ruby', '-e', SCRIPT) | ||
break unless @status.success? | ||
end | ||
end | ||
|
||
def success? | ||
@status.success? && @stdout.empty? && @stderr.empty? | ||
end | ||
|
||
def detail | ||
<<~MESSAGE | ||
It looks like your system re2 library may have been upgraded, and | ||
the re2 gem needs to be rebuilt as a result. | ||
Please run `gem pristine re2`. | ||
MESSAGE | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters