# PHP Fatal error:  Interned strings buffer overflow in /var/www/html/index.php on line 0

- **ID:** `php/opcache-interned-strings-corruption`
- **Domain:** php
- **Category:** system_error
- **Verification:** ai_generated
- **Fix Rate:** 88%

## Root Cause

OPcache's interned strings buffer is too small for the total number of unique strings used across all PHP files, causing memory corruption when the buffer overflows.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| PHP 8.1.27 | active | — | — |
| PHP 8.2.15 | active | — | — |
| PHP 8.3.3 | active | — | — |

## Workarounds

1. **Increase opcache.interned_strings_buffer in php.ini from default 8 MB to 16 MB or higher, then restart PHP-FPM: sudo systemctl restart php8.2-fpm** (85% success)
   ```
   Increase opcache.interned_strings_buffer in php.ini from default 8 MB to 16 MB or higher, then restart PHP-FPM: sudo systemctl restart php8.2-fpm
   ```
2. **If the application uses many unique strings (e.g., dynamic SQL queries), reduce string duplication by using constants or shared helper functions to reuse common strings.** (75% success)
   ```
   If the application uses many unique strings (e.g., dynamic SQL queries), reduce string duplication by using constants or shared helper functions to reuse common strings.
   ```
3. **Monitor current interned strings usage with opcache_get_status()['interned_strings_usage'] and set buffer to 1.5x the peak usage.** (90% success)
   ```
   Monitor current interned strings usage with opcache_get_status()['interned_strings_usage'] and set buffer to 1.5x the peak usage.
   ```

## Dead Ends

- **** — Clearing OPcache files manually (rm -rf /tmp/opcache/) without restarting PHP-FPM often fails because the cache persists in shared memory. (60% fail)
- **** — Setting opcache.interned_strings_buffer to 0 (disable) can cause severe performance degradation and still trigger the error if any interned strings are used internally. (80% fail)
- **** — Adding more RAM to the server without adjusting the buffer size does not resolve the buffer overflow because the issue is configuration-based, not hardware-related. (90% fail)
