[Home]

Summary:ASTERISK-29934: func_channel: Invalid memory management in CHANNELS can cause a crash
Reporter:N A (InterLinked)Labels:
Date Opened:2022-02-23 06:59:50.000-0600Date Closed:2022-03-09 12:00:01.000-0600
Priority:MinorRegression?
Status:Closed/CompleteComponents:Functions/func_channel
Versions:18.9.0 Frequency of
Occurrence
One Time
Related
Issues:
Environment:Debian 10Attachments:( 0) backtrace.txt
Description:Reading the CHANNELS function can cause Asterisk to crash.

However, I can't replicate this again on the same system.
Comments:By: Asterisk Team (asteriskteam) 2022-02-23 06:59:51.371-0600

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.

Please note that by submitting data, code, or documentation to Sangoma through JIRA, you accept the Terms of Use present at [https://www.asterisk.org/terms-of-use/|https://www.asterisk.org/terms-of-use/].

By: Joshua C. Colp (jcolp) 2022-02-23 07:09:42.645-0600

You've marked this as "One Time" but in your comment you say occasionally, so did it just happen once or is this happening repeatedly? Do you have an additional backtrace from another occurrence to see if it was in the same spot?

By: Sean Bright (seanbright) 2022-02-23 09:14:06.717-0600

The line numbers in [the attached backtrace|^backtrace.txt] do not match {{funcs/func_channel.c}} from 18.9.0 - can you confirm the Asterisk version and whether or not your {{funcs/func_channel.c}} is modified?

By: N A (InterLinked) 2022-02-23 11:38:40.059-0600

> You've marked this as "One Time" but in your comment
I marked it as "one time" because I've only experienced it once. Presumably it could happen again, but it doesn't happen every time. I said occasionally as I doubt a bug really would only occur "one time", given enough time.

> The line numbers in the attached backtrace do not match
It's 18.9.0, but the file is slightly different as mine also has the TECH_EXISTS function in the file, and the XML docs for that at the top push everything else down a bit.

Line 729 on my system corresponds to the regcomp line at the bottom here, which aligns with what the backtrace contains:

```
static int func_channels_read(struct ast_channel *chan, const char *function, char *data, char *buf, size_t maxlen)
{
       struct ast_channel *c = NULL;
       regex_t re;
       int res;
       size_t buflen = 0;
       struct ast_channel_iterator *iter;

       buf[0] = '\0';

       if (!ast_strlen_zero(data)) {
               if ((res = regcomp(&re, data, REG_EXTENDED | REG_ICASE | REG_NOSUB))) {
```

By: Joshua C. Colp (jcolp) 2022-02-23 11:44:12.639-0600

Please don't say something happens occasionally if it hasn't actually happened occasionally, it causes confusion and can change the perceived impact of things.

By: Joshua C. Colp (jcolp) 2022-02-23 11:50:39.559-0600

I don't think this is the result of func_channel and CHANNELS itself. It's just the victim of memory corruption from somewhere else, which without valgrind or potentially MALLOC_DEBUG is extremely difficult to pinpoint. It could even be the same root cause as the other issue you have open.

By: Asterisk Team (asteriskteam) 2022-03-09 12:00:01.274-0600

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