Task extends \Threaded {

    public function run() {
        var_dump(get_class($this));
    }

}

class MyWorker extends \Worker {

    public function run() {
        ini_set("memory_limit", -1);
    }

    public function start(int $options = PTHREADS_INHERIT_CONSTANTS) {
        parent::start($options);
    }

}

$pool = new \Pool(4, MyWorker::class);

for ($i = 0; $i < 4; $i++) {
    $pool->submit(new AllocateMemoryTask());
}

while (true) {
    for ($i = 0; $i < 4; $i++) {
        $pool->submit(new SimpleTask());
    }
    sleep(1);
}
<issue_comment>username_1: reproduced, will investigate.
<issue_comment>username_1: This is an interesting bug for sure. With debug-compiled PHP, this error is spammed:
```
Fatal error: Uncaught Error: Call to undefined function test() in test.php:23
Stack trace:
#0 [internal function]: SimpleTask->run()
#1 {main}
  thrown in test.php on line 23
```
<issue_comment>username_0: The problem in memory allocation when copying function. For literals memory allocated there https://github.com/pmmp/pthreads/blob/0f9f2db2037d9d8cfeec96e27dba837f36a40c23/src/copy.h#L123, for opcodes https://github.com/pmmp/pthreads/blob/0f9f2db2037d9d8cfeec96e27dba837f36a40c23/src/copy.h#L213. 
Than recalc opline->op1.constant and opline->op2.constant https://github.com/pmmp/pthreads/blob/0f9f2db2037d9d8cfeec96e27dba837f36a40c23/src/copy.h#L231-L237
If other threads allocate many memory between allocating for literals and opcodes opline->op1.constant and opline->op2.constant value may be bigger than uint32_t.
For debug I used code 
`if (opline->op1_type == IS_CONST) {		
	uint64_t a = (zval*)(((char*)(op_array->opcodes + (opline - copy))) + (int32_t)opline->op1.constant) - literals;
	
	int64_t test = 
		(char*)(op_array->literals +
			((zval*)((char*)(op_array->opcodes + (opline - copy)) +
			(int32_t)opline->op1.constant) - literals)) -
		(char*)opline;
	opline->op1.constant = test;
	
	int64_t size_test = test > 0? test : -test;
	if (size_test > 0x7fffffff) {
		printf("opline->op1.constant bigger than uint32_t\n");
	}
	
	uint64_t a_new = (zval*)(((char*)(opline)) + (int32_t)opline->op1.constant) - op_array->literals;
	if (a_new!= a) {
		printf("opcode error %ld %ld\n", a, a_new);
	}
}`
<issue_comment>username_0: I tried allocate memory for literals and opcodes near but it doesn't help
```
void *literals_memory = safe_emalloc(op_array->last_literal, sizeof(zval), 0);
void *opcodes_memory = safe_emalloc(op_array->last, sizeof(zend_op), 0);
```
If allocate memory by one malloc it is help, but later when thread will join and memory try to free of course will be seg fault
```
void *literals_memory = malloc(sizeof(zval) * op_array->last_literal + sizeof(zend_op) * op_array->last);
void *opcodes_memory = literals_memory + sizeof(zval) * op_array->last_literal;
```
Maybe you have some ideas how to fix it
<issue_comment>username_1: The first thing that jumps out at me is that `znode_op.constant` is a `uint32_t`, but it's being casted to `int32_t` in the code you referenced. It's possible this is as simple as a basic "overflow" (addition of negative).
<issue_comment>username_1: This code originates from opcache as far as I recall, so if that isn't the solution, there may be answers in php-src.<issue_closed>By Chicago Standards, Rosty Looks Honest : Scandal: Politics in the Windy City offers an advanced class in kickbacks. Among these masters, Rostenkowski is purely minor league.
It sounds jaded, but there’s not a lot of outrage around here over Rep. Dan Rostenkowski (D-Ill.) and his House Post Office scandal. Certainly, no one is surprised. Despite his power and prestige in the Capitol--chairman of the House Ways and Means Committee and vital to passage of Bill Clinton’s economic package--at heart, he’s just another Chicago pol. Sooner or later, they all take a fall--or so it seems.
It’s not even an interesting scandal, at least by Chicago standards. Real corruption is a raw, almost sensual experience, something you can taste, touch and smell. We’re pretty selective about these things, with so much to choose from, going back to Mayor Fred A. Busse, a turn-of-the-century Republican, who owned stock in the company that, coincidentally, sold the city its manhole covers.
And then there was Alderman Tom Keane, old “squinty eyes” himself, who once said of his buddy, Mayor Richard J. Daley: “Daley wanted power, and I wanted to make money, and we both succeeded.” In the 1970s, Keane was sent to prison after he used his clout to buy almost 2,000 parcels of tax-delinquent property that he then sold, at considerable profit, to various public agencies.
In the past 20 years, about 400 people in the city have been convicted for various kickbacks, shakedowns or frauds. That includes 20-odd judges, 18 aldermen, one governor, a press aide to the first Mayor Daley, a political aide to former Mayor Harold Washington, the most recent city clerk, and countless cops, clerks and inspectors of all races, creeds and colors.
Some do it for love, trading sex for jobs, but most do it for money. It seems like there’s a different scandal every night--an endless parade of rigged bids, fixed contracts, crooked cops, convoluted land deals, building-inspection shakedowns and bought judges. One inept alderman actually paid a bribe to help two relatives pass a fire-department entrance exam. How could he not know that aldermen are supposed to take bribes, not pay them?
The feds are always running some entrapment scam. They call them “operations.” We’ve had Operation Incubator, Operation Lantern, Operation Greylord, Operation Phocus and, well, I think that’s it. You lose track after a while.
As for Rostenkowski, he’s been unofficially accused of allegedly converting about $21,300 worth of stamps (obtained free from the House Post Office). What he did, if he did it, is definitely unethical and probably illegal. I say we vote him out of office, with or without an indictment. 
But as scandals go, it’s ho-hum. It doesn’t even involve a stoolie. How can you have a scandal without a stoolie--preferably an old, bald guy, fat and sweaty, with a microphone taped to his hairy chest? A guy like Robert J. Cooley, for example. These days he’s living under a new identity in the federal witness-protection program. But in his heyday, Cooley was one of those fixers, his pockets stuffed with cash, who stalks the courthouse halls. He claimed to have bought off judges, prosecutors, court clerks and cops. He says he once bribed a judge in the restroom of a restaurant, slipping his honor $2,500 in cash (always cash, no checks--never, ever put anything in writing) to fix the murder trial of an alleged mob hit man. It doesn’t get more audacious than that.
For three years, starting in 1986, Cooley secretly recorded the pay