Symptoms
You run an SQL query that contains an IF EXISTS statement in Microsoft SQL Server 2012. If the IF EXISTS statement contains the dynamic management function sys.dm_db_index_physical_stats, you receive an access violation that resembles the following:
date time spid # * *******************************************************************************
datetime spid # * datetime spid # * BEGIN STACK DUMP: datetime spid # * date time spid # datetime spid # * datetime spid # * datetime spid # * Exception Address = 000007FF7DA5614B Module(sqlmin+000000000000614B) datetime spid # * Exception Code = c0000005 EXCEPTION_ACCESS_VIOLATION datetime spid # * Access Violation occurred reading address 0000000800000F04 datetime spid # * Input Buffer 510 bytes - datetime spid # * SQL_query_code datetime spid # * endNotes
-
If you run the DBCC CHECKDB command against that database after the access violation occurs, no error is reported.
-
The access violation does not occur when you first run the SQL query. However, the access violation does occur every time that you run the SQL query after that.
-
If you enable trace flag 3654, the access violation does not occur. However, you receive the following error in the trace instead:
Location: sosmemdbg.cpp:2074
Expression: FALSE SPID: 55 Process ID: 16972 Description: MEMOBJ_INDEXANALYSIS -- Unfreed memory detected. Msg 3624, Level 20, State 1, Line 5 A system assertion check has failed. Check the SQL Server error log for details. Typically, an assertion failure is caused by a software bug or data corruption. To check for database corruption, consider running DBCC CHECKDB. If you agreed to send dumps to Microsoft during setup, a mini dump will be sent to Microsoft. An update might be available from Microsoft in the latest Service Pack or in a QFE from Technical Support. Msg 0, Level 20, State 0, Line 0 A severe error occurred on the current command. The results, if any, should be discarded.
Resolution
To resolve this problem, install Cumulative Update 7 for SQL Server 2012 SP1. This problem was first fixed in this cumulative update.
Each new cumulative update for SQL Server contains all the hotfixes and all the security fixes that were included in the previous cumulative update. For more information, check out the latest cumulative update for SQL Server 2012 SP1.
Status
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
References
See the terminology Microsoft uses to describe software updates.