pecl_bug10194_blob.phpt 1.5 KB

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