Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when parsing a certain file #396

Open
danog opened this issue Mar 9, 2020 · 1 comment
Open

Crash when parsing a certain file #396

danog opened this issue Mar 9, 2020 · 1 comment
Labels

Comments

@danog
Copy link

danog commented Mar 9, 2020

Code:

<?php

namespace Amp;

class InvalidYieldError extends \Error
{
    /**
     * @param \Generator      $generator
     * @param string          $prefix
     * @param \Throwable|null $previous
     */
    public function __construct(\Generator $generator, string $prefix, \Throwable $previous = null)
    {
        $yielded = $generator->current();
        $prefix .= \sprintf(
            "; %s yielded at key %s",
            \is_object($yielded) ? \get_class($yielded) : \gettype($yielded),
            \var_export($generator->key(), true)
        );

        if (!$generator->valid()) {
            parent::__construct($prefix, 0, $previous);
            return;
        }

        $reflGen = new \ReflectionGenerator($generator);
        $exeGen = $reflGen->getExecutingGenerator();
        if ($isSubgenerator = ($exeGen !== $generator)) {
            $reflGen = new \ReflectionGenerator($exeGen);
        }

        parent::__construct(\sprintf(
            "%s on line %s in %s",
            $prefix,
            $reflGen->getExecutingLine(),
            $reflGen->getExecutingFile()
        ), 0, $previous);
    }
}

Result:

