# zend_ts_hash_clean not thread-safe?

- Thread: https://externals.io/message/28862
- Original archive: https://news-web.php.net/php.internals/28862
- Started by Marco Cova on 2007-04-16T17:47:05+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #28862 — Marco Cova — 2007-04-16T17:47:05+00:00

URL: https://externals.io/message/28862#28862

Hi all.

It seems that zend_ts_hash_clean is not actually thread-safe: it
delegates to zend_hash_clean without first acquiring the write lock on
the hashtable.

Is this behavior an oversight (if so, should I open a bug report with
the trivial patch below?) or is this intentional?

Marco

--- zend_ts_hash.c.orig 2007-04-16 10:27:24.000000000 -0700
+++ zend_ts_hash.c      2007-04-16 10:28:44.000000000 -0700
@@ -90,8 +90,10 @@

 ZEND_API void zend_ts_hash_clean(TsHashTable *ht)
 {
+       begin_write(ht);
        ht->reader = 0;
        zend_hash_clean(TS_HASH(ht));
+       end_write(ht);
 }

 ZEND_API int _zend_ts_hash_add_or_update(TsHashTable *ht, char *arKey, uint nK
eyLength, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC
)
