Giter Site home page Giter Site logo

Segfault 5.5.6 about msgpack-php HOT 7 CLOSED

msgpack avatar msgpack commented on July 1, 2024
Segfault 5.5.6

from msgpack-php.

Comments (7)

laruence avatar laruence commented on July 1, 2024

are you able to provide a small reproduce script?

from msgpack-php.

joeyhub avatar joeyhub commented on July 1, 2024

I am trying to ;). I have 5.5.5 and 5.5.6 compiled. Will update when I find a way to trigger it again.

from msgpack-php.

joeyhub avatar joeyhub commented on July 1, 2024
mkdir issue_49
cd issue_49

wget https://pecl.php.net/get/msgpack-0.5.{5,6}.tgz
for v in 5 6
do
 tar -xvzf msgpack-0.5.$v.tgz
 cd msgpack-0.5.$v
 phpize
 ./configure
 make
 cd ..
 php -n -dextension=msgpack-0.5.$v/modules/msgpack.so\
  -r 'echo msgpack_pack([["item"=>["obj"=>(object)["y" => "YYYYYYY"],"str" =>["x" => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"]]]]);'\
  > msgpack$v
done

php -n -dextension=msgpack-0.5.5/modules/msgpack.so\
 -r "msgpack_unpack(file_get_contents("msgpack6"));"

Enjoy :).

from msgpack-php.

joeyhub avatar joeyhub commented on July 1, 2024

In some cases I also get a message about bad msgpack structure.

For example... ["item"=>["str" =>["x" => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"]]] gives:

Warning: msgpack Parse error in Command line code on line 1

from msgpack-php.

joeyhub avatar joeyhub commented on July 1, 2024

It's the str8, you added encode support in the last revision. This shaves a byte for strings < 256.

# cat msgpack5 | xxd
0000000: 9181 a469 7465 6d82 a36f 626a 82c0 a873  ...item..obj...s
0000010: 7464 436c 6173 73a1 79a7 5959 5959 5959  tdClass.y.YYYYYY
0000020: 59a3 7374 7281 a178 da00 3658 5858 5858  Y.str..x..6XXXXX
0000030: 5858 5858 5858 5858 5858 5858 5858 5858  XXXXXXXXXXXXXXXX
0000040: 5858 5858 5858 5858 5858 5858 5858 5858  XXXXXXXXXXXXXXXX
0000050: 5858 5858 5858 5858 5858 5858 5858 5858  XXXXXXXXXXXXXXXX
0000060: 58                                       X
# cat msgpack6 | xxd
0000000: 9181 a469 7465 6d82 a36f 626a 82c0 a873  ...item..obj...s
0000010: 7464 436c 6173 73a1 79a7 5959 5959 5959  tdClass.y.YYYYYY
0000020: 59a3 7374 7281 a178 d936 5858 5858 5858  Y.str..x.6XXXXXX
0000030: 5858 5858 5858 5858 5858 5858 5858 5858  XXXXXXXXXXXXXXXX
0000040: 5858 5858 5858 5858 5858 5858 5858 5858  XXXXXXXXXXXXXXXX
0000050: 5858 5858 5858 5858 5858 5858 5858 5858  XXXXXXXXXXXXXXXX

da (str16) to d9 (str8)

So 0.5.5 compatibility is broken but also it should not really segfault either :(.

When making such a change I really think it would be a good idea to attribute it to a less minor version component.

That is, 5.5.6 should be 5.6.0.

from msgpack-php.

Sean-Der avatar Sean-Der commented on July 1, 2024

Hey @laruence when looking at implementing this I think I have two options. I need to add a conditional on https://github.com/msgpack/msgpack-php/blob/master/msgpack/pack_template.h#L733 I have two ideas on how I could accomplish this. Either way I have to edit this 'upstream' header file. (I would like to avoid this, but it seems like other implementations are doing the same thing?)

I could either make msgpack_pack_user a struct that contains the zend_string and a boolean use_str8_serialization
OR
just put a call to MSGPACK_G(use_str8_serialization)

Also what do you think of the STD_PHP_INI_BOOLEAN name use_str8_serialization

from msgpack-php.

Sean-Der avatar Sean-Der commented on July 1, 2024

Hey!

The msgpack spec calls for a compatibility mode so serialization doesn't create data that older deserializers can't handle.
You can see that in action here

@joeyhub
So the segfault is no good, but there isn't anything we can do in the old versions. I will however check and make sure that this segfault doesn't occur for any other 'first bytes'!

@mattheworiordan
Just a heads up this is done! Looking at the issue you posted you hopefully should be unblocked, but also super happy to tackle anything you throw my way :)

thanks.

from msgpack-php.

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.