Skip to content

Memory corruption issues #2280

@pzhang-zg

Description

@pzhang-zg

What happened?

We're building a new service on top of FrankenPHP.
Around the time of the 1.11.2 security update, we realized that our containers have been crashing at irregular intervals, and the various logging messages indicated some kind of low level memory corruption. At the time we were upgrading from 1.9.0 and similar memory corruption logs were being logged from the previous version.

The various error messages we were seeing include:

  • malloc_consolidate(): unaligned fastbin chunk detected
  • Out of memory
  • zend_mm_heap corrupted
  • malloc(): unaligned tcache chunk detected
  • memory allocation of [3275089422124871200-8245929725132762100] bytes failed
  • double free or corruption (fasttop)

We also noticed that some logs seemed to have been interleaved as well:

  • memory allocation of memory allocation of [78096346336516770000000000000000000000-78817066060829420000000000000000000000] bytes failed
  • bytes failed
  • 7881706606082942000 bytes failed

Our app is still fairly new and does not currently deal with a heavy amount of traffic, but we've been unable to determine a direct cause for the conditions leading up to these memory corruption related crashes. We've tried disabling Datadog's tracing and profiling as well as disabling opcache, but these crashes seem to persist.

Crashes seem to vary pretty wildly in frequency, a 12 hour period having between roughly 0-20 crashes (the extreme ends being less common), with no noticeable correlation to time of day/week.

Build Type

Docker (Debian Trixie)

Worker Mode

No

Operating System

GNU/Linux

CPU Architecture

x86_64

PHP configuration

phpinfo() output
System 	Linux 6.12.68-92.122.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Feb 9 10:43:10 UTC 2026 x86_64
Build Date 	Feb 3 2026 02:28:00
Build System 	Linux - Docker
Build Provider 	https://github.com/docker-library/php
Configure Command 	'./configure' '--build=x86_64-linux-gnu' '--sysconfdir=/usr/local/etc' '--with-config-file-path=/usr/local/etc/php' '--with-config-file-scan-dir=/usr/local/etc/php/conf.d' '--enable-option-checking=fatal' '--with-mhash' '--with-pic' '--enable-mbstring' '--enable-mysqlnd' '--with-password-argon2' '--with-sodium=shared' '--with-pdo-sqlite=/usr' '--with-sqlite3=/usr' '--with-curl' '--with-iconv' '--with-openssl' '--with-readline' '--with-zlib' '--enable-phpdbg' '--enable-phpdbg-readline' '--with-pear' '--with-libdir=lib/x86_64-linux-gnu' '--enable-embed' '--enable-zts' '--disable-zend-signals' 'build_alias=x86_64-linux-gnu' 'PHP_UNAME=Linux - Docker' 'PHP_BUILD_PROVIDER=https://github.com/docker-library/php'
Server API 	FrankenPHP
Virtual Directory Support 	enabled
Configuration File (php.ini) Path 	/usr/local/etc/php
Loaded Configuration File 	/usr/local/etc/php/php.ini
Scan this dir for additional .ini files 	/usr/local/etc/php/conf.d
Additional .ini files parsed 	/usr/local/etc/php/conf.d/98-ddtrace.ini, /usr/local/etc/php/conf.d/docker-php-ext-awscrt.ini, /usr/local/etc/php/conf.d/docker-php-ext-bcmath.ini, /usr/local/etc/php/conf.d/docker-php-ext-pcntl.ini, /usr/local/etc/php/conf.d/docker-php-ext-pdo_pgsql.ini, /usr/local/etc/php/conf.d/docker-php-ext-redis.ini, /usr/local/etc/php/conf.d/docker-php-ext-sockets.ini, /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini, /usr/local/etc/php/conf.d/docker-php-ext-zip.ini
PHP API 	20250925
PHP Extension 	20250925
Zend Extension 	420250925
Zend Extension Build 	API420250925,TS
PHP Extension Build 	API20250925,TS
PHP Integer Size 	64 bits
Debug Build 	no
Thread Safety 	enabled
Thread API 	POSIX Threads
Zend Signal Handling 	disabled
Zend Memory Manager 	disabled
Zend Multibyte Support 	provided by mbstring
Zend Max Execution Timers 	enabled
IPv6 Support 	enabled
DTrace Support 	disabled
Registered PHP Streams	https, ftps, compress.zlib, php, file, glob, data, http, ftp, phar, zip
Registered Stream Socket Transports	tcp, udp, unix, udg, ssl, tls, tlsv1.0, tlsv1.1, tlsv1.2, tlsv1.3
Registered Stream Filters	zlib.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, convert.*, consumed, dechunk


Configuration
awscrt
Version 	1.2.7
Directive	Local Value	Master Value
awscrt.log_level	no value	no value
bcmath
BCMath support 	enabled
Directive	Local Value	Master Value
bcmath.scale	0	0

Core
PHP Version 	8.5.2
Directive	Local Value	Master Value
allow_url_fopen	On	On
allow_url_include	Off	Off
arg_separator.input	&	&
arg_separator.output	&	&
auto_append_file	no value	no value
auto_globals_jit	On	On
auto_prepend_file	no value	no value
browscap	no value	no value
default_charset	UTF-8	UTF-8
default_mimetype	text/html	text/html
disable_functions	no value	no value
display_errors	On	On
display_startup_errors	On	On
doc_root	no value	no value
docref_ext	no value	no value
docref_root	no value	no value
enable_dl	On	On
enable_post_data_reading	On	On
error_append_string	no value	no value
error_log	no value	no value
error_log_mode	0644	0644
error_prepend_string	no value	no value
error_reporting	no value	no value
expose_php	Off	Off
extension_dir	/usr/local/lib/php/extensions/no-debug-zts-20250925	/usr/local/lib/php/extensions/no-debug-zts-20250925
fatal_error_backtraces	On	On
fiber.stack_size	no value	no value
file_uploads	On	On
hard_timeout	2	2
highlight.comment	#FF8000	#FF8000
highlight.default	#0000BB	#0000BB
highlight.html	#000000	#000000
highlight.keyword	#007700	#007700
highlight.string	#DD0000	#DD0000
html_errors	On	On
ignore_repeated_errors	Off	Off
ignore_repeated_source	Off	Off
ignore_user_abort	Off	Off
implicit_flush	Off	Off
include_path	.:/usr/local/lib/php	.:/usr/local/lib/php
input_encoding	no value	no value
internal_encoding	no value	no value
log_errors	Off	Off
mail.add_x_header	Off	Off
mail.cr_lf_mode	crlf	crlf
mail.force_extra_parameters	no value	no value
mail.log	no value	no value
mail.mixed_lf_and_crlf	Off	Off
max_execution_time	30	30
max_file_uploads	20	20
max_input_nesting_level	64	64
max_input_time	5	5
max_input_vars	1000	1000
max_memory_limit	-1	-1
max_multipart_body_parts	-1	-1
memory_limit	512M	512M
open_basedir	no value	no value
output_buffering	0	0
output_encoding	no value	no value
output_handler	no value	no value
post_max_size	8M	8M
precision	14	14
realpath_cache_size	16M	16M
realpath_cache_ttl	360	360
register_argc_argv	Off	Off
report_memleaks	On	On
report_zend_debug	Off	Off
request_order	no value	no value
sendmail_from	no value	no value
sendmail_path	/usr/sbin/sendmail -t -i	/usr/sbin/sendmail -t -i
serialize_precision	-1	-1
short_open_tag	On	On
SMTP	localhost	localhost
smtp_port	25	25
sys_temp_dir	no value	no value
syslog.facility	LOG_USER	LOG_USER
syslog.filter	no-ctrl	no-ctrl
syslog.ident	php	php
unserialize_callback_func	no value	no value
upload_max_filesize	2M	2M
upload_tmp_dir	no value	no value
user_dir	no value	no value
user_ini.cache_ttl	300	300
user_ini.filename	.user.ini	.user.ini
variables_order	EGPCS	EGPCS
xmlrpc_error_number	0	0
xmlrpc_errors	Off	Off
zend.assertions	1	1
zend.detect_unicode	On	On
zend.enable_gc	On	On
zend.exception_ignore_args	Off	Off
zend.exception_string_param_max_len	15	15
zend.max_allowed_stack_size	0	0
zend.multibyte	Off	Off
zend.reserved_stack_size	0	0
zend.script_encoding	no value	no value

ctype
ctype functions 	enabled
curl
cURL support 	enabled
cURL Information 	8.14.1
Age 	11
Features
AsynchDNS 	Yes
CharConv 	No
Debug 	No
GSS-Negotiate 	No
IDN 	Yes
IPv6 	Yes
krb4 	No
Largefile 	Yes
libz 	Yes
NTLM 	Yes
NTLMWB 	No
SPNEGO 	Yes
SSL 	Yes
SSPI 	No
TLS-SRP 	Yes
HTTP2 	Yes
GSSAPI 	Yes
KERBEROS5 	Yes
UNIX_SOCKETS 	Yes
PSL 	Yes
HTTPS_PROXY 	Yes
MULTI_SSL 	No
BROTLI 	Yes
ALTSVC 	Yes
HTTP3 	Yes
UNICODE 	No
ZSTD 	Yes
HSTS 	Yes
GSASL 	No
Protocols 	dict, file, ftp, ftps, gopher, gophers, http, https, imap, imaps, ldap, ldaps, mqtt, pop3, pop3s, rtmp, rtmpe, rtmps, rtmpt, rtmpte, rtmpts, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp, ws, wss
Host 	x86_64-pc-linux-gnu
SSL Version 	OpenSSL/3.5.4
ZLib Version 	1.3.1
libSSH Version 	libssh2/1.11.1
Directive	Local Value	Master Value
curl.cainfo	no value	no value
datadog-profiling
Version 	1.16.0
Profiling Enabled 	true
Profiling Experimental Features Enabled 	false
Experimental CPU Time Profiling Enabled 	true
Allocation Profiling Enabled 	true
Timeline Enabled 	true
Exception Profiling Enabled 	true
I/O Profiling Enabled 	false
Endpoint Collection Enabled 	true
Platform's CPU Time API Works 	true
Profiling Log Level 	off
Profiling Agent Endpoint 	unix:///var/run/datadog/apm.socket

