summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFlorian Frank <flori@ping.de>2011-08-29 23:12:58 +0200
committerFlorian Frank <flori@ping.de>2011-11-09 23:07:12 +0100
commit4ee26ac90981bbe5d7b5114ddd5036a5cea24251 (patch)
treeb1a6af3a78529bdd82e7e9f87e56fdce1807afdf /tests
parentb50b1bdeaec8759bdf0d11e1c1f942e0ed6542f5 (diff)
downloadjson-4ee26ac90981bbe5d7b5114ddd5036a5cea24251.tar.gz
Add testcase for a possible crash with bignum
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_json_generate.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_json_generate.rb b/tests/test_json_generate.rb
index da96603..2110eba 100755
--- a/tests/test_json_generate.rb
+++ b/tests/test_json_generate.rb
@@ -210,4 +210,24 @@ EOT
ensure
GC.stress = stress
end if GC.respond_to?(:stress=)
+
+ def test_broken_bignum # [ruby-core:38867]
+ pid = fork do
+ Bignum.class_eval do
+ def to_s
+ end
+ end
+ begin
+ JSON::Ext::Generator::State.new.generate(1<<64)
+ exit 1
+ rescue TypeError
+ exit 0
+ end
+ end
+ _, status = Process.waitpid2(pid)
+ assert status.success?
+ rescue NotImplementedError
+ # forking to avoid modifying core class of a parent process and
+ # introducing race conditions of tests are run in parallel
+ end if defined?(JSON::Ext)
end