Capicom dll usage in SQL Server 2000 gives EXCEPTION_ACCESS_VIOLAT
Hi,
I am using the Capicom COM(version 2.1.0.2) component to encrypt/decrypt
data using SQL server 2000 scalar functions. The functions run fine once I
start the server and use the Capicom.dll for encryption/decryption for a
small number of records. When I run a query that applies the scalar function
on a large resultset returning around 300000 rows, the query runs fine the
first time around only.
However, when I run the query again, CAPICOM.EncryptedData object
initialization fails with EXCEPTION_ACCESS_VIOLATION error. If I wait for a
longer amount of time or restart the server, the function starts working
again till the time I run a query that again applies the function to a large
set of data.
I am running the function using the âsaâ user on the SQL server. The machine
where SQL server 2000 is installed is a windows 2003 server.
Can you please let me know what might be causing the access violation? It
looks like a virtual memory space allocation issue to me. I am attaching part
of the SQL server error dumps for your reference.
Any help from you in this regard will be highly appreciated.
=====================================================================
BugCheck Dump
=====================================================================
This file is generated by Microsoft SQL Server 8.00.2039
upon detection of fatal unexpected error. Please return this file,
the query or program that produced the bugcheck, the database and
the error log, and any other pertinent information with a Service Request.
Computer type is AT/AT COMPATIBLE.
Bios Version is A M I - 3000518
SE7520BD22 Production BIOS Version 07.30, Build 0067
Current time is 22:00:50 05/14/08.
4 Intel x86 level 15, 2793 Mhz processor(s).
Windows NT 5.2 Build 3790 CSD Service Pack 1.
Memory
MemoryLoad = 44%
Total Physical = 2047 MB
Available Physical = 1140 MB
Total Page File = 4401 MB
Available Page File = 3589 MB
Total Virtual = 2047 MB
Available Virtual = 324 MB
*Stack Dump being sent to e:\Microsoft SQL Server\MSSQL\log\SQLDump0009.txt
*
*****************************************************************************
**
*
* BEGIN STACK DUMP:
* 05/14/08 22:00:50 spid 52
*
* Exception Address = 7C83002E (RtlAllocateHeap + 00000631 Line
0+00000000)
* Exception Code = c0000005 EXCEPTION_ACCESS_VIOLATION
* Access Violation occurred writing address 053C49F1
* Input Buffer 3996 bytes -
* DECLARE @RC int DECLARE @startVal bigint DECLARE @lastVal bigint DECL
* ARE @amountFrom varchar(12) DECLARE @amountTo varchar(12) DECLARE @net
* work varchar(1000) DECLARE @subnetwork varchar(1000) DECLARE @agent va
* rchar(1000) DECLARE @transaction varchar(10) DECLARE @datefrom varchar
* (10) DECLARE @dateto varchar(10) DECLARE @sortFirstLevel varchar(30)
* DECLARE @sortFirstOrder varchar(30) DECLARE @sortSecondLevel varchar(30
* ) DECLARE @sortSecondOrder varchar(30) DECLARE @sortThirdLevel varchar
* (30) DECLARE @sortThirdOrder varchar(30) DECLARE @fieldName varchar(25
* ) DECLARE @fieldValue varchar(100) DECLARE @key varchar(256) SELECT @
* startVal = 1 SELECT @lastVal = 300 SELECT @amountFrom = '1' SELECT @a
* mountTo = '999' SELECT @network = NULL SELECT @subnetwork = NULL SELE
* CT @agent = NULL SELECT @transaction = NULL SELECT @datefrom = NULL S
* ELECT @dateto = NULL SELECT @sortFirstLevel = NULL SELECT @sortFirstOr
* der = NULL SELECT @sortSecondLevel = NULL SELECT @sortSecondOrder = NU
* LL SELECT @sortThirdLevel = NULL SELECT @sortThirdOrder = NULL SELECT
* @fieldName = NULL SELECT @fieldValue = NULL SELECT @key = 'iLcy04RSXs
* qRU/XcCBx+fQ==' select getdate() --EXEC @RC = [Agentlink2UAT].[dbo
* ].[sp_DetailRecords] @startVal, @lastVal, @amountFrom, @amountTo, @netwo
* rk, @subnetwork, @agent, @transaction, @datefrom, @dateto, @sortFirstLev
* el, @sortFirstOrder, @sortSecondLevel, @sortSecondOrder, @sortThirdLevel
* , @sortThirdOrder, @fieldName, @fieldValue EXEC @RC = [Agentlink2UAT]
* .[dbo].[sp_DetailRecords_Encryption] @startVal, @lastVal, @amountFrom, @
* amountTo, @network, @subnetwork, @agent, @transaction, @datefrom, @datet
* o, @sortFirstLevel, @sortFirstOrder, @sortSecondLevel, @sortSecondOrder,
* @sortThirdLevel, @sortThirdOrder, @fieldName, @fieldValue, @key DECLAR
* E @PrnLine nvarchar(4000) PRINT 'Stored Procedure: Agentlink2UAT.dbo.sp
* _DetailRecords_Encryption' SELECT @PrnLine = ' Return Code = ' + CONVER
* T(nvarchar, @RC) PRINT @PrnLine select getdate()
*
*
* MODULE BASE END SIZE
* sqlservr 00400000 00CBAFFF 008bb000
* ntdll 7C800000 7C8BFFFF 000c0000
* kernel32 77E40000 77F41FFF 00102000
* ADVAPI32 77F50000 77FEBFFF 0009c000
* RPCRT4 77C50000 77CEEFFF 0009f000
* MSVCP71 7C3A0000 7C41AFFF 0007b000
* MSVCR71 7C340000 7C395FFF 00056000
* opends60 41060000 41065FFF 00006000
* SHELL32 7C8D0000 7D0D3FFF 00804000
* msvcrt 77BA0000 77BF9FFF 0005a000
* GDI32 77C00000 77C48FFF 00049000
* USER32 77380000 77411FFF 00092000
* SHLWAPI 77DA0000 77DF1FFF 00052000
* sqlsort 42AE0000 42B6FFFF 00090000
* ums 41070000 4107DFFF 0000e000
* IMM32 76290000 762ACFFF 0001d000
* comctl32 77420000 77522FFF 00103000
* sqlevn70 41080000 4108AFFF 0000b000
* NETAPI32 02C90000 02CE7FFF 00058000
* AUTHZ 02CF0000 02D03FFF 00014000
* COMRES 03120000 031E5FFF 000c6000
* ole32 031F0000 03323FFF 00134000
* XOLEHLP 03330000 03335FFF 00006000
* MSDTCPRX 03340000 033B7FFF 00078000
* msvcp60 033C0000 03420FFF 00061000
* MTXCLU 03430000 03448FFF 00019000
* VERSION 03450000 03457FFF 00008000
* WSOCK32 03460000 03468FFF 00009000
* WS2_32 03470000 03486FFF 00017000
* WS2HELP 03490000 03497FFF 00008000
* OLEAUT32 034A0000 0352BFFF 0008c000
* CLUSAPI 03570000 03581FFF 00012000
* RESUTILS 03590000 035A2FFF 00013000
* USERENV 035B0000 03673FFF 000c4000
* secur32 03680000 03692FFF 00013000
* mswsock 036B0000 036F0FFF 00041000
* DNSAPI 03700000 0372EFFF 0002f000
* winrnr 03770000 03776FFF 00007000
* WLDAP32 03780000 037ADFFF 0002e000
* rasadhlp 037D0000 037D7FFF 00008000
* NTMARTA 03FB0000 03FD1FFF 00022000
* SAMLIB 03FE0000 03FEEFFF 0000f000
* SSNETLIB 00E50000 00E65FFF 00016000
* security 042C0000 042C3FFF 00004000
* hnetcfg 042D0000 04328FFF 00059000
* wshtcpip 04370000 04377FFF 00008000
* SSmsLPCn 04400000 04407FFF 00008000
* SSnmPN70 04410000 04416FFF 00007000
* ntdsapi 044A0000 044B4FFF 00015000
* kerberos 04CD0000 04D27FFF 00058000
* cryptdll 04D30000 04D3BFFF 0000c000
* MSASN1 04D40000 04D51FFF 00012000
* msv1_0 044E0000 04506FFF 00027000
* iphlpapi 04510000 04529FFF 0001a000
* PSAPI 04530000 0453AFFF 0000b000
* rsaenh 04540000 0456EFFF 0002f000
* xpsp2res 10000000 102C4FFF 002c5000
* CLBCatQ 047C0000 04842FFF 00083000
* sqloledb 04850000 048D0FFF 00081000
* MSDART 04250000 04269FFF 0001a000
* MSDATL3 04270000 04284FFF 00015000
* oledb32 04BA0000 04C18FFF 00079000
* OLEDB32R 04290000 042A0FFF 00011000
* odsole70 04C20000 04C30FFF 00011000
* capicom 053B0000 0542DFFF 0007e000
* MSSIGN32 042B0000 042BBFFF 0000c000
* CRYPT32 05430000 054C2FFF 00093000
* WININET 054D0000 0559EFFF 000cf000
* Normaliz 05150000 05158FFF 00009000
* iertutil 055A0000 055E4FFF 00045000
* WINTRUST 055F0000 0561AFFF 0002b000
* imagehlp 05620000 05648FFF 00029000
* SXS 05770000 0582BFFF 000bc000
* odsole70 05880000 05884FFF 00005000
* dbghelp 05990000 05A8FFFF 00100000
*
* Edi: 05760000: 000000C8 00000143 EEFFEEFF 00001002 00000000
0000F
E00
* Esi: 05763938: 01010084 000C0064 053B3760 053C49F1 00000001
00000
000
* Eax: 05763940: 053B3760 053C49F1 00000001 00000000 00000000
00000
000
* Ebx: 05760178: 053B3760 053B3734 00000001 00000000 00000000
00000
000
* Ecx: 053B3760: 053C2CCC 053C49F1 053C2FCE 053C2C89 053BCA8E
053C2
B88
* Edx: 053C49F1: 8B55FF8B 08458BEC 5008C083 116815FF C25D053B
CCCC0
004
* Eip: 7C83002E: 41890289 758B5604 B3E856D0 8BFFFFF5 4601E045
83DB3
328
* Ebp: 0526F7AC: 0526F7EC 053E1B72 05760000 00000000 05763D00
C63FB
5A5
* SegCs: 0000001B:
* EFlags: 00010283: 69005C00 63006E00 75006C00 65006400 49000000
4F005
700
* Esp: 0526F6DC: 00000000 05763D00 0029D530 7C8302B3 05763938
0526F
7D0
* SegSs: 00000023:
*
*****************************************************************************
**
*
-----------------------------------------------------------------------------
--
* Short Stack Dump
* 7C83002E Module(ntdll+0003002E) (RtlAllocateHeap+00000631)
* 053E1B72 Module(capicom+00031B72) (DllUnregisterServer+000218AC)
* 053C2FC1 Module(capicom+00012FC1) (DllUnregisterServer+00002CFB)
* 053C2FF5 Module(capicom+00012FF5) (DllUnregisterServer+00002D2F)
* 04C24962 Module(odsole70+00004962) (sp_OAGetErrorInfo+000002F2)
-------------------------------------------------------------------------------
* Location : 7C83002E Module(ntdll+0003002E) (RtlAllocateHeap+00000631)
* Return Addr: 053E1B72 Module(capicom+00031B72)
(DllUnregisterServer+000218AC)
Frame : 0526F7AC
Parameters:
[1] 05760000: 000000C8 00000143 EEFFEEFF 00001002 00000000 0000FE00
[2] 00000000:
[3] 05763D00: 053B3760 053B3734 00000001 00000000 00000000 00000000
[4] C63FB5A5:
160 bytes of stack data from 0526F70C to 0526F7AC
0526F70C: 053B3758 43709CB0 05760538 00000000 [X7;...pC8.v.....]
0526F71C: 00000001 00000000 05760538 053C49F1 [........8.v..I<.]
0526F72C: 00000000 05763940 42D6EE70 00000000 [....@9v.p..B....]
0526F73C: 00000000 053B3760 437CB454 0526F7C0 [....`7;.T.|C..&.]
0526F74C: 00415977 437CB1F0 437CBE00 00415D52 [wYA...|C..|CR]A.]
0526F75C: 000C0000 00000000 00000000 00000028 [............(...]
0526F76C: 00000028 00000005 0001F6BC 0526F6C0 [(.............&.]
0526F77C: 05760000 00000000 7C82F680 00000060 [..v........|`...]
0526F78C: 00000084 0101F9DD 0526F6DC 0526F308 [..........&...&.]
0526F79C: 0526F7DC 7C82F680 7C82F9E0 00000001 [..&....|...|....]
-------------------------------------------------------------------------------
* Location : 053E1B72 Module(capicom+00031B72)
(DllUnregisterServer+000218AC)
* Return Addr: 053C2FC1 Module(capicom+00012FC1)
(DllUnregisterServer+00002CFB)
Frame : 0526F7EC
Parameters:
[1] 05763D00: 053B3760 053B3734 00000001 00000000 00000000 00000000
[2] 05763D00: 053B3760 053B3734 00000001 00000000 00000000 00000000
[3] 0526F810: 000000F1 04C24962 05763D00 0029D4C0 04C226CD 437CB1F0
[4] 053C2FF5: 5E5FC78B 0004C25D CCCCCCCC 246C83CC C2E90404 CCFFFFFF
64 bytes of stack data from 0526F7AC to 0526F7EC
0526F7AC: 0526F7EC 053E1B72 05760000 00000000 [..&.r.>...v.....]
0526F7BC: 05763D00 C63FB5A5 00000000 05763D00 [.=v...?......=v.]
0526F7CC: 0029D530 7C82F9DD 0526F7C0 0526F2F8 [0.)....|..&...&.]
0526F7DC: 0526F864 053E1810 C62633E9 FFFFFFFE [d.&...>..3&.....]
-------------------------------------------------------------------------------
* Location : 053C2FC1 Module(capicom+00012FC1)
(DllUnregisterServer+00002CFB)
* Return Addr: 053C2FF5 Module(capicom+00012FF5)
(DllUnregisterServer+00002D2F)
Frame : 0526F7FC
Parameters:
[1] 00000001:
[2] 0029AD50: 36363636 4333C0C0 05763D04 00000000 00000000 0029ABA0
[3] 0029AD50: 36363636 4333C0C0 05763D04 00000000 00000000 0029ABA0
[4] 000000F1:
16 bytes of stack data from 0526F7EC to 0526F7FC
0526F7EC: 0526F7FC 053C2FC1 05763D00 05763D00 [..&../<..=v..=v.]
-------------------------------------------------------------------------------
* Location : 053C2FF5 Module(capicom+00012FF5)
(DllUnregisterServer+00002D2F)
* Return Addr: 04C24962 Module(odsole70+00004962)
(sp_OAGetErrorInfo+000002F2)
Frame : 0526F810
Parameters:
[1] 05763D00: 053B3760 053B3734 00000001 00000000 00000000 00000000
[2] 0029D4C0: 00A99F4C 00000000 0000001A 00000003 00002728 0012B77C
[3] 04C226CD: 7921E857 C4830000 04C38304 8BE4754D C0853046 7E8B2474
[4] 437CB1F0: 00000034 00000000 016AB8F7 00009A9C 00000000 00000000
20 bytes of stack data from 0526F7FC to 0526F810
0526F7FC: 0526F810 053C2FF5 00000001 0029AD50 [..&../<.....P.).]
0526F80C: 0029AD50 [P.).]
-------------------------------------------------------------------------------
* Location : 04C24962 Module(odsole70+00004962)
(sp_OAGetErrorInfo+000002F2)
* Return Addr: 00000000 Module(sqlservr+FFC00000)
Frame : 000000F1
Parameters:
[1] 00000000:
[2] 00000000:
[3] 00000000:
[4] 00000000:
*
-----------------------------------------------------------------------------
--
PSS @0x437CB1F0
---------------
pspid = 52 m_dwLoginFlags = 0x03e0 plsid = 1119453848
pbackground = 0
pbSid
-----
01 .
sSecFlags = 0x12
pdeadlockpri = 0 poffsets = 0x0 pss_stats = 0x0
ptickcount = 505000 pcputickcount = 1407222254445
ploginstamp = 25 ptimestamp = 2008-05-14 22:00:37.943
plangid = 0 pdateformat = 1 pdatefirst = 7
Language = us_english UserName = sa poptions = 0x28080860
poptions2 = 0x3f438 pline = 51 pcurstepno = 0
prowcount = 0 pstatlist = 0 pcurcmd = 193
pseqstat = 0 ptextsize = 64512 pretstat = 0
CNestLevel = 0 @@procid = 0
pslastbatchstarttime = 2008-05-14 22:00:37.960 pmemusage = 43
hLicense = 0 tpFlags = 0x1 isolation_level = 0
fips_flag = 0x0 sSaveSecFlags = 0x0 psavedb = 0
pfetchstat = 0 pcrsrows = 0
pslastbatchtime = 2008-05-14 22:00:37.960 pubexecdb = 0
fInReplicatedProcExec = 0 pMsqlXact = 0x437CD040 presSemCount = [0]0
presSemCount = [0]0 pcputot = 0 pcputotstart = 0
pcpucmdstart = 0 pbufread = 662 pbufreadstart = 0
plogbufread = 5264 plogbufreadstart = 24 pbufwrite = 54
pbufwritestart = 0 pLockTimeout = 4294967295 pUtilResultSet =
0x00000000
date: Mon, 19 May 2008 01:48:06 -0700
author: Anil Allewar