[Home]

Summary:ASTERISK-29049: Memory Leak caused by fix for ASTERISK-28445
Reporter:Bernhard Schmidt (bschmidt)Labels:
Date Opened:2020-08-27 08:07:54Date Closed:2020-09-10 12:00:01
Priority:MajorRegression?Yes
Status:Closed/CompleteComponents:pjproject/pjsip
Versions:16.2.1 Frequency of
Occurrence
Constant
Related
Issues:
is related toASTERISK-28445 res_pjsip_session: ast_json_vpack: Invalid UTF-8 string on hangup when TEST_FRAMEWORK enabled
Environment:Attachments:( 0) Screenshot_20200827_152027.png
Description:I'm not exactly sure whether this affects recent versions where the patch has been merged upstream as well, I can't test that due to ASTERISK-29017 . But I haven't found any subsequent fixes so I think it is quite likely.

In ASTERISK-28445 a one-line fix has been proposed and merged to fix a use-after-free in res_pjsip_session. Backporting this to 16.2.1 in Debian  the fix is leaking memory. Since the patch only changes one line to ast_strdupa a variable but doesn't free it anywhere that's probably the root cause.

https://github.com/asterisk/asterisk/commit/fbc80db350ee006cdebcb113a6daf60f95c8851d#diff-abd0465e5ff1c7907e3b8826ce1dde80
Comments:By: Asterisk Team (asteriskteam) 2020-08-27 08:07:55.339-0500

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution. Please note that log messages and other files should not be sent to the Sangoma Asterisk Team unless explicitly asked for. All files should be placed on this issue in a sanitized fashion as needed.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur.

By: Joshua C. Colp (jcolp) 2020-08-27 08:14:42.388-0500

The ast_strdupa function is a wrapper around strdupa. This function does not require freeing, as it uses alloca underneath. The alloca function allocates from the stack and is automatically freed when the function exits. If you're experiencing a leak, it is unlikely this is the cause unless the alloca implementation is for some reason not adhering to the way it is supposed to behave.

By: Bernhard Schmidt (bschmidt) 2020-08-27 08:20:22.090-0500

Hum, okay ... I had prepared a stable update for Debian with the patches for AST-2019-004, -006, -007, ASTERISK-28854 and ASTERISK-28445. This build is leaking memory heavily. ASTERISK-28445 was the first guess. I'm now running a build with this patch backed out, I will keep searching until I find the exact culprit.

Sorry for the noise.

By: Bernhard Schmidt (bschmidt) 2020-08-27 08:21:10.814-0500

Memory Leak

By: Asterisk Team (asteriskteam) 2020-09-10 12:00:01.340-0500

Suspended due to lack of activity. This issue will be automatically re-opened if the reporter posts a comment. If you are not the reporter and would like this re-opened please create a new issue instead. If the new issue is related to this one a link will be created during the triage process. Further information on issue tracker usage can be found in the Asterisk Issue Guidlines [1].

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines