stopgap_13632 1.0.0.beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/.travis.yml +10 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +27 -0
- data/Rakefile +9 -0
- data/appveyor.yml +22 -0
- data/ext/stopgap_13632/extconf.rb +13 -0
- data/ext/stopgap_13632/stopgap_13632.c +91 -0
- data/lib/.keep +0 -0
- data/stopgap_13632.gemspec +16 -0
- data/test/test_stopgap_13632.rb +34 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 24c31b0438ffbdc89e3e80b5bb7f49d1de13e361
|
4
|
+
data.tar.gz: c08119667058a4f92dae3b5510b0ef03afdcc47f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 91ace3348ffa796061f0cdb22edd895837f678c0bccf51605d91e27e0ffb55adbf4a659427ec33369abd23e7552a72337447cf4349a4108262f788f40b29d256
|
7
|
+
data.tar.gz: 88f906e4342376151cfa8706bda38fc48c626c97ff2a33c6bb71048830ea4f0dee91d542b0cfe12ae2a9f0b6e331a29376fecba67484e6d3fb0c6255b2c664a6
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Nikolay Vashchenko
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
## Description
|
2
|
+
Ruby gem temporary stopgap workaround for MRI Ruby versions 2.2.7, 2.3.4, 2.4.1 for the bug https://bugs.ruby-lang.org/issues/13632 until proper fix gets backported.
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
```ruby
|
6
|
+
gem install stopgap_13632
|
7
|
+
require 'stopgap_13632'
|
8
|
+
```
|
9
|
+
|
10
|
+
## Usage
|
11
|
+
And when an "IOError: stream closed" happens in a thread, accessing a busy IO:
|
12
|
+
```
|
13
|
+
rescue IOError
|
14
|
+
Thread.current.purge_interrupt_queue
|
15
|
+
end
|
16
|
+
```
|
17
|
+
It will unblock the thread and allow it to proceed.
|
18
|
+
|
19
|
+
## Contributing
|
20
|
+
```bash
|
21
|
+
rake compile
|
22
|
+
rake test
|
23
|
+
```
|
24
|
+
|
25
|
+
## CI
|
26
|
+
[](http://travis-ci.org/NickolasVashchenko/stopgap_13632)
|
27
|
+
[](https://ci.appveyor.com/api/projects/status/cqgu4tce6of44c9x?svg=true)
|
data/Rakefile
ADDED
data/appveyor.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
install:
|
2
|
+
- SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
|
3
|
+
- SET PATH=C:\MinGW\bin;%PATH%
|
4
|
+
- SET RAKEOPT=-rdevkit
|
5
|
+
- ruby --version
|
6
|
+
- gem --version
|
7
|
+
- bundle install
|
8
|
+
- bundle exec rake compile
|
9
|
+
|
10
|
+
build: off
|
11
|
+
|
12
|
+
test_script:
|
13
|
+
- bundle exec rake test
|
14
|
+
|
15
|
+
environment:
|
16
|
+
matrix:
|
17
|
+
- ruby_version: "24"
|
18
|
+
- ruby_version: "24-x64"
|
19
|
+
|
20
|
+
branches:
|
21
|
+
only:
|
22
|
+
- master
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
|
3
|
+
extension_name = 'stopgap_13632'
|
4
|
+
|
5
|
+
dir_config(extension_name)
|
6
|
+
|
7
|
+
BROKEN_VERSIONS = %w(2.2.7 2.3.4 2.4.1)
|
8
|
+
if (BROKEN_VERSIONS.include? RUBY_VERSION)
|
9
|
+
$defs << '-DBROKEN_RUBY'
|
10
|
+
$defs << "-DVERSION_#{RUBY_VERSION.gsub('.', '_')}"
|
11
|
+
end
|
12
|
+
|
13
|
+
create_makefile(extension_name )
|
@@ -0,0 +1,91 @@
|
|
1
|
+
#ifdef BROKEN_RUBY
|
2
|
+
#include "ruby.h"
|
3
|
+
#include "ruby/config.h"
|
4
|
+
|
5
|
+
struct common_field {
|
6
|
+
const size_t len;
|
7
|
+
const char *name;
|
8
|
+
int raw;
|
9
|
+
VALUE value;
|
10
|
+
};
|
11
|
+
|
12
|
+
enum enum4 {
|
13
|
+
status1,
|
14
|
+
status2,
|
15
|
+
status3,
|
16
|
+
status4
|
17
|
+
};
|
18
|
+
|
19
|
+
#if defined(_WIN32)
|
20
|
+
#include <windows.h>
|
21
|
+
typedef HANDLE rb_nativethread_id_t;
|
22
|
+
#else
|
23
|
+
#include <pthread.h>
|
24
|
+
typedef pthread_t rb_nativethread_id_t;
|
25
|
+
#endif
|
26
|
+
|
27
|
+
typedef struct half_thread {
|
28
|
+
void *vmlt_node1;
|
29
|
+
void *vmlt_node2;
|
30
|
+
void *self;
|
31
|
+
void *vm;
|
32
|
+
void *stack;
|
33
|
+
size_t stack_size;
|
34
|
+
void *cfp;
|
35
|
+
int safe_level;
|
36
|
+
int raised_flag;
|
37
|
+
void *last_status;
|
38
|
+
int state;
|
39
|
+
int waiting_fd;
|
40
|
+
void *passed_block;
|
41
|
+
void *passed_bmethod_me;
|
42
|
+
void *passed_ci_or_calling;
|
43
|
+
void *top_self;
|
44
|
+
void *top_wrapper;
|
45
|
+
#ifndef VERSION_2_4_1
|
46
|
+
void *base_block;
|
47
|
+
#endif
|
48
|
+
void *root_lep;
|
49
|
+
void *root_svar;
|
50
|
+
rb_nativethread_id_t thread_id;
|
51
|
+
#ifdef NON_SCALAR_THREAD_ID
|
52
|
+
char thread_id_string[sizeof(rb_nativethread_id_t) * 2 + 3];
|
53
|
+
#endif
|
54
|
+
enum enum4 status;
|
55
|
+
int to_kill;
|
56
|
+
int priority;
|
57
|
+
#if defined(_WIN32)
|
58
|
+
void *interrupt_event;
|
59
|
+
#elif defined(HAVE_PTHREAD_H)
|
60
|
+
void *ubf_list1_or_signal_thread_list;
|
61
|
+
#ifndef VERSION_2_2_7
|
62
|
+
void *ubf_list2;
|
63
|
+
#endif
|
64
|
+
pthread_cond_t cond;
|
65
|
+
#ifdef HAVE_CLOCKID_T
|
66
|
+
clockid_t clockid;
|
67
|
+
#endif
|
68
|
+
#endif
|
69
|
+
void *blocking_region_buffer;
|
70
|
+
void *thgroup;
|
71
|
+
void *value;
|
72
|
+
void *errinfo;
|
73
|
+
VALUE pending_interrupt_queue;
|
74
|
+
void *pending_interrupt_mask_stack;
|
75
|
+
int pending_interrupt_queue_checked;
|
76
|
+
} rb_half_thread_t;
|
77
|
+
|
78
|
+
VALUE
|
79
|
+
rb_thread_purge_queue(VALUE thread)
|
80
|
+
{
|
81
|
+
rb_half_thread_t *th = (rb_half_thread_t*)DATA_PTR(thread);
|
82
|
+
th->pending_interrupt_queue_checked = 1;
|
83
|
+
rb_ary_clear(th->pending_interrupt_queue);
|
84
|
+
return Qnil;
|
85
|
+
}
|
86
|
+
|
87
|
+
void Init_stopgap_13632()
|
88
|
+
{
|
89
|
+
rb_define_method(rb_cThread, "purge_interrupt_queue", rb_thread_purge_queue, 0);
|
90
|
+
}
|
91
|
+
#endif
|
data/lib/.keep
ADDED
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'stopgap_13632'
|
3
|
+
s.version = '1.0.0.beta'
|
4
|
+
s.authors = ['Nikolay Vashchenko']
|
5
|
+
s.description = 'Temporary stopgap workaround for MRI Ruby versions 2.2.7, 2.3.4, 2.4.1 for the bug https://bugs.ruby-lang.org/issues/13632 until it gets backported'
|
6
|
+
s.summary = 'Temporary solution for https://bugs.ruby-lang.org/issues/13632'
|
7
|
+
s.email = 'sir.nickolas@gmail.com'
|
8
|
+
s.extensions = ['ext/stopgap_13632/extconf.rb']
|
9
|
+
s.files = `git ls-files`.split($/)
|
10
|
+
s.homepage = 'https://github.com/NickolasVashchenko/stopgap_13632'
|
11
|
+
s.license = 'MIT'
|
12
|
+
s.platform = 'ruby' # Installable only for MRI
|
13
|
+
s.required_ruby_version = '> 2.2.6', '< 2.4.2'
|
14
|
+
s.add_development_dependency 'rake-compiler', '~> 1.0'
|
15
|
+
s.add_development_dependency 'minitest', '~> 5.8'
|
16
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require_relative '../lib/stopgap_13632'
|
3
|
+
|
4
|
+
Thread.abort_on_exception = true
|
5
|
+
|
6
|
+
class Stopgap13632Test < Minitest::Test
|
7
|
+
|
8
|
+
def test_concurrent_io_access
|
9
|
+
pipes = []
|
10
|
+
threads = []
|
11
|
+
100.times do
|
12
|
+
r, w = IO.pipe
|
13
|
+
pipes << [r, w]
|
14
|
+
threads << Thread.new do
|
15
|
+
while r.gets
|
16
|
+
end rescue IOError
|
17
|
+
if Thread.current.pending_interrupt?
|
18
|
+
assert Thread.current.respond_to? (:purge_interrupt_queue), "The bug detected for version #{RUBY_VERSION}"
|
19
|
+
Thread.current.purge_interrupt_queue
|
20
|
+
assert !Thread.current.pending_interrupt?, 'Workaround failed'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
pipes.each do |r, w|
|
25
|
+
w.puts 'test'
|
26
|
+
w.close
|
27
|
+
r.close
|
28
|
+
end
|
29
|
+
threads.each do |th|
|
30
|
+
th.join
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stopgap_13632
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.beta
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nikolay Vashchenko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-07-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake-compiler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.8'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.8'
|
41
|
+
description: Temporary stopgap workaround for MRI Ruby versions 2.2.7, 2.3.4, 2.4.1
|
42
|
+
for the bug https://bugs.ruby-lang.org/issues/13632 until it gets backported
|
43
|
+
email: sir.nickolas@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions:
|
46
|
+
- ext/stopgap_13632/extconf.rb
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- ".travis.yml"
|
51
|
+
- Gemfile
|
52
|
+
- LICENSE
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- appveyor.yml
|
56
|
+
- ext/stopgap_13632/extconf.rb
|
57
|
+
- ext/stopgap_13632/stopgap_13632.c
|
58
|
+
- lib/.keep
|
59
|
+
- stopgap_13632.gemspec
|
60
|
+
- test/test_stopgap_13632.rb
|
61
|
+
homepage: https://github.com/NickolasVashchenko/stopgap_13632
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 2.2.6
|
74
|
+
- - "<"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 2.4.2
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 1.3.1
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 2.6.11
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: Temporary solution for https://bugs.ruby-lang.org/issues/13632
|
88
|
+
test_files: []
|