[asterisk-dev] [Code Review] 3078: astdb: crash in sqlite3 during shutdown

Scott Griepentrog reviewboard at asterisk.org
Wed Dec 18 15:26:13 CST 2013



> On Dec. 18, 2013, 2:53 p.m., Mark Michelson wrote:
> > /branches/11/main/db.c, lines 150-156
> > <https://reviewboard.asterisk.org/r/3078/diff/1/?file=49824#file49824line150>
> >
> >     I got a bit curious about how sqlite3_finalize() works, so I took a look at the source code.
> >     
> >     If I'm reading it correctly, even if an error is returned, the prepared statement is actually freed. The return simply indicates whether the last execution of the statement was successful or not.
> >     
> >     Having said that, I believe that you need to NULL out *stmt whether sqlite3_finalize() returns an error or not.

Agreed.


- Scott


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/3078/#review10454
-----------------------------------------------------------


On Dec. 18, 2013, 1:42 p.m., Scott Griepentrog wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/3078/
> -----------------------------------------------------------
> 
> (Updated Dec. 18, 2013, 1:42 p.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Bugs: AST-1265 and ASTERISK-22350
>     https://issues.asterisk.org/jira/browse/AST-1265
>     https://issues.asterisk.org/jira/browse/ASTERISK-22350
> 
> 
> Repository: Asterisk
> 
> 
> Description
> -------
> 
> When Asterisk is shut down, the astdb_atexit() function releases (finalizes) the previously initialized (prepared) SQL statements in sqlite3.  Another thread subsequently attempting an astdb operation tries to use the released statement and causes a violation in sqlite3.  This patch eliminates that issue by resetting the statement pointer after it is released/cleared.  Code in sqlite3 will detect the null pointer and abort the operation rather than crash.
> 
> 
> Diffs
> -----
> 
>   /branches/11/main/db.c 404197 
> 
> Diff: https://reviewboard.asterisk.org/r/3078/diff/
> 
> 
> Testing
> -------
> 
> 
> Thanks,
> 
> Scott Griepentrog
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20131218/2f4e90ed/attachment.html>


More information about the asterisk-dev mailing list