Access violation with VariantClear()

L

LEK

My problem is my product has crash when I ran it over night. Then I
dump call stack and found that it happen at VariantClear function. I
think it is the problem of varaint variable send as parameter to this
function. The dump file tell me that this variable have initialized
before. But I don't know what value store in this variable because I
use vc2003 that it can't monitor a variant variable.

My question is what is the behavior of VariantClear function lead to
this problem?
And how can I prevent this problem before call VariantClear?

Call stack:
0391eb5c 2200e324 04666938 00000000 03f18b90 oleaut32!VariantClear
+0x52
0391eb94 28508ae6 0391ec16 e219652c 403cd758 Dexutil!
CMrvMTVarRange::setFloat+0xb4 [c:\dev\trunk_dex5.1\dll\dexutil\source
\m_mtvarrange.cpp @ 1259]
0391ee34 28509249 0391fbd8 2854fe28 00000007 MrvTsi!
CTsiClientItemBaseImp::FillRow+0x4e6 [c:\dev\trunk_dex5.1\dll\mrvtsi
\tsiclientitembaseimp.cpp @ 741]
0391f0f4 2850635b 0391fbd8 0397da78 039e0818 MrvTsi!
CTsiClientItemBaseImp::DataLoad+0x3e9 [c:\dev\trunk_dex5.1\dll\mrvtsi
\tsiclientitembaseimp.cpp @ 853]
0391fb68 491058e5 01000140 00004002 00000000 MrvTsi!CBGetData+0x103b
[c:\dev\trunk_dex5.1\dll\mrvtsi\tsiclientitembaseimp.cpp @ 260]
0391fc54 49126c1e 00050336 77d4cefd 00000000 TSI500!tsiQueryInterface
+0x3fd0
0391fc64 49122859 00942318 00000000 2850b730 TSI500!tsiQueryInterface
+0x25309
00000000 00000000 00000000 00000000 00000000 TSI500!tsiQueryInterface
+0x20f44

My source code:
INT16 CMrvMTVarRange::setFloat(const XYZ &xyz, FLOAT64 Value)
{
SAFEARRAY_LOCK_FAILS_WITH(M_ERR);

//<PS> Access violation
//EMPTY_ENTRY(pVar, M_ERR);
VARIANT *pVar = getVariantPtr(xyz);
if (!pVar || (VariantClear(pVar) != S_OK))
return M_ERR;
//<PS>

V_VT(pVar) = VT_R8;
V_R8(pVar) = Value;
return M_OK;
}
 
A

Alf P. Steinbach

* LEK:
[off-topic]
My problem is my product has crash when I ran it over night. Then I
dump call stack and found that it happen at VariantClear function. I
think it is the problem of varaint variable send as parameter to this
function. The dump file tell me that this variable have initialized
before. But I don't know what value store in this variable because I
use vc2003 that it can't monitor a variant variable.

My question is what is the behavior of VariantClear function lead to
this problem?
And how can I prevent this problem before call VariantClear?

Call stack:
0391eb5c 2200e324 04666938 00000000 03f18b90 oleaut32!VariantClear
+0x52
0391eb94 28508ae6 0391ec16 e219652c 403cd758 Dexutil!
CMrvMTVarRange::setFloat+0xb4 [c:\dev\trunk_dex5.1\dll\dexutil\source
\m_mtvarrange.cpp @ 1259]
0391ee34 28509249 0391fbd8 2854fe28 00000007 MrvTsi!
CTsiClientItemBaseImp::FillRow+0x4e6 [c:\dev\trunk_dex5.1\dll\mrvtsi
\tsiclientitembaseimp.cpp @ 741]
0391f0f4 2850635b 0391fbd8 0397da78 039e0818 MrvTsi!
CTsiClientItemBaseImp::DataLoad+0x3e9 [c:\dev\trunk_dex5.1\dll\mrvtsi
\tsiclientitembaseimp.cpp @ 853]
0391fb68 491058e5 01000140 00004002 00000000 MrvTsi!CBGetData+0x103b
[c:\dev\trunk_dex5.1\dll\mrvtsi\tsiclientitembaseimp.cpp @ 260]
0391fc54 49126c1e 00050336 77d4cefd 00000000 TSI500!tsiQueryInterface
+0x3fd0
0391fc64 49122859 00942318 00000000 2850b730 TSI500!tsiQueryInterface
+0x25309
00000000 00000000 00000000 00000000 00000000 TSI500!tsiQueryInterface
+0x20f44

My source code:
INT16 CMrvMTVarRange::setFloat(const XYZ &xyz, FLOAT64 Value)
{
SAFEARRAY_LOCK_FAILS_WITH(M_ERR);

//<PS> Access violation
//EMPTY_ENTRY(pVar, M_ERR);
VARIANT *pVar = getVariantPtr(xyz);
if (!pVar || (VariantClear(pVar) != S_OK))
return M_ERR;
//<PS>

V_VT(pVar) = VT_R8;
V_R8(pVar) = Value;
return M_OK;
}

Hi. There are two main problems with your posting. The first, very obvious, is
that you're posting about Microsoft technology for C, in a C++ language group,
i.e. your posting is OFF-TOPIC squared. What made you think that this group
could be relevant?

Second, you're including a lot of irrelevant information and omitting the only
relevant information.

Not a problem with the posting, but with the code: setters and getters are bad,
prefixes are bad, cryptic short names like CMrvMt are bad, all uppercase for
non-macros are bad, custom functionality for what you have standard
functionality for is bad, and not the least, writing a 2001-line "Hello, world",
which the kind of code above amounts to, is bad. Think about what your code is
/actually/ achieving. It's most probably next to nothing, then write that.

But presumably you'll get detailed responses about that when you post in an
appropriate group.

Look up this group's FAQ on how to post a question about code that doesn't work,
and also look up the FAQ's suggestions of relevant groups, then post anew there.


Cheers & hth.,

- Alf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top