I have installed:
MicroStation CONNECT Edition10.15.0.74
MicroStation CONNECT Edition SDK10.15.00.076
Our application consists of 3 complex command dlls, each of which creates, uses, and frees several SymbolSets. We encounter consistent but random crashes with calls to mdlCExpression_getValue() for workflows that execute command sequences that jump from one dll to the other (but not if you only execute commands from a single dll.)
Unfortunately I can't readily provide a simple test case due to the complexity and randomness of the problem.
Below is a typical stack seen inside exceptions.log. Since I don't know much about how the mdlCExprssion API manages memory I'm not sure how to interpret this stack nor how to go about debugging the problem.
Any advice would be appreciated.
Thanks,
John M.
Call Stack
0: 000000bb591fc130 000000006ddadfce 000001f78270b290 000000006e3fde40 000001f7dd3f6970 000000006ddf0c03 mdlSymbols_getList+0x340 1: 000000bb591fc160 000000006ddaed28 000001f782ecee68 00000000ffffffff 000001f7dd3f6950 000000006e3fde40 mdlButtonMap_setNoInterpretArea+0x3fe 2: 000000bb591fc1a0 000000006ddef33f 000000bb591fc220 000001f782ecf2b8 00000000ffffffff 000001f7dd3f6950 mdlCExpression_publishTrustedFunction+0x18 3: 000000bb591fc210 000000006ddefd76 000001f782ecee68 000001f782eceef8 000001f782ecf2b8 00007ff913de12b8 mdlCExpression_isWCharPointer+0x23bf 4: 000000bb591fc260 000000006ddf08ab 0000000000000052 000000bb591fc310 0000000000000000 000000006dded149 mdlCExpression_isWCharPointer+0x2df6 5: 000000bb591fc2b0 000000006ddf0394 000000bb591fc780 0000000000000000 000000000000002b 0000000000000000 mdlCExpression_isWCharPointer+0x392b 6: 000000bb591fc330 000000006ddefb5e 000000bb591fc780 0000000000000000 0000000000000000 0000000000000000 mdlCExpression_isWCharPointer+0x3414 7: 000000bb591fc380 000000006ddf0284 0000000000000000 000000bb591fc780 000000bb591fc780 000000bb591fc439 mdlCExpression_isWCharPointer+0x2bde 8: 000000bb591fc3e0 000000006ddef89a 0000000000000000 000000bb591fc460 000000bb591fc780 0000000000000000 mdlCExpression_isWCharPointer+0x3304 9: 000000bb591fc470 000000006ddef774 0000000000000000 000000bb591fc780 0000000000000000 000001f7abf3fa70 mdlCExpression_isWCharPointer+0x291a 10: 000000bb591fc4d0 000000006ddef5b4 0000000000000000 0000000000000000 000000bb591fc780 0000000000000000 mdlCExpression_isWCharPointer+0x27f4 11: 000000bb591fc530 000000006ddf09a4 000001f782db4380 000000006dbbeb8c 000000bb591fc780 00007ff916dda3db mdlCExpression_isWCharPointer+0x2634 12: 000000bb591fc590 000000006ddef694 000001f7829767b8 0000000000000000 0000953aa182e9f1 000000006db9ae70 mdlCExpression_isWCharPointer+0x3a24 13: 000000bb591fc5f0 000000006ddefa50 000000bb591fc6c0 000000bb591fc780 000000006e5519f0 0000000000000000 mdlCExpression_isWCharPointer+0x2714 14: 000000bb591fc650 000000006ddf00fb 0000000000000131 000000000000006c 0000000000000000 000000bb591fc890 mdlCExpression_isWCharPointer+0x2ad0 15: 000000bb591fc6b0 000000006ddf0e34 000000bb591fc858 000000bb591fc780 000000bb591fc890 0000000000000000 mdlCExpression_isWCharPointer+0x317b 16: 000000bb591fc700 000000006ddf0d80 00000000ffffff00 000000bb591fc780 000000006e5519f0 000000006ddf18f8 mdlCExpression_isWCharPointer+0x3eb4 17: 000000bb591fc750 000000006ddaeaac 0000000000000002 000000bb591fc858 000000bb591fc890 0000000000000002 mdlCExpression_isWCharPointer+0x3e00 18: 000000bb591fc7a0 000000006ddaea4b 000000bb591fc828 000000bb591fc858 000000bb591fc890 000001f7abf3fa70 mdlCExpression_getValueForApp+0x4c 19: 000000bb591fc7e0 00007ff8800a2b6e 000001f7abf40010 0000000000000000 0000000000000000 0000000000000000 mdlCExpression_getValue+0x3b 20: 000000bb591fc9c0 00007ff88009c45a 000001f7fd212000 cccccccccccccccc cccccccccccccccc cccccccccccccccc MdlMain+0x21001 21: 000000bb591fca20 00007ff88009b2c6 000001f7a9ca0980 cccccccccccccccc cccccccccccccccc cccccccccccccccc MdlMain+0x1a8ed 22: 000000bb591fca70 00007ff88009b6d4 000001f7a9ca0980 000001f782b9a8b0 0000000000000000 cccccccccccccccc MdlMain+0x19759 23: 000000bb591fcb70 000000006dba20f3 000000bb591fcc30 0000000000000000 0000000000000001 00007ff900000000 MdlMain+0x19b67 24: 000000bb591fcbf0 000000006dc1f907 000001f7a9c72320 000001f782b9a8b0 000001f782b70120 0000000000000001 mdlDialog_hookItemCall+0x133 25: 000000bb591fcd30 000000006dc1f6ff 000001f7a9c72320 0000000000000000 000001f7a9c72320 0000000000000000 ListBox::SetTopRow+0xe0a7 26: 000000bb591fcdc0 000000006dc26b76 000001f77fffffff 000001f7a9c72320 000001f700000000 000000000000001e ListBox::SetTopRow+0xde9f 27: 000000bb591fce10 00007ff88009b618 000001f7abf40010 0000000000000000 0000000000000000 cccccccccccccccc mdlDialog_listBoxSelectCells+0x66 28: 000000bb591fcf10 000000006dba20f3 000000bb591fcff0 0000000000000000 000000bb591fcf01 000000bb591fcff0 MdlMain+0x19aab 29: 000000bb591fcf90 000000006dbb7c70 000001f7ddc23da8 000001f7a9c72320 000001f7dd0aec40 000001f7abf3f550 mdlDialog_hookItemCall+0x133 30: 000000bb591fd0a0 000000006dbb8fbd 0000000000000000 0000000000000018 000001f782e2c5d0 0000000000000000 mdlDialog_updateNativeMenuTitle+0x730 31: 000000bb591fd140 000000006dc66b11 0000000000000000 000001f7a9c6f5a8 0000000000000032 a400000100000000 mdlDialog_updateNativeMenuTitle+0x1a7d 32: 000000bb591fd1e0 000000006dc6b5ea 000001f700000000 0000000000000000 000000bb591fd3a0 000000bb591fd299 Bentley::MstnPlatform::GuiLayoutTabPageList::SetGeometry+0x5771 33: 000000bb591fd2f0 000000006db97a64 000000bb591fd3a0 0000000000000032 000000bb591fd3a0 000000006db9790f mdlDialog_tabPageSetLayoutManager+0x88a 34: 000000bb591fd340 000000006dbba68b 000001f7dd0aec40 000000006dc6b570 000001f7dd0aec40 000001f7a996fb10 mdlDialog_itemMessageSend+0x114 35: 000000bb591fd560 000000006dbba503 000001f7824a6b01 000001f7a996fb10 0000000000000000 0000000000000000 mdlDialog_rItemChildCreateWithRFileOpt+0x15b 36: 000000bb591fd5d0 000000006dbb8e0e 000001f782e2d4b0 000001f7ddb67084 000001f7824a6b20 0000000000000002 mdlDialog_rItemChildCreateWRscAndRFileOpt+0x113 37: 000000bb591fd670 000000006dc63e84 000001f782b9a8b0 000001f7ddb67058 000001f7a996f000 0000000000000000 mdlDialog_updateNativeMenuTitle+0x18ce 38: 000000bb591fd720 000000006db97a64 000000bb591fd7d0 0000000000000000 000001f7824a6701 0000000000000000 Bentley::MstnPlatform::GuiLayoutTabPageList::SetGeometry+0x2ae4 39: 000000bb591fd770 000000006dbb7c4e 000001f7dd0aec40 000000006dc6adc0 000001f782b70120 000001f782704b00 mdlDialog_itemMessageSend+0x114 40: 000000bb591fd880 000000006dbb8fbd 0000000000000000 0000000000000008 000001f7828222f0 0000000000000000 mdlDialog_updateNativeMenuTitle+0x70e 41: 000000bb591fd920 000000006dba700b 000001f782b70120 000001f782975a58 000000bb00000019 000001f700000000 mdlDialog_updateNativeMenuTitle+0x1a7d 42: 000000bb591fdc00 000000006dba7d10 000001f700000000 0000000000000000 000000bb00000001 00007ff800000001 mdlWindow_undockWindow+0x9eb 43: 000000bb591fdcc0 000000006dbad4bb 0000000000000001 000000bb591fdf80 000000bb591fdd44 0000000000000000 mdlWindow_undockWindow+0x16f0 44: 000000bb591fdcf0 00007ff880088e1b 000000bb591fdeb0 00007ff880081e88 00007ff880081e88 cccccccc00000005 mdlDialog_openModal+0x2b 45: 000000bb591fde30 000000006dfb5535 000000bb591fdeb0 00007ff880081e88 000001f7ddaffc01 0000000000000000 MdlMain+0x72ae 46: 000000bb591fde70 000000006dec0116 000001f7e554c850 000000006e5618a0 000000bb591fe8c0 000001f7e554c850 SaveAndSwitchMdlDesc::~SaveAndSwitchMdlDesc+0xae5 47: 000000bb591fe860 000000006dec3645 000000bb591fe8c0 0000000000000001 000001f78296e1e8 000001f7829767a0 priorityGui_initialize+0x8e6 48: 000000bb591fe890 000000006dd5a3b4 000000006dd5bb30 000000006dd5bb30 0000000000000000 0000000000000000 mdlInput_processQueuedInput+0x25
Hi John Majerle
I remember problems with mdlCExpression_getValue(),and that we where trying to get get rid of those calls. One of the main problems were loaded RSC-files. Or better said, the missing of fresh loaded RSC-files.
On a DEVCON some years ago, some one told us, it is better to oben and close RSC files in short terms is better than to open them once at the start of an DLL/MA.
Maybe this is a hint for your.
Mit freundlichen Grüßen / Best regards Volker Hüfner
| AB_DATE Engineering Software | ab-date.de |
Unfortunately getting rid of the use of mdlCExpression API is not an option for this project. It would help considerably if we knew more about what was going on "under the hood." Currently when it crashes there isn't much in the way of clues for tracking down the root cause.
John Majerle said: getting rid of the use of mdlCExpression API is not an option
I agree, that would lead to a total rewrite of the program. I just talked about "mdlCExpression_getValue()", that one could often be replaced by other techniques. E.g. in hook-functions by "mdlDialog_itemGetValue()" or it could help to surround the call with "mdlResource_openFile()" and "mdlResource_closeFile()".
Volker HĂĽfner said:surround the call with "mdlResource_openFile()" and "mdlResource_closeFile()"
A clear usage case for the C++ Resource Acquisition is Initialisation (RAII) idiom.
struct MdlResourceManager { MdlResourceManager () { mdlResource_openFile(...); } ~MdlResourceManager () { mdlResource_closeFile(...); } ... other methods };
Usage...
void SomeFunctionThatNeedsResourceData () { MdlResourceManager resource; resource.GetData (...); // Resource file closed automatically by MdlResourceManager destructor }
Regards, Jon Summers LA Solutions
Jon Summers said:A clear usage case for the C++ Resource Acquisition is Initialisation (RAII) idiom.
NIce and clear sample. Thanks for sharing!
Hi,
My guess is you are performing an evaluate of an expression which is referencing something in one of your freed symbol sets. I would start by commenting out the free of the symbol sets and see if the crash still occurs. Also it would be helpful to understand how your application is architected. Do you have multiple mdlDescr's one for each dll ? etc. what commands are you sending, are you unloading anything etc....
I would also not believe that call stack. When looking at crashes I no longer trust the exception log. The minidump generated is much better.
Regards
Paul
All very good suggestions but none of them panned out for me. After some intense debugging I tracked down a clue. The crashes occur when the expression to be evaluated contains the the function ceil(). For example:
"ceil(__AREA__*wt*150)"
If I change this to:
"__AREA__*wt*150"
The crashes disappears. I verified that both __AREA__ and wt evaluate. I also verified that I could get it to crash with:
"ceil(4950)"
Interesting that the expression repeatedly works fine until I unload/reload the dll.
The function ceil is from the C math library and not published by my code.
I also tried:
So it appears mdlCExpression recognizes ceil() but sometimes chokes on the function call.
Any theories as to why?
Good work, Holmes!
John Majerle said:The crashes occur when the expression to be evaluated contains the the function ceil()
Did that expression work in an earlier version of MicroStation?
Yes. And it works in this version as well. The problem is that it randomly crashes.
John Majerle said:The problem is that it randomly crashes
What are the declarations of __AREA__ and wt?
__AREA__
wt
Are they declared in the same DLL as they are used?
Where are they initialized?