Microsoft KB Archive/839405

= You may receive an access violation exception when you try to use SQL Mail on a multiprocessor computer =

Article ID: 839405

Article Last Modified on 3/19/2007

-

APPLIES TO


 * Microsoft SQL Server 2000 Standard Edition

-



Bug #: 471055 (SQL Server 8.0)

Important This article contains information about modifying the registry. Before you modify the registry, make sure to back it up and make sure that you understand how to restore the registry if a problem occurs. For information about how to back up, restore, and edit the registry, click the following article number to view the article in the Microsoft Knowledge Base:

256986 Description of the Microsoft Windows Registry



SYMPTOMS
When you try to use SQL Mail on a multiprocessor computer, SQL Mail may not call the MAPIInitialize function and the MAPIUninitialize function for every thread that uses MAPI API calls. Therefore, you may receive an access violation exception.

For example, this problem may occur when you run the BULK INSERT Transact-SQL statement on a Microsoft SQL Server 2000 database that runs on a multiprocessor computer, and the BULK INSERT Transact-SQL statement tries to copy MAPI messages to a table in the SQL Server database.

After you receive the access violation exception, you may notice a stack dump file that is similar to one of the following: * BEGIN STACK DUMP: .... ---
 * 10/10/03 22:30:02 spid 61
 * Exception Address = 77F8910E (RtlEnterCriticalSection + 0000000B Line 0+00000000)
 * Exception Code   = c0000005 EXCEPTION_ACCESS_VIOLATION
 * Access Violation occurred reading address 00C9FF70
 * Input Buffer 336 bytes -
 * BULK INSERT [DB1].[dbo].[Table1] FROM 'c:\files.dat'
 * WITH (FORMATFILE = 'c:\files.fmt', MAXERRORS = 10 )
 * WITH (FORMATFILE = 'c:\files.fmt', MAXERRORS = 10 )
 * Short Stack Dump
 * 77F8910E Module(ntdll+0000910E) (RtlEnterCriticalSection+0000000B)
 * 77E12CA8 Module(USER32+00002CA8) (GetSysColor+00000444)
 * 77E12DC5 Module(USER32+00002DC5) (GetSysColor+00000561)
 * 77E1577D Module(USER32+0000577D) (DispatchMessageA+0000000B)
 * 16142BB3 Module(impprov+00002BB3)
 * 1614E84A Module(impprov+0000E84A) (DllRegisterServer+0000AA3A)
 * 1615145C Module(impprov+0001145C) (DllRegisterServer+0000D64C)
 * 1614E1DC Module(impprov+0000E1DC) (DllRegisterServer+0000A3CC)
 * 0047FB7B Module(sqlservr+0007FB7B) (CBcpImport::CreateInprocProvider+000002FA)
 * 0047F05A Module(sqlservr+0007F05A) (CBcpImport::Init+0000029D)
 * 0047ED54 Module(sqlservr+0007ED54) (BcpImportMain+0000014D)
 * 0047EC14 Module(sqlservr+0007EC14) (CStmtBulkIns::XretExecute+0000005F)
 * 0041C3CB Module(sqlservr+0001C3CB) (CMsqlExecContext::ExecuteStmts+000003B9)
 * 0041BA11 Module(sqlservr+0001BA11) (CMsqlExecContext::Execute+000001B6)
 * 0041B02D Module(sqlservr+0001B02D) (CSQLSource::Execute+00000357)
 * 0048DAE8 Module(sqlservr+0008DAE8) (language_exec+000003E1)
 * 004292A5 Module(sqlservr+000292A5) (process_commands+0000010E)
 * 41072838 Module(UMS+00002838) (ProcessWorkRequests+00000272)
 * 410725B3 Module(UMS+000025B3) (ThreadStartRoutine+00000098)
 * 78008454 Module(MSVCRT+00008454) (endthread+000000C1)
 * 7C4E987C Module(KERNEL32+0000987C) (SetThreadExecutionState+00000227)

 ....
 * BEGIN STACK DUMP:
 * 01/27/04 22:30:02 spid 62
 * Exception Address = 77F8910E (RtlEnterCriticalSection + 0000000B Line 0+00000000)
 * Exception Code   = c0000005 EXCEPTION_ACCESS_VIOLATION
 * Access Violation occurred reading address 197AFF70
 * Input Buffer 336 bytes -
 * BULK INSERT [DB1].[dbo].[Table1] FROM 'c:\files.dat'
 * WITH (FORMATFILE = 'c:\files.fmt', MAXERRORS = 10 )
 * WITH (FORMATFILE = 'c:\files.fmt', MAXERRORS = 10 )
 * Short Stack Dump
 * 77F8910E Module(ntdll+0000910E) (RtlEnterCriticalSection+0000000B)
 * 77E3A2D0 Module(USER32+0002A2D0) (SetWindowPlacement+00000050)
 * 77E145E5 Module(USER32+000045E5) (TranslateMessageEx+00000605)
 * 77E15B51 Module(USER32+00005B51) (DispatchMessageA+0000000B)
 * 15D02BB3 Module(impprov+00002BB3)
 * 15D0E84A Module(impprov+0000E84A) (DllRegisterServer+0000AA3A)
 * 15D1145C Module(impprov+0001145C) (DllRegisterServer+0000D64C)
 * 15D0E1DC Module(impprov+0000E1DC) (DllRegisterServer+0000A3CC)
 * 0047FB7B Module(sqlservr+0007FB7B) (CBcpImport::CreateInprocProvider+000002FA)
 * 0047F05A Module(sqlservr+0007F05A) (CBcpImport::Init+0000029D)
 * 0047ED54 Module(sqlservr+0007ED54) (BcpImportMain+0000014D)
 * 0047EC14 Module(sqlservr+0007EC14) (CStmtBulkIns::XretExecute+0000005F)
 * 0041C3CB Module(sqlservr+0001C3CB) (CMsqlExecContext::ExecuteStmts+000003B9)
 * 0041BA11 Module(sqlservr+0001BA11) (CMsqlExecContext::Execute+000001B6)
 * 0041B02D Module(sqlservr+0001B02D) (CSQLSource::Execute+00000357)
 * 0048DAE8 Module(sqlservr+0008DAE8) (language_exec+000003E1)
 * 004292A5 Module(sqlservr+000292A5) (process_commands+0000010E)
 * 41072838 Module(UMS+00002838) (ProcessWorkRequests+00000272)
 * 410725B3 Module(UMS+000025B3) (ThreadStartRoutine+00000098)
 * 78008454 Module(MSVCRT+00008454) (endthread+000000C1)
 * 7C57B382 Module(KERNEL32+0000B382) (lstrcmpiW+000000B7)
 * 7C57B382 Module(KERNEL32+0000B382) (lstrcmpiW+000000B7)



CAUSE
This problem occurs because SQL Mail does not use the MAPI_MULTITHREADED_NOTIFICATIONS flag in the MAPIInitialize function.



WORKAROUND
To work around this problem, you must turn on the  registry entry. To do this, follow these steps.

Warning If you use Registry Editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that you can solve problems that result from using Registry Editor incorrectly. Use Registry Editor at your own risk.  Click Start, and then click Run. In the Open box, type Regedit, and then click OK. For a default instance of SQL Server 2000, locate the following registry key in the left pane of the Registry Editor window:

For a named instance of SQL Server 2000, locate the following registry key in the left pane of the Registry Editor window:

 Right-click the registry key that is specified in step 3, point to New, and then click DWORD Value. Name the DWORD Value MAPIInitializeFlags .</li> Right-click the MAPIInitializeFlags registry value, and then click Modify.</li> In the Edit DWORD Value dialog box, type 10001 in the Value data box, and then click OK.

Note Make sure that the Hexadecimal option in the Base section is selected.</li> Quit Registry Editor.</li></ol>

You must restart the SQL Server service for these flags to take effect.

<div class="references_section">