pecl_bug10194_blob.phpt 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. --TEST--
  2. PECL Bug #10194 (segfault in Instant Client when memory_limit is reached inside the callback)
  3. --SKIPIF--
  4. <?php
  5. $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs
  6. require(dirname(__FILE__).'/skipif.inc');
  7. if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platforms only");
  8. if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request');
  9. if (getenv("USE_ZEND_ALLOC") === "0") {
  10. die("skip Zend MM disabled");
  11. }
  12. ?>
  13. --INI--
  14. memory_limit=3M
  15. --FILE--
  16. <?php
  17. // This test is dependent on the behavior of the memory manager
  18. require(dirname(__FILE__).'/connect.inc');
  19. require(dirname(__FILE__).'/create_table.inc');
  20. $ora_sql = "INSERT INTO ".$schema.$table_name." (blob) VALUES (empty_blob())";
  21. $statement = oci_parse($c,$ora_sql);
  22. oci_execute($statement);
  23. $ora_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE";
  24. $statement = oci_parse($c,$ora_sql);
  25. oci_execute($statement, OCI_DEFAULT);
  26. $row = oci_fetch_assoc($statement);
  27. $string = str_repeat("test", 32768*4*4);
  28. for ($i = 0; $i < 8; $i++) {
  29. $row['BLOB']->write($string);
  30. }
  31. oci_commit($c);
  32. $ora_sql = "SELECT blob FROM ".$schema.$table_name;
  33. $statement = oci_parse($c,$ora_sql);
  34. oci_execute($statement);
  35. echo "Before load()\n";
  36. $row = oci_fetch_assoc($statement);
  37. var_dump(strlen($row['BLOB']->load())); /* here it should fail */
  38. require dirname(__FILE__).'/drop_table.inc';
  39. echo "Done\n";
  40. ?>
  41. --EXPECTF--
  42. Before load()
  43. Fatal error: Allowed memory size of %d bytes exhausted%s(tried to allocate %d bytes) in %s on line %d