oops-null 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,52 @@
1
+ require 'rubygems'
2
+ require 'rubygems/package_task'
3
+ require 'rake/extensiontask'
4
+
5
+ begin
6
+ have_tools = %w{gcc make sh}.all? do |t|
7
+ system("#{t} --version > NUL 2>&1")
8
+ end
9
+ require 'devkit' unless have_tools or ENV['RI_DEVKIT']
10
+ rescue LoadError
11
+ abort '[ERROR] build environment unavailable or misconfigured'
12
+ end
13
+
14
+ spec = Gem::Specification.new do |s|
15
+ s.name = 'oops-null'
16
+ s.summary = 'A segfaulting native RubyGem for Windows'
17
+ s.description = 'A native RubyGem for Windows that segfaults due to dereferencing a NULL pointer'
18
+ s.homepage = 'http://oopsforge.github.com/'
19
+ s.version = '0.1.0'
20
+ s.date = Time.now.strftime('%Y-%m-%d')
21
+
22
+ s.authors = ['Jon Maken']
23
+ s.email = 'jon.forums@gmail.com'
24
+
25
+ s.executables = ['nulloops']
26
+ s.default_executable = 'nulloops'
27
+ s.extensions = ['ext/oops_null/extconf.rb']
28
+
29
+ s.has_rdoc = false
30
+
31
+ s.require_paths = %w[lib]
32
+
33
+ s.files = FileList.new('bin/nulloops')
34
+ s.files << FileList.new('ext/**/extconf.rb', 'ext/**/*.{c,h}')
35
+ s.files << FileList.new('lib/**/*.rb', 'lib/**/*.so')
36
+ s.files << %w[
37
+ Rakefile
38
+ ]
39
+
40
+ s.rubygems_version = '1.3.7'
41
+ s.add_development_dependency('rake-compiler', ['>= 0.7.5'])
42
+ end
43
+
44
+ Gem::PackageTask.new(spec) do |pkg|
45
+ end
46
+
47
+ Rake::ExtensionTask.new('oops_null', spec) do |ext|
48
+ ext.lib_dir = 'lib/oops_null'
49
+ end
50
+
51
+ desc 'Clobber and compile oops-null extension'
52
+ task :default => [ :clobber, :compile ]
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'oops-null'
4
+
5
+ Oops::Null.boom
@@ -0,0 +1,15 @@
1
+ require 'mkmf'
2
+
3
+ # override normal build configuration to build debug friendly library
4
+ if ENV['BUILD_DEBUG_LIB']
5
+ puts '[INFO] enabling debug library build configuration.'
6
+ if RUBY_VERSION < '1.9'
7
+ $CFLAGS = CONFIG['CFLAGS'].gsub(/\s\-O\d?\s/, ' -O0 ')
8
+ $CFLAGS.gsub!(/\s?\-g\w*\s/, ' -ggdb3 ')
9
+ CONFIG['LDSHARED'] = CONFIG['LDSHARED'].gsub(/\s\-s(\s|\z)/, ' ')
10
+ else
11
+ CONFIG['debugflags'] << ' -ggdb3 -O0'
12
+ end
13
+ end
14
+
15
+ create_makefile('oops_null/oops_null')
@@ -0,0 +1,31 @@
1
+ #include <oops_null.h>
2
+
3
+ VALUE mOops = Qnil;
4
+ VALUE cOopsNull = Qnil;
5
+
6
+ static VALUE boom(VALUE self)
7
+ {
8
+ FILE* pFile;
9
+
10
+ pFile = fopen("MyBogusPurchaseOrder.edi", "rb");
11
+
12
+ /* Trying to reference a member of a FILE structure through a NULL pointer
13
+ * causes a segmentation fault.
14
+ */
15
+ printf("Backing FILE buffer size %d\n", pFile->_bufsiz);
16
+
17
+ /* Because of the segfault this part will never be reached. It is left
18
+ * as an example of how an opened file should be closed, thus avoiding
19
+ * a potential memory leak.
20
+ */
21
+ fclose(pFile);
22
+ return Qnil;
23
+ }
24
+
25
+ void Init_oops_null(void)
26
+ {
27
+ mOops = rb_define_module("Oops");
28
+ cOopsNull = rb_define_class_under(mOops, "Null", rb_cObject);
29
+
30
+ rb_define_singleton_method(cOopsNull, "boom", boom, 0);
31
+ }
@@ -0,0 +1,13 @@
1
+ #ifndef RUBY_OOPS_NULL
2
+ #define RUBY_OOPS_NULL
3
+
4
+ #include <ruby.h>
5
+
6
+ #define VALID_PTR(X) ((X) != NULL)
7
+
8
+ extern VALUE mOops;
9
+ extern VALUE cOopsNull;
10
+
11
+ void Init_oops_null(void);
12
+
13
+ #endif /* RUBY_OOPS_NULL */
@@ -0,0 +1 @@
1
+ require 'oops_null/oops_null'
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: oops-null
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Jon Maken
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-01-27 00:00:00 -05:00
18
+ default_executable: nulloops
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rake-compiler
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ - 7
31
+ - 5
32
+ version: 0.7.5
33
+ type: :development
34
+ version_requirements: *id001
35
+ description: A native RubyGem for Windows that segfaults due to dereferencing a NULL pointer
36
+ email: jon.forums@gmail.com
37
+ executables:
38
+ - nulloops
39
+ extensions:
40
+ - ext/oops_null/extconf.rb
41
+ extra_rdoc_files: []
42
+
43
+ files:
44
+ - bin/nulloops
45
+ - ext/oops_null/extconf.rb
46
+ - ext/oops_null/oops_null.c
47
+ - ext/oops_null/oops_null.h
48
+ - lib/oops-null.rb
49
+ - Rakefile
50
+ has_rdoc: false
51
+ homepage: http://oopsforge.github.com/
52
+ licenses: []
53
+
54
+ post_install_message:
55
+ rdoc_options: []
56
+
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ requirements: []
76
+
77
+ rubyforge_project:
78
+ rubygems_version: 1.3.7
79
+ signing_key:
80
+ specification_version: 3
81
+ summary: A segfaulting native RubyGem for Windows
82
+ test_files: []
83
+