Skip to content

Instantly share code, notes, and snippets.

@TysonAndre
Created May 10, 2020
Embed
What would you like to do?
Opcache jit_debug crash
<?php
// Crashes with USE_ZEND_ALLOC=0 valgrind `which php` -d opcache.protect_memory=1 -d opcache.file_cache= -d opcache.enable_cli=1 -d opcache.jit=1235 -d opcache.jit_buffer_size=20M -d opcache.jit_debug=2 example.php
// For php-src 8.0 built on 2020-05-10 commit b452d5923de3bfef3268bcea289d59d6bc789437 with NTS (debug or non-debug)
class FullyQualifiedGlobalStructuralElement
{
public static function make(
string $namespace,
string $name
) {
$name_parts = \explode('\\', $name);
foreach ($name_parts as $i => $part) {
$namespace .= '\\' . $part;
}
$namespace = self::cleanNamespace($namespace);
return \rtrim($namespace);
}
protected static function cleanNamespace(string $namespace): string { return $namespace; }
// This isn't even called, but the crash doesn't happen without it
public static function memoizeStatic($key, $closure) { static $cache; return $cache[$key] ?? ($cache[$key] = $closure()); }
}
// This isn't even used, but the crash doesn't happen without it
class MyExample extends FullyQualifiedGlobalStructuralElement {
protected static function getNamespaceMapType(): int { return 0; }
public static function canonicalLookupKey($name) {
return strtoupper($name);
}
}
for ($i = 0; $i < 10; $i++) {
for ($j = 0; $j < 10; $j++) {
FullyQualifiedGlobalStructuralElement::make("\\", "v$i", 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment