Memory Leak and Segfault (Exit Code 139) in Aws\ResultPaginator Due to Repeated Metrics Middleware Registration #3086
Labels
bug
This issue is a bug.
p1
This is a high priority issue
potential-regression
Marking this issue as a potential regression to be checked by team member
queued
This issues is on the AWS team's backlog
Describe the bug
Starting from version 3.336.0, the Aws\ResultPaginator class continuously adds a metrics middleware each time it is instantiated. This leads to:
• An increasing function call stack over time in long-running processes.
• High memory consumption due to repeated middleware registrations.
• In some cases, PHP crashes with exit code 139 (segmentation fault).
Regression Issue
Expected Behavior
The Aws\ResultPaginator class should not repeatedly add the metrics middleware on each instantiation. Middleware should be registered once per client lifecycle or have a mechanism to prevent redundant additions.
Current Behavior
Reproduction Steps
Steps to reproduce the behavior:
1. Run a long-running script that continuously creates Aws\ResultPaginator instances.
2. Monitor memory usage and function call stack growth.
3. Eventually, PHP may crash with exit code 139.
Possible Solution
A possible fix could involve checking if the middleware is already present before adding it again.
Additional Information/Context
Disabling the metrics middleware prevents the issue, confirming it as the root cause.
SDK version used
3.339.14
Environment details (Version of PHP (
php -v
)? OS name and version, etc.)PHP 8.3.8
The text was updated successfully, but these errors were encountered: