Giter Club home page Giter Club logo

Comments (4)

krakjoe avatar krakjoe commented on August 28, 2024

You can still throw an exception, nothing has changed in that regard.

<?php
class Unit {
    public function test() {
        exit(10);
    }
}

class Uopz_Test extends PHPUnit_Framework_TestCase
{
    public static function setupBeforeClass() {
        uopz_overload(ZEND_EXIT, function($status = 0) {
            throw new Exception("test");
        });
    }

    public function testExit()
    {
        $unit = new Unit();
        $unit->test();
        $this->assertTrue(true);
    }

    public static function teardownAfterClass() {
        uopz_overload(ZEND_EXIT, null);
    }
}
?>

This is fine, and still make sense.

When you throw, you are instructing the executor to leave the current block (scope), which is what you are doing when you return ZEND_USER_OPCODE_RETURN.

from uopz.

Raven24 avatar Raven24 commented on August 28, 2024

thanks for your quick response!
unfortunately I get a segfault when I try to run your code with

  • PHP 5.5.22 (cli) (built: Feb 19 2015 07:04:43)
  • with uopz v2.0.7 from PECL
  • PHPUnit 4.5.0

the output I get from strace right before the crash is:

open("/usr/local/bin/phpunit", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0775, st_size=3411356, ...}) = 0
lseek(3, 0, SEEK_CUR)                   = 0
lseek(3, 2662017, SEEK_SET)             = 2662017
read(3, "<?php\n/**\n * GlobalState\n *\n * C"..., 8192) = 8192
lseek(3, 2670209, SEEK_SET)             = 2670209
read(3, " foreach ($superGlobalArrays as "..., 8192) = 8192
lseek(3, 2673320, SEEK_SET)             = 2673320
brk(0)                                  = 0x7f79e5265000
brk(0x7f79e52a5000)                     = 0x7f79e52a5000
close(3)                                = 0
getcwd("/home/user/src/unittests", 4096) = 28
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x209} ---
+++ killed by SIGSEGV (core dumped) +++

let me know if you need any more information to debug this.

from uopz.

krakjoe avatar krakjoe commented on August 28, 2024

with uopz v2.0.7 from PECL

These changes are only in master right now, and are tentative (unreleased)

from uopz.

Raven24 avatar Raven24 commented on August 28, 2024

ok, thanks. I tried the code from git and it worked. the segfault was a problem somewhere in my setup.

from uopz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.