Comments (4)
Yes, don't put non-interned persistent strings into non-persistent hashtables (array_init creates a non-persistent hashtable), it's not permitted.
Either intern the string (in minit) or allocate a non-persistent one.
from php-src.
it's not permitted.
Two questions:
- Should this then be verified during insertion?
- Why does this work for raw (non-array) HashTables then:
HashTable array;
zend_hash_init(&array, 0, NULL, ZVAL_PTR_DTOR, 0);
zval value;
ZVAL_LONG(&value, 1);
zend_string *key = zend_string_init("foo", strlen("foo"), 1);
zend_hash_update(&array, key, &value);
zend_string_release(key);
zend_hash_destroy(&array);
I also believe this is unnecessarily restrictive. Persistent strings should outlive the request-specific array, resulting in needless duplication when using them to index the array, no?
from php-src.
Okay, to be more precise: it's not permitted for arrays exposed as zvals to userland. The zend_array_destroy()
API is used for pure runtime things.
You can do it for raw hashtables. But the goal of not permitting this is mostly so that you avoid accidentally exposing a refcounted persistent key to userland, which in threaded environments may lead to race conditions.
As long as you mutex these or keep the persistent string bound to a thread, it's fine.
from php-src.
Understood, thanks for the clarification.
from php-src.
Related Issues (20)
- Link latest sqlite3 library into php_sqlite3.dll, php_sqlite3.so HOT 4
- array_diff weirdness HOT 5
- The ldap extension cannot be built on Solaris with Oracle Instant Client HOT 19
- PCRE pattern cache crashes process in wrapper stream_close called after shutdown HOT 2
- 8.4.0alpha2 fails to build: `error: redefinition of typedef ‘zend_string’` HOT 13
- BUG : Compiling opcache extensions statically into ZTS PHP , JIT bug HOT 6
- In Czech function have bad order with diacritic HOT 11
- IntlChar::foldCase()'s $option is not optional HOT 3
- Support typed variables HOT 3
- The `IntlChar::getBidiPairedBracket()` method is not defined HOT 2
- Add support for all flags from mysql in the PDO MySql driver in the getColumnMeta function.
- php_random_default_engine() is not C++ conforming HOT 4
- PHP interpretor stops on ?> inside comment HOT 10
- _ir_RSTORE: Assertion `ctx->control' failed HOT 3
- Segmentation fault (core dumped) in ext/pgsql/tests/gh13519.phpt HOT 10
- Memory issues yield vs yield from HOT 4
- Compiling php_random_pcgoneseq128xslrr64_rotr64() triggers C4146 HOT 9
- Modifying the $value in a Property Hook setter alters the stack trace HOT 3
- Segfault / Assertion failed: (p->refcount > 0), function zend_gc_delref, file zend_types.h, line 1342 HOT 3
- Memory allocation error: pdo-odbc HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-src.