[Home]

Summary:ASTERISK-28095: func_odbc: Crash when calling an ODBC function from another ODBC function
Reporter:Niksa Baldun (niksa)Labels:
Date Opened:2018-10-07 07:55:06Date Closed:
Priority:MinorRegression?
Status:Open/NewComponents:Functions/func_odbc
Versions:16.0.0 Frequency of
Occurrence
Constant
Related
Issues:
Environment:Attachments:( 0) core-ASTERISK-28095-results.tar.gz
Description:Steps to reproduce:

Create the following database table (I am using Postgres, but the database server is likely irrelevant):

{code:sql}
CREATE TABLE setting (
   name text NOT NULL,
   value text NOT NULL,
   CONSTRAINT setting_unique UNIQUE (name)
);
{code}

Put the following in func_odbc.conf:

{code:sql}
[GET]
prefix=SETTING
dsn=PBX
readsql=SELECT value FROM setting WHERE name = '${ARG1}'

[RESOLVE]
prefix=SETTING
dsn=PBX
readsql=SELECT '${SETTING_GET(${ARG1})}' AS value
{code}

When you call {noformat}${SETTING_RESOLVE(somesetting)}{noformat} from dialplan, Asterisk crashes. Calling one function from another may or may not make sense, but I think Asterisk should not crash even if this is not supported.
Comments:By: Asterisk Team (asteriskteam) 2018-10-07 07:55:08.410-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.

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].

By: Richard Mudgett (rmudgett) 2018-10-08 10:18:51.718-0500

Thank you for the crash report. However, we need more information to investigate the crash. Please provide:

1. A backtrace generated from a core dump using the instructions provided on the Asterisk wiki [1].
2. Specific steps taken that lead to the crash.
3. All configuration information necesary to reproduce the crash.

Thanks!

[1]: https://wiki.asterisk.org/wiki/display/AST/Getting+a+Backtrace



By: Niksa Baldun (niksa) 2018-10-08 14:44:15.391-0500

I have attached a backtrace. As for information needed to reproduce the crash, I believe it is included in original report. The crash is easy to reproduce. Create an ODBC function that reads anything from any table, create a second ODBC function that uses the first function in SELECT clause, and then call the second function from anywhere within dialplan.

By: Richard Mudgett (rmudgett) 2018-10-08 17:09:33.799-0500

I see what's going on.  We have thread local storage buffers that are being used recursively in this case.  When the internal ODBC function returns the code doesn't know that the outer buffer data is stale and we crash.  We'll definitely need a buffer for each ODBC function invocation.

I'm acknowledging the issue.