msgpack / msgpack-php

msgpack.org[PHP]
BSD 3-Clause "New" or "Revised" License
774 stars 120 forks source link

Segmentation fault when using cloned unpacker #139

Closed rybakit closed 4 years ago

rybakit commented 5 years ago

Reproducer:

$unpacker = new \MessagePackUnpacker(true);
$unpacker = clone $unpacker; // <-- this line is causing the segmentation fault error
$unpacker->feed("\xc3");
$unpacker->execute();
$data = $unpacker->data();
PHP 7.3.8 (cli) (built: Jul 30 2019 09:26:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.8, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.8, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans
rybakit commented 4 years ago

@m6w6 Is there a reason why it can't be cloneable?

m6w6 commented 4 years ago

It was just deemed too complex to copy the unpacker state to fix this issue, i.e. the crash.

You might want to create a feature request explicitly requesting clone functionality, so it won't get lost.

HTH, Mike