neversaydie 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +23 -0
- data/CHANGELOG.ja.rdoc +6 -0
- data/CHANGELOG.rdoc +6 -0
- data/Manifest.txt +11 -0
- data/README.ja.rdoc +86 -0
- data/README.rdoc +81 -0
- data/Rakefile +22 -0
- data/ext/neversaydie/extconf.rb +56 -0
- data/ext/neversaydie/neversaydie.c +32 -0
- data/lib/neversaydie.rb +5 -0
- data/test/test_never_say_die.rb +10 -0
- metadata +90 -0
data/.autotest
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'autotest/restart'
|
4
|
+
|
5
|
+
# Autotest.add_hook :initialize do |at|
|
6
|
+
# at.extra_files << "../some/external/dependency.rb"
|
7
|
+
#
|
8
|
+
# at.libs << ":../some/external"
|
9
|
+
#
|
10
|
+
# at.add_exception 'vendor'
|
11
|
+
#
|
12
|
+
# at.add_mapping(/dependency.rb/) do |f, _|
|
13
|
+
# at.files_matching(/test_.*rb$/)
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# %w(TestA TestB).each do |klass|
|
17
|
+
# at.extra_class_map[klass] = "test/test_misc.rb"
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
|
21
|
+
# Autotest.add_hook :run_command do |at|
|
22
|
+
# system "rake build"
|
23
|
+
# end
|
data/CHANGELOG.ja.rdoc
ADDED
data/CHANGELOG.rdoc
ADDED
data/Manifest.txt
ADDED
data/README.ja.rdoc
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
= NeverSayDie
|
2
|
+
|
3
|
+
* http://seattlerb.rubyforge.org
|
4
|
+
* http://github.com/tenderlove/neversaydie
|
5
|
+
|
6
|
+
== DESCRIPTION:
|
7
|
+
|
8
|
+
|
9
|
+
NEVER SAY DIEはSEGV発生時の救助を果たす為に開発されました。どんな過酷な
|
10
|
+
状況下でも、SEGVがあれば君の人生は救われたも同然。なんでSEGVが必要かって?
|
11
|
+
ただのメモリだろ? 俺が、高校生だった時、テストで100点なんか進級するのに
|
12
|
+
必要なかったんだから。なんで、作業を済ます為に君のメモリが100%
|
13
|
+
厳密でなくちゃあいけなんだよ。メモリのコラプションがあっちでもこっちでも
|
14
|
+
発生しても痛くも痒くもないんだろう?
|
15
|
+
|
16
|
+
当たって砕けてみろよ。畳の上でゴロゴロしてビールでも飲んで、NEVER SAY DIEを
|
17
|
+
使ってごらんよ。ほうら、君の悩みはなんてどっかに行っちゃっただろ?
|
18
|
+
|
19
|
+
|
20
|
+
== FEATURES/PROBLEMS:
|
21
|
+
|
22
|
+
* 問題は間違いなくあるだろう
|
23
|
+
* 移植性
|
24
|
+
* 根本的な問題には修正不能
|
25
|
+
* 時々機能停止する
|
26
|
+
* 以上
|
27
|
+
|
28
|
+
== SYNOPSIS:
|
29
|
+
|
30
|
+
以下のテストで内容をお見せしよう:
|
31
|
+
|
32
|
+
assert_raises NeverSayDie do
|
33
|
+
NeverSayDie.segv
|
34
|
+
end
|
35
|
+
|
36
|
+
以下はsegvのメソッドのソースコード:
|
37
|
+
|
38
|
+
static VALUE segv(VALUE self)
|
39
|
+
{
|
40
|
+
int *ptr = NULL;
|
41
|
+
*ptr = 1;
|
42
|
+
|
43
|
+
return self;
|
44
|
+
}
|
45
|
+
|
46
|
+
== REQUIREMENTS:
|
47
|
+
|
48
|
+
* libsigsegv
|
49
|
+
|
50
|
+
== INSTALL:
|
51
|
+
|
52
|
+
第1章: libsigsegv をインストール。OS X を使用の場合、以下のコマンドを使用:
|
53
|
+
|
54
|
+
$ sudo port install libsigsegv
|
55
|
+
|
56
|
+
他のプラットホームについては現在未確認
|
57
|
+
|
58
|
+
第2章: gem をインストール:
|
59
|
+
|
60
|
+
$ sudo gem install neversaydie
|
61
|
+
|
62
|
+
== LICENSE:
|
63
|
+
|
64
|
+
(The MIT License)
|
65
|
+
|
66
|
+
Copyright (c) 2009 Aaron Patterson
|
67
|
+
|
68
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
69
|
+
a copy of this software and associated documentation files (the
|
70
|
+
'Software'), to deal in the Software without restriction, including
|
71
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
72
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
73
|
+
permit persons to whom the Software is furnished to do so, subject to
|
74
|
+
the following conditions:
|
75
|
+
|
76
|
+
The above copyright notice and this permission notice shall be
|
77
|
+
included in all copies or substantial portions of the Software.
|
78
|
+
|
79
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
80
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
81
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
82
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
83
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
84
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
85
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
86
|
+
|
data/README.rdoc
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
= NeverSayDie
|
2
|
+
|
3
|
+
* http://seattlerb.rubyforge.org
|
4
|
+
* http://github.com/tenderlove/neversaydie
|
5
|
+
|
6
|
+
== DESCRIPTION:
|
7
|
+
|
8
|
+
NEVER SAY DIE lets you rescue from segmentation faults. Got a SEGV, don't
|
9
|
+
worry about it anymore! Just rescue an exception and get on with life. Who
|
10
|
+
cares about getting a SEGV anyway? It's just memory. I mean, when I was in
|
11
|
+
school, I didn't need 100% to pass the class. Why should your memory need to
|
12
|
+
be 100% correct to get the job done? A little memory corruption here and there
|
13
|
+
doesn't hurt anyone.
|
14
|
+
|
15
|
+
So go for it! Kick back, grab a beer, require the NEVER SAY DIE gem and let
|
16
|
+
your problems go away sometimes!
|
17
|
+
|
18
|
+
== FEATURES/PROBLEMS:
|
19
|
+
|
20
|
+
* Oh so many problems...
|
21
|
+
* Portability...
|
22
|
+
* Not solving the root cause..
|
23
|
+
* It might not work.
|
24
|
+
* Just to name a few
|
25
|
+
|
26
|
+
== SYNOPSIS:
|
27
|
+
|
28
|
+
I will let the (passing) test speak for itself:
|
29
|
+
|
30
|
+
assert_raises NeverSayDie do
|
31
|
+
NeverSayDie.segv
|
32
|
+
end
|
33
|
+
|
34
|
+
Here is the source of the segv method:
|
35
|
+
|
36
|
+
static VALUE segv(VALUE self)
|
37
|
+
{
|
38
|
+
int *ptr = NULL;
|
39
|
+
*ptr = 1;
|
40
|
+
|
41
|
+
return self;
|
42
|
+
}
|
43
|
+
|
44
|
+
== REQUIREMENTS:
|
45
|
+
|
46
|
+
* libsigsegv
|
47
|
+
|
48
|
+
== INSTALL:
|
49
|
+
|
50
|
+
First, install libsigsegv. If you're on OS X, do this:
|
51
|
+
|
52
|
+
$ sudo port install libsigsegv
|
53
|
+
|
54
|
+
I'm not sure about other platforms. Then install the gem:
|
55
|
+
|
56
|
+
$ sudo gem install neversaydie
|
57
|
+
|
58
|
+
== LICENSE:
|
59
|
+
|
60
|
+
(The MIT License)
|
61
|
+
|
62
|
+
Copyright (c) 2009 Aaron Patterson
|
63
|
+
|
64
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
65
|
+
a copy of this software and associated documentation files (the
|
66
|
+
'Software'), to deal in the Software without restriction, including
|
67
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
68
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
69
|
+
permit persons to whom the Software is furnished to do so, subject to
|
70
|
+
the following conditions:
|
71
|
+
|
72
|
+
The above copyright notice and this permission notice shall be
|
73
|
+
included in all copies or substantial portions of the Software.
|
74
|
+
|
75
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
76
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
77
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
78
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
79
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
80
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
81
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
gem 'rake-compiler', '>= 0.4.1'
|
6
|
+
require "rake/extensiontask"
|
7
|
+
|
8
|
+
name = 'neversaydie'
|
9
|
+
HOE = Hoe.spec name do
|
10
|
+
developer('Aaron Patterson', 'aaronp@rubyforge.org')
|
11
|
+
self.readme_file = ['README', ENV['HLANG'], 'rdoc'].compact.join('.')
|
12
|
+
self.history_file = ['CHANGELOG', ENV['HLANG'], 'rdoc'].compact.join('.')
|
13
|
+
self.extra_rdoc_files = FileList['*.rdoc']
|
14
|
+
spec_extras[:extensions] = "ext/neversaydie/extconf.rb"
|
15
|
+
self.rubyforge_name = 'seattlerb'
|
16
|
+
end
|
17
|
+
|
18
|
+
RET = Rake::ExtensionTask.new(name, HOE.spec) do |ext|
|
19
|
+
ext.lib_dir = File.join('lib', name)
|
20
|
+
end
|
21
|
+
|
22
|
+
# vim: syntax=ruby
|
@@ -0,0 +1,56 @@
|
|
1
|
+
ENV['RC_ARCHS'] = '' if RUBY_PLATFORM =~ /darwin/
|
2
|
+
|
3
|
+
# :stopdoc:
|
4
|
+
|
5
|
+
require 'mkmf'
|
6
|
+
|
7
|
+
LIBDIR = Config::CONFIG['libdir']
|
8
|
+
INCLUDEDIR = Config::CONFIG['includedir']
|
9
|
+
|
10
|
+
$CFLAGS << " -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline"
|
11
|
+
|
12
|
+
HEADER_DIRS = [
|
13
|
+
# First search /opt/local for macports
|
14
|
+
'/opt/local/include',
|
15
|
+
|
16
|
+
# Then search /usr/local for people that installed from source
|
17
|
+
'/usr/local/include',
|
18
|
+
|
19
|
+
# Check the ruby install locations
|
20
|
+
INCLUDEDIR,
|
21
|
+
|
22
|
+
# Finally fall back to /usr
|
23
|
+
'/usr/include',
|
24
|
+
]
|
25
|
+
|
26
|
+
LIB_DIRS = [
|
27
|
+
# First search /opt/local for macports
|
28
|
+
'/opt/local/lib',
|
29
|
+
|
30
|
+
# Then search /usr/local for people that installed from source
|
31
|
+
'/usr/local/lib',
|
32
|
+
|
33
|
+
# Check the ruby install locations
|
34
|
+
LIBDIR,
|
35
|
+
|
36
|
+
# Finally fall back to /usr
|
37
|
+
'/usr/lib',
|
38
|
+
]
|
39
|
+
|
40
|
+
sig_dirs = dir_config('sigsegv', '/opt/local/include', '/opt/local/lib')
|
41
|
+
unless ["", ""] == sig_dirs
|
42
|
+
HEADER_DIRS.unshift sig_dirs.first
|
43
|
+
LIB_DIRS.unshift sig_dirs[1]
|
44
|
+
end
|
45
|
+
|
46
|
+
unless find_header('sigsegv.h', *HEADER_DIRS)
|
47
|
+
abort "sigsegv is missing. please install it."
|
48
|
+
end
|
49
|
+
|
50
|
+
unless find_library('sigsegv', 'sigsegv_install_handler', *LIB_DIRS)
|
51
|
+
abort "sigsegv is missing. please install it."
|
52
|
+
end
|
53
|
+
|
54
|
+
create_makefile('neversaydie/neversaydie')
|
55
|
+
|
56
|
+
# :startdoc:
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#include <stdio.h>
|
2
|
+
#include <sigsegv.h>
|
3
|
+
#include <ruby.h>
|
4
|
+
|
5
|
+
static VALUE segv(VALUE self)
|
6
|
+
{
|
7
|
+
int *ptr = NULL;
|
8
|
+
*ptr = 1;
|
9
|
+
|
10
|
+
return self;
|
11
|
+
}
|
12
|
+
|
13
|
+
VALUE cNeverSayDie;
|
14
|
+
|
15
|
+
void continuation(void * a, void * b, void * c)
|
16
|
+
{
|
17
|
+
rb_raise(cNeverSayDie, "segfault at %ld", (int)a);
|
18
|
+
}
|
19
|
+
|
20
|
+
int handler(void * fault_address, int serious)
|
21
|
+
{
|
22
|
+
sigsegv_leave_handler(&continuation, fault_address, NULL, NULL);
|
23
|
+
return 1;
|
24
|
+
}
|
25
|
+
|
26
|
+
void Init_neversaydie()
|
27
|
+
{
|
28
|
+
cNeverSayDie = rb_define_class("NeverSayDie", rb_eRuntimeError);
|
29
|
+
rb_define_singleton_method(cNeverSayDie, "segv", segv, 0);
|
30
|
+
|
31
|
+
sigsegv_install_handler(&handler);
|
32
|
+
}
|
data/lib/neversaydie.rb
ADDED
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: neversaydie
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aaron Patterson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-08-10 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hoe
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.3.2
|
24
|
+
version:
|
25
|
+
description: |-
|
26
|
+
NEVER SAY DIE lets you rescue from segmentation faults. Got a SEGV, don't
|
27
|
+
worry about it anymore! Just rescue an exception and get on with life. Who
|
28
|
+
cares about getting a SEGV anyway? It's just memory. I mean, when I was in
|
29
|
+
school, I didn't need 100% to pass the class. Why should your memory need to
|
30
|
+
be 100% correct to get the job done? A little memory corruption here and there
|
31
|
+
doesn't hurt anyone.
|
32
|
+
|
33
|
+
So go for it! Kick back, grab a beer, require the NEVER SAY DIE gem and let
|
34
|
+
your problems go away sometimes!
|
35
|
+
email:
|
36
|
+
- aaronp@rubyforge.org
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions:
|
40
|
+
- ext/neversaydie/extconf.rb
|
41
|
+
extra_rdoc_files:
|
42
|
+
- Manifest.txt
|
43
|
+
- CHANGELOG.ja.rdoc
|
44
|
+
- CHANGELOG.rdoc
|
45
|
+
- README.ja.rdoc
|
46
|
+
- README.rdoc
|
47
|
+
files:
|
48
|
+
- .autotest
|
49
|
+
- CHANGELOG.ja.rdoc
|
50
|
+
- CHANGELOG.rdoc
|
51
|
+
- Manifest.txt
|
52
|
+
- README.ja.rdoc
|
53
|
+
- README.rdoc
|
54
|
+
- Rakefile
|
55
|
+
- ext/neversaydie/extconf.rb
|
56
|
+
- ext/neversaydie/neversaydie.c
|
57
|
+
- lib/neversaydie.rb
|
58
|
+
- test/test_never_say_die.rb
|
59
|
+
has_rdoc: true
|
60
|
+
homepage: http://seattlerb.rubyforge.org
|
61
|
+
licenses: []
|
62
|
+
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options:
|
65
|
+
- --main
|
66
|
+
- README.rdoc
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
- ext
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: "0"
|
75
|
+
version:
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: "0"
|
81
|
+
version:
|
82
|
+
requirements: []
|
83
|
+
|
84
|
+
rubyforge_project: seattlerb
|
85
|
+
rubygems_version: 1.3.4
|
86
|
+
signing_key:
|
87
|
+
specification_version: 3
|
88
|
+
summary: NEVER SAY DIE lets you rescue from segmentation faults
|
89
|
+
test_files:
|
90
|
+
- test/test_never_say_die.rb
|