Directive	Local Value	Master Value
datadog.profiling.allocation_enabled	On	On
datadog.profiling.allocation_sampling_distance	4194304	4194304
datadog.profiling.enabled	On	On
datadog.profiling.endpoint_collection_enabled	On	On
datadog.profiling.exception_enabled	On	On
datadog.profiling.exception_message_enabled	Off	Off
datadog.profiling.exception_sampling_distance	100	100
datadog.profiling.experimental_allocation_enabled	On	On
datadog.profiling.experimental_cpu_enabled	On	On
datadog.profiling.experimental_cpu_time_enabled	On	On
datadog.profiling.experimental_exception_enabled	On	On
datadog.profiling.experimental_exception_sampling_distance	100	100
datadog.profiling.experimental_features_enabled	Off	Off
datadog.profiling.experimental_io_enabled	Off	Off
datadog.profiling.experimental_timeline_enabled	On	On
datadog.profiling.log_level	off	off
datadog.profiling.output_pprof	no value	no value
datadog.profiling.timeline_enabled	On	On
datadog.profiling.walltime_enabled	On	On

Zend OPcache
Opcode Caching 	Up and Running
Optimization 	Enabled
SHM Cache 	Enabled
File Cache 	Disabled
JIT 	Disabled
Startup 	OK
Shared memory model 	mmap
Cache hits 	1888559
Cache misses 	761
Used memory 	-232594744
Free memory 	232594744
Wasted memory 	0
Interned Strings Used memory 	8434496
Interned Strings Free memory 	8342720
Cached scripts 	756
Cached keys 	1448
Max keys 	32531
OOM restarts 	0
Hash keys restarts 	0
Manual restarts 	0
Start time 	2026-03-13T14:19:23+0000
Last restart time 	none
Last force restart time 	none
Directive	Local Value	Master Value
opcache.blacklist_filename	no value	no value
opcache.dups_fix	Off	Off
opcache.enable	On	On
opcache.enable_cli	On	On
opcache.enable_file_override	Off	Off
opcache.error_log	no value	no value
opcache.file_cache	no value	no value
opcache.file_cache_consistency_checks	On	On
opcache.file_cache_only	Off	Off
opcache.file_cache_read_only	Off	Off
opcache.file_update_protection	0	0
opcache.force_restart_timeout	180	180
opcache.huge_code_pages	Off	Off
opcache.interned_strings_buffer	16	16
opcache.jit	disable	disable
opcache.jit_bisect_limit	0	0
opcache.jit_blacklist_root_trace	16	16
opcache.jit_blacklist_side_trace	8	8
opcache.jit_buffer_size	128M	128M
opcache.jit_debug	0	0
opcache.jit_hot_func	127	127
opcache.jit_hot_loop	61	61
opcache.jit_hot_return	8	8
opcache.jit_hot_side_exit	8	8
opcache.jit_max_exit_counters	8192	8192
opcache.jit_max_loop_unrolls	8	8
opcache.jit_max_polymorphic_calls	2	2
opcache.jit_max_recursive_calls	2	2
opcache.jit_max_recursive_returns	2	2
opcache.jit_max_root_traces	2048	2048
opcache.jit_max_side_traces	256	256
opcache.jit_max_trace_length	1024	1024
opcache.jit_prof_threshold	0.001	0.001
opcache.lockfile_path	/tmp	/tmp
opcache.log_verbosity_level	1	1
opcache.max_accelerated_files	32531	32531
opcache.max_file_size	0	0
opcache.max_wasted_percentage	5	5
opcache.memory_consumption	256M	256M
opcache.opt_debug_level	0	0
opcache.optimization_level	0x7FFEBFFF	0x7FFEBFFF
opcache.preferred_memory_model	no value	no value
opcache.preload	no value	no value
opcache.preload_user	no value	no value
opcache.protect_memory	Off	Off
opcache.record_warnings	Off	Off
opcache.restrict_api	no value	no value
opcache.revalidate_freq	2	2
opcache.revalidate_path	Off	Off
opcache.save_comments	On	On
opcache.use_cwd	Off	Off
opcache.validate_permission	Off	Off
opcache.validate_root	Off	Off
opcache.validate_timestamps	Off	Off

Relevant log output

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions