If you attended https://event.afup.org/afup-day-2022/programme/#3875, you might know that I am currently working on a PHP module for web servers written in Go. While testing my upcoming library, I encountered strange memory access issues related to the threads created by the Go runtime (https://dave.cheney.net/2016/01/18/cgo-is-not-go…

This behavior is incompatible with C code that relies on https://en.wikipedia.org/wiki/Thread-local_storage, such as http://blog.jpauli.tech/2017-01-12-threads-and-php-html/.

Let’s write a test program to understand how runtime.LockOSThread() works, and if the system really reuses thread IDs: // This Go program demonstrates the behavior of runtime.LockOSThread() and runtime.UnlockOSThread().

// To prove this, we store used thread IDs in a global variable, and some data in each local thread using pthread_setspecific().
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners