[asterisk-commits] sgriepentrog: branch certified-11.6 r404349 - in /certified/branches/11.6: ./...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Dec 19 10:38:53 CST 2013


Author: sgriepentrog
Date: Thu Dec 19 10:38:50 2013
New Revision: 404349

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=404349
Log:
astdb: crash in sqlite3 during shutdown

When Asterisk is shut down, the astdb_atexit() function releases
(finalize) the previously initiated (prepared) SQL statements in
sqlite3.  Another thread making a subsequent request can cause a
crash in sqlite3.  This patch eliminates that issue by resetting
the statement pointer after it is released/cleared.  The sqlite3
code detects the null pointer, and aborts the operation cleanly.

(closes issue AST-1265)
Reported by: Alexander Hömig
(closes issue ASTERISK-22350)
Reported by: Birger "WIMPy" Harzenetter
Review: https://reviewboard.asterisk.org/r/3078/
........

Merged revisions 404344 from http://svn.asterisk.org/svn/asterisk/branches/11

Modified:
    certified/branches/11.6/   (props changed)
    certified/branches/11.6/main/db.c

Propchange: certified/branches/11.6/
------------------------------------------------------------------------------
--- branch-11-merged (original)
+++ branch-11-merged Thu Dec 19 10:38:50 2013
@@ -1,1 +1,1 @@
-/branches/11:396884,399513,400075-400093,401446,401960,402450,403917
+/branches/11:396884,399513,400075-400093,401446,401960,402450,403917,404344

Modified: certified/branches/11.6/main/db.c
URL: http://svnview.digium.com/svn/asterisk/certified/branches/11.6/main/db.c?view=diff&rev=404349&r1=404348&r2=404349
==============================================================================
--- certified/branches/11.6/main/db.c (original)
+++ certified/branches/11.6/main/db.c Thu Dec 19 10:38:50 2013
@@ -145,12 +145,14 @@
  * \brief Clean up the prepared SQLite3 statement
  * \note dblock should already be locked prior to calling this method
  */
-static int clean_stmt(sqlite3_stmt *stmt, const char *sql)
-{
-	if (sqlite3_finalize(stmt) != SQLITE_OK) {
+static int clean_stmt(sqlite3_stmt **stmt, const char *sql)
+{
+	if (sqlite3_finalize(*stmt) != SQLITE_OK) {
 		ast_log(LOG_WARNING, "Couldn't finalize statement '%s': %s\n", sql, sqlite3_errmsg(astdb));
+		*stmt = NULL;
 		return -1;
 	}
+	*stmt = NULL;
 	return 0;
 }
 
@@ -160,15 +162,15 @@
  */
 static void clean_statements(void)
 {
-	clean_stmt(get_stmt, get_stmt_sql);
-	clean_stmt(del_stmt, del_stmt_sql);
-	clean_stmt(deltree_stmt, deltree_stmt_sql);
-	clean_stmt(deltree_all_stmt, deltree_all_stmt_sql);
-	clean_stmt(gettree_stmt, gettree_stmt_sql);
-	clean_stmt(gettree_all_stmt, gettree_all_stmt_sql);
-	clean_stmt(showkey_stmt, showkey_stmt_sql);
-	clean_stmt(put_stmt, put_stmt_sql);
-	clean_stmt(create_astdb_stmt, create_astdb_stmt_sql);
+	clean_stmt(&get_stmt, get_stmt_sql);
+	clean_stmt(&del_stmt, del_stmt_sql);
+	clean_stmt(&deltree_stmt, deltree_stmt_sql);
+	clean_stmt(&deltree_all_stmt, deltree_all_stmt_sql);
+	clean_stmt(&gettree_stmt, gettree_stmt_sql);
+	clean_stmt(&gettree_all_stmt, gettree_all_stmt_sql);
+	clean_stmt(&showkey_stmt, showkey_stmt_sql);
+	clean_stmt(&put_stmt, put_stmt_sql);
+	clean_stmt(&create_astdb_stmt, create_astdb_stmt_sql);
 }
 
 static int init_statements(void)




More information about the asterisk-commits mailing list