Coder Social home page Coder Social logo

Comments (9)

ju1ius avatar ju1ius commented on September 22, 2024 1

IMO the ::types::array::Iter implementation should not fiddle with the hashtable internal buckets directly.
That's likely to break often and introduce safety/soundness issues.

Instead, the implementation should be refactored to use the iteration functions in Zend/zend_hash.c (i.e zend_hash_iterator_add, zend_hash_iterator_pos, zend_hash_get_current_pos, etc...).

from ext-php-rs.

ju1ius avatar ju1ius commented on September 22, 2024 1

Sounds good! Do you want to take this with a PR?

If I remember correctly, I already have a POC somewhere locally.
Just have to find the time to come back at it... 😓

In the meantime, if anyone wants to have a stab at it, one just need to look at how it's done in the C implementation for SPL's ArrayIterator.

from ext-php-rs.

ewguo avatar ewguo commented on September 22, 2024

I'm also having this issue with PHP 8.2 (fpm) but not 8.1.

from ext-php-rs.

pedrosoares avatar pedrosoares commented on September 22, 2024

Can confirm, PHP 8.1.14 works fine.

from ext-php-rs.

ptondereau avatar ptondereau commented on September 22, 2024

Hello and thanks for the report. I think this related to packed array optimization that landed in PHP 8.2.0 and I've implemented very (too?) quickly in #212

from ext-php-rs.

ptondereau avatar ptondereau commented on September 22, 2024

IMO the ::types::array::Iter implementation should not fiddle with the hashtable internal buckets directly.

That's likely to break often and introduce safety/soundness issues.

Instead, the implementation should be refactored to use the iteration functions in Zend/zend_hash.c (i.e zend_hash_iterator_add, zend_hash_iterator_pos, zend_hash_get_current_pos, etc...).

Sounds good! Do you want to take this with a PR?

from ext-php-rs.

joehoyle avatar joehoyle commented on September 22, 2024

I'm running into this too, though under PHP 8.0, not 8.2. Specifically the issue I'm seeing is given the PHP array [ 1 ], I get a segfault in some cases.

Specifically the bug is laying in https://github.com/davidcole1340/ext-php-rs/blob/master/src/types/array.rs#L538. In some cases (I don't know why), though the Array has 1 item (nNumOfElements == 1), nNumUsed is set to two. The end is then miscalculated to be an offset beyond (I guess) the end of the array. That in turn means the bucket.key reference is set to 0xffffffffffffffff, which cases a segfault when calling trying to call ext_php_rs_is_known_valid_utf8 on that invalid pointer reference.

from ext-php-rs.

AdrienGras avatar AdrienGras commented on September 22, 2024

Hi,

Any update on this ? I'm also having issues with PHP 8.2.4, but everything is fine with PHP 8.1

from ext-php-rs.

ptondereau avatar ptondereau commented on September 22, 2024

Hi,

Any update on this ? I'm also having issues with PHP 8.2.4, but everything is fine with PHP 8.1

I don't have any room to work on it for the moment but I'm available to do reviews if someone is up.

from ext-php-rs.

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.