-> linux
-> app:run 
-> install 
java.lang.VerifyError: Bad local variable type
Exception Details:
  Location:
    $php_module_mcc0782e8f2e946d88c66d7d1912b91a2_class0.__construct$0(Lphp/runtime/env/Environment;[Lphp/runtime/Memory;)Lphp/runtime/Memory; @400: aload
  Reason:
    Type top (current frame, locals[10]) is not assignable to reference type
  Current Frame:
    bci: @400
    flags: { }
    locals: { '$php_module_mcc0782e8f2e946d88c66d7d1912b91a2_class0', 'php/runtime/env/Environment', '[Lphp/runtime/Memory;', 'php/runtime/Memory', 'php/runtime/memory/ReferenceMemory', 'php/runtime/memory/ReferenceMemory', 'php/runtime/Memory', 'php/runtime/Memory', 'php/runtime/memory/ReferenceMemory', 'php/runtime/Memory' }
    stack: { }
  Bytecode:
    0x0000000: b200 354e 2c03 3259 4ec7 0007 b200 354e
    0x0000010: bb00 3759 b700 3a3a 042c 0432 1904 b800
    0x0000020: 3ec7 000c b200 3519 04b8 003e 57bb 0037
    0x0000030: 59b7 003a 3a05 2c05 3219 05b8 003e c700
    0x0000040: 0cb2 0035 1905 b800 3e57 b200 353a 06b2
    0x0000050: 0035 3a07 bb00 3759 b700 3a3a 08b2 0035
    0x0000060: 3a09 2d12 4012 402b b200 4203 3201 b800
    0x0000070: 48b8 004c 1908 b800 3e57 1904 2bb2 0042
    0x0000080: 0432 124e 05bd 0031 5903 1908 b800 5499
    0x0000090: 0014 2bb2 0042 0532 1908 b600 58b8 005c
    0x00000a0: a700 0e19 08b6 0058 b800 60b8 0066 b800
    0x00000b0: 4c53 5904 2bb2 0042 0632 2d12 6812 682b
    0x00000c0: b200 4207 3201 b800 4804 b800 6e53 b800
    0x00000d0: 74b6 0077 572d 1279 1279 2bb2 0042 0832
    0x00000e0: 01b8 0048 b600 7d99 0045 2ab9 0082 0100
    0x00000f0: 9900 0bb2 0085 3a0a a700 092a b800 8a3a
    0x0000100: 0a19 0a12 8c12 8c2b b200 4212 8d32 06bd
    0x0000110: 0031 5903 1904 5359 04b2 008f 0332 5359
    0x0000120: 0519 0553 b800 9257 b200 85b0 2b12 9412
    0x0000130: 96b2 0042 1297 3204 bd00 3159 032d 53b2
    0x0000140: 0099 03b6 009f 3a07 1907 12a1 12a3 2bb2
    0x0000150: 0042 12a4 3201 b800 48b8 004c 3a09 1909
    0x0000160: 2db8 004c b600 a7b8 00ac 593a 06b6 00af
    0x0000170: 9900 202b 1294 1296 b200 4212 b032 04bd
    0x0000180: 0031 5903 1909 53b2 0099 04b6 009f 3a07
    0x0000190: 190a 128c 128c 2bb2 0042 12b1 3206 bd00
    0x00001a0: 3159 032b b200 4212 b232 12b4 06bd 0031
    0x00001b0: 5903 1904 b800 4c53 5904 1907 12b6 12b8
    0x00001c0: 2bb2 0042 12b9 3201 b800 48b8 004c 5359
    0x00001d0: 0519 0712 bb12 bd2b b200 4212 be32 01b8
    0x00001e0: 0048 b800 4c53 b800 7453 5904 b200 8f04
    0x00001f0: 3253 5905 1905 53b8 0092 57b2 0085 b0  
  Stackmap Table:
    append_frame(@16,Object[#49])
    append_frame(@45,Object[#55])
    append_frame(@74,Object[#55])
    full_frame(@163,{Object[#2],Object[#155],Object[#200],Object[#49],Object[#55],Object[#55],Object[#49],Object[#49],Object[#55],Object[#49]},{Object[#55],Object[#155],Object[#202],Object[#204],Object[#200],Object[#200],Integer})
    full_frame(@174,{Object[#2],Object[#155],Object[#200],Object[#49],Object[#55],Object[#55],Object[#49],Object[#49],Object[#55],Object[#49]},{Object[#55],Object[#155],Object[#202],Object[#204],Object[#200],Object[#200],Integer,Object[#49]})
    same_frame_extended(@251)
    append_frame(@257,Object[#49])
    chop_frame(@300,1)
    same_frame_extended(@400)

	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
	at java.lang.Class.getConstructor0(Class.java:3075)
	at java.lang.Class.getConstructor(Class.java:1825)
	at php.runtime.reflection.ClassEntity.setNativeClazz(ClassEntity.java:855)
	at php.runtime.loader.RuntimeClassLoader.loadClass(RuntimeClassLoader.java:55)
	at php.runtime.loader.RuntimeClassLoader.loadModule(RuntimeClassLoader.java:113)
	at php.runtime.env.CompileScope.loadModule(CompileScope.java:599)
	at php.runtime.env.CompileScope.loadModule(CompileScope.java:603)
	at php.runtime.env.Environment.importModule(Environment.java:1253)
	at php.runtime.env.ConcurrentEnvironment.importModule(ConcurrentEnvironment.java:175)
	at php.runtime.env.ModuleManager.fetchTemporaryModule(ModuleManager.java:71)
	at php.runtime.env.ModuleManager.fetchModule(ModuleManager.java:41)
	at php.runtime.env.ModuleManager.fetchModule(ModuleManager.java:27)
	at php.runtime.launcher.Launcher.loadFrom(Launcher.java:121)
	at php.runtime.launcher.Launcher.run(Launcher.java:308)
	at php.runtime.launcher.Launcher.run(Launcher.java:247)
	at php.runtime.launcher.Launcher.run(Launcher.java:243)
	at php.runtime.launcher.Launcher.main(Launcher.java:425)
@dim-s dim-s added the bug label Mar 9, 2020
@dim-s
Copy link
Member

dim-s commented Mar 9, 2020

The same error:

class InvalidYieldError
{
    public function construct()
    {
        $prefix = true;

        if ($prefix) {
            parent::construct();
        }

        parent::construct();
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants