LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I actively develop a DLL while interfacing with LabVIEW?

Solved!
Go to solution

Hi all,

 

I'm writing a DLL that will later be interfaced with some LabVIEW code. Because of LabVIEW's locking behavior on DLL's, I've written a wrapper DLL which calls my DLL function at runtime, so I can continue developing on the main DLL without having to close and reopen LabVIEW all the time. The problem is that the main DLL still has a lock on it, even though I've properly freed the library resource when I'm done calling the function.

 

In debugging, I've used WinDbg and found that LabVIEW has reached a breakpoint, but lacking debug symbols am unable to see how or why LabVIEW is on an internal breakpoint. Here's my WinDbg output:

Microsoft (R) Windows Debugger Version 10.0.17763.1 AMD64
Copyright (c) Microsoft Corporation. All rights reserved.

*** wait with pending attach
Symbol search path is: srv*
Executable search path is: 
ModLoad: 00000000`00400000 00000000`02a6f000   C:\Program Files (x86)\National Instruments\LabVIEW 2013\LabVIEW.exe
ModLoad: 00007ffe`9f960000 00007ffe`9fb41000   C:\WINDOWS\SYSTEM32\ntdll.dll
ModLoad: 00000000`77070000 00000000`77200000   ntdll.dll
ModLoad: 00000000`76f80000 00000000`76fd2000   C:\WINDOWS\System32\wow64.dll
ModLoad: 00000000`76ff0000 00000000`77068000   C:\WINDOWS\System32\wow64win.dll
ModLoad: 00000000`76fe0000 00000000`76fea000   C:\WINDOWS\System32\wow64cpu.dll
ModLoad: 00000000`75c70000 00000000`75d50000   KERNEL32.dll
ModLoad: 00000000`75070000 00000000`75254000   KERNELBASE.dll
ModLoad: 00000000`75b00000 00000000`75b78000   ADVAPI32.dll
ModLoad: 00000000`757e0000 00000000`7589f000   msvcrt.dll
ModLoad: 00000000`716e0000 00000000`716e8000   WSOCK32.dll
ModLoad: 00000000`75d90000 00000000`75dd4000   SECHOST.dll
ModLoad: 00000000`76b80000 00000000`76be7000   WS2_32.dll
ModLoad: 00000000`76890000 00000000`76950000   RPCRT4.dll
ModLoad: 00000000`73930000 00000000`73950000   SspiCli.dll
ModLoad: 00000000`73920000 00000000`7392a000   CRYPTBASE.dll
ModLoad: 00000000`76ee0000 00000000`76f38000   bcryptPrimitives.dll
ModLoad: 00000000`73950000 00000000`74c9a000   SHELL32.dll
ModLoad: 00000000`76f40000 00000000`76f79000   CFGMGR32.dll
ModLoad: 00000000`76db0000 00000000`76ece000   ucrtbase.dll
ModLoad: 00000000`75b80000 00000000`75c08000   SHCORE.dll
ModLoad: 00000000`758a0000 00000000`75afc000   combase.dll
ModLoad: 00000000`75f40000 00000000`764f9000   Windows.Storage.dll
ModLoad: 00000000`76bf0000 00000000`76c35000   SHLWAPI.dll
ModLoad: 00000000`769d0000 00000000`769f2000   GDI32.dll
ModLoad: 00000000`74ca0000 00000000`74e04000   gdi32full.dll
ModLoad: 00000000`76950000 00000000`769cd000   msvcp_win.dll
ModLoad: 00000000`766c0000 00000000`7684d000   USER32.dll
ModLoad: 00000000`75d50000 00000000`75d67000   win32u.dll
ModLoad: 00000000`76510000 00000000`7651f000   AppCore.dll
ModLoad: 00000000`74e10000 00000000`74e28000   profapi.dll
ModLoad: 00000000`75020000 00000000`75065000   POWRPROF.dll
ModLoad: 00000000`76500000 00000000`76508000   FLTLIB.DLL
ModLoad: 00000000`74e30000 00000000`74ec6000   OLEAUT32.dll
ModLoad: 00000000`75df0000 00000000`75eec000   ole32.dll
ModLoad: 00000000`74ed0000 00000000`74fa6000   COMDLG32.dll
ModLoad: 00000000`75d70000 00000000`75d89000   imagehlp.dll
ModLoad: 00000000`76850000 00000000`76876000   IMM32.dll
ModLoad: 00000000`74fb0000 00000000`74fb6000   PSAPI.DLL
ModLoad: 00000000`71de0000 00000000`71e04000   WINMM.dll
ModLoad: 00000000`6ccc0000 00000000`6cec4000   COMCTL32.dll
ModLoad: 00000000`728f0000 00000000`728f8000   VERSION.dll
ModLoad: 00000000`721a0000 00000000`7220d000   WINSPOOL.DRV
ModLoad: 00000000`71e10000 00000000`71eb3000   MSVCR90.dll
ModLoad: 00000000`71ec0000 00000000`71f4e000   MSVCP90.dll
ModLoad: 00000000`71f50000 00000000`720bb000   gdiplus.dll
ModLoad: 00000000`71530000 00000000`71560000   IPHLPAPI.DLL
ModLoad: 00000000`71500000 00000000`71523000   WINMMBASE.dll
ModLoad: 00000000`71560000 00000000`716e0000   PROPSYS.dll
ModLoad: 00000000`72af0000 00000000`72b09000   bcrypt.dll
ModLoad: 00000000`10000000 00000000`100b1000   mgcore_SH_13_0.dll
ModLoad: 00000000`03020000 00000000`03041000   niCPULib.dll
ModLoad: 00000000`04d70000 00000000`05012000   dfir_13_0.dll
ModLoad: 00000000`05120000 00000000`0524e000   tdcore_13_0.dll
ModLoad: 00000000`72be0000 00000000`72d62000   dbghelp.dll
ModLoad: 00000000`72bb0000 00000000`72bd5000   dbgcore.dll
ModLoad: 00000000`72120000 00000000`7219c000   UxTheme.dll
ModLoad: 00000000`75260000 00000000`753a3000   MSCTF.dll
ModLoad: 00000000`76af0000 00000000`76b73000   CLBCatQ.DLL
ModLoad: 00000000`6b010000 00000000`6b410000   EXPLORERFRAME.dll
ModLoad: 00000000`058e0000 00000000`058ec000   QtManager452_2013.dll
ModLoad: 00000000`67000000 00000000`67221000   NIQtCore_2013.dll
ModLoad: 00000000`65000000 00000000`657b3000   NIQtGui_2013.dll
ModLoad: 00000000`6c9e0000 00000000`6ca03000   dwmapi.dll
ModLoad: 00000000`05ec0000 00000000`06023000   nilmClient.dll
ModLoad: 00000000`753b0000 00000000`757db000   SETUPAPI.dll
ModLoad: 00000000`12000000 00000000`12241000   xerces-c_2_6.dll
ModLoad: 00000000`7c3c0000 00000000`7c43c000   MSVCP71.dll
ModLoad: 00000000`6ca50000 00000000`6ca63000   NETAPI32.dll
ModLoad: 00000000`7c360000 00000000`7c3b6000   MSVCR71.dll
ModLoad: 00000000`06030000 00000000`06074000   xerces-depdom_2_6.dll
ModLoad: 00000000`72b30000 00000000`72b43000   CRYPTSP.dll
ModLoad: 00000000`72ac0000 00000000`72aef000   RSAENH.dll
ModLoad: 00000000`75de0000 00000000`75de7000   NSI.dll 
ModLoad: 00000000`53400000 00000000`53403000   icmp.dll
ModLoad: 00000000`6c9c0000 00000000`6c9d1000   NAPINSP.dll
ModLoad: 00000000`6c9a0000 00000000`6c9b6000   PNRPNSP.dll
ModLoad: 00000000`6c980000 00000000`6c993000   nlaapi.dll
ModLoad: 00000000`72b50000 00000000`72ba6000   MSWSOCK.dll
ModLoad: 00000000`6d2f0000 00000000`6d37e000   DNSAPI.dll
ModLoad: 00000000`6c970000 00000000`6c97c000   WINRNR.dll
ModLoad: 00000000`6d380000 00000000`6d3cf000   fwpuclnt.dll
ModLoad: 00000000`6c960000 00000000`6c968000   rasadhlp.dll
ModLoad: 00000000`69570000 00000000`69576000   InjectionDll.dll
ModLoad: 00000000`061e0000 00000000`061e6000   nilmWizard.dll
ModLoad: 00000000`28000000 00000000`28030000   nicont.DLL
ModLoad: 00000000`76a00000 00000000`76a60000   coml2.dll
ModLoad: 00000000`65e90000 00000000`65f1e000   mscms.dll
ModLoad: 00000000`72a90000 00000000`72ab1000   USERENV.dll
ModLoad: 00000000`68b20000 00000000`68b2c000   ColorAdapterClient.dll
ModLoad: 00000000`65e50000 00000000`65e8e000   ICM32.dll
ModLoad: 00000000`09840000 00000000`098dd000   nitaglv.dll
ModLoad: 00000000`098e0000 00000000`0995d000   LKSOCK.dll
ModLoad: 00000000`09960000 00000000`09989000   LKSEC.dll
ModLoad: 00000000`09990000 00000000`099c9000   LKBROW.dll
ModLoad: 00000000`099d0000 00000000`09a0a000   LKDYNAM.dll
ModLoad: 00000000`09a40000 00000000`09a9a000   LKREALT.dll
ModLoad: 00000000`38130000 00000000`3817d000   nilvicv_hostdeploy.dll
ModLoad: 00000000`28400000 00000000`2844c000   NICONTDT.DLL
ModLoad: 00000000`456e0000 00000000`4575e000   RICHED20.dll
ModLoad: 00000000`692a0000 00000000`692b7000   USP10.dll
ModLoad: 00000000`0f330000 00000000`0f362000   msls31.dll
ModLoad: 00000000`63800000 00000000`63813000   NiSpyLog.dll
ModLoad: 00000000`0af80000 00000000`0afe3000   CallistoLV.dll
ModLoad: 00000000`0b000000 00000000`0b07d000   lvdaq.mxx
ModLoad: 00000000`6d280000 00000000`6d2b5000   nimdbgu.dll
ModLoad: 00000000`6e0c0000 00000000`6e0df000   nimercu.dll
ModLoad: 00000000`6db40000 00000000`6df26000   nidmxfu.dll
ModLoad: 00000000`6df50000 00000000`6e07b000   nilvaiu.dll
ModLoad: 00000000`6c3f0000 00000000`6c78d000   mfc90.dll
ModLoad: 00000000`6d000000 00000000`6d01c000   niorbu.dll
ModLoad: 00000000`6d0f0000 00000000`6d139000   nimxdfu.dll
ModLoad: 00000000`6e2c0000 00000000`6e2dc000   nimstsu.dll
ModLoad: 00000000`64580000 00000000`645e7000   NIPALU.dll
ModLoad: 00000000`6e0e0000 00000000`6e1c7000   nimhwcfu.dll
ModLoad: 00000000`6ec70000 00000000`6ecb8000   nimru2u.dll
ModLoad: 00000000`72290000 00000000`72296000   MSIMG32.dll
ModLoad: 00000000`64600000 00000000`64618000   nirpc.dll
ModLoad: 00000000`64500000 00000000`64506000   nipalut.dll
ModLoad: 00000000`1f700000 00000000`1f708000   NIPAL32.dll
ModLoad: 00000000`63550000 00000000`6355b000   nimdnsResponder.dll
ModLoad: 00000000`6d050000 00000000`6d07a000   nidimu.dll
ModLoad: 00000000`72e90000 00000000`73295000   WININET.dll
ModLoad: 00000000`6c100000 00000000`6c1b0000   WINHTTP.dll
ModLoad: 00000000`0b680000 00000000`0b6b0000   nicrtsiu.dll
ModLoad: 00000000`0b6b0000 00000000`0b6b9000   niprtsiu.dll
ModLoad: 00000000`5d360000 00000000`5d36d000   image00000000`5d360000
ModLoad: 00000000`36000000 00000000`360aa000   lvdesktop.mxx
ModLoad: 00000000`39800000 00000000`3989d000   lvelemio.mxx
ModLoad: 00000000`39900000 00000000`39a51000   lvfpga.mxx
ModLoad: 00000000`36500000 00000000`36511000   LvProjectProxy.mxx
ModLoad: 00000000`07b50000 00000000`07bbf000   LvRealTimeCoreProvider.mxx
ModLoad: 00000000`07bd0000 00000000`07bdd000   SystemStateClient.dll
ModLoad: 00000000`07be0000 00000000`07c0d000   lvRemoteWindows.mxx
ModLoad: 00000000`07c30000 00000000`07c8b000   lvrt_cvs.mxx
ModLoad: 00000000`07cb0000 00000000`07d0d000   lvrt_evs.mxx
ModLoad: 00000000`07d30000 00000000`07d8c000   lvrt_smartcamera.mxx
ModLoad: 00000000`07db0000 00000000`07e32000   LvTargetCoreProvider.mxx
ModLoad: 00000000`36700000 00000000`3678d000   MVEProvider.mxx
ModLoad: 00000000`61000000 00000000`61060000   NIQtXml_2013.dll
ModLoad: 00000000`36800000 00000000`36877000   mxLvProvider.mxx
ModLoad: 00000000`12c00000 00000000`12c1f000   mxwProjectProvider.mxx
ModLoad: 00000000`78230000 00000000`782ef000   MSVCR100.dll
ModLoad: 00000000`774c0000 00000000`77529000   MSVCP100.dll
ModLoad: 00000000`12f40000 00000000`13339000   mxwTask.dll
ModLoad: 00000000`78970000 00000000`78996000   ATL100.DLL
ModLoad: 00000000`11280000 00000000`114f9000   mxwRCENU.dll
ModLoad: 00000000`0bab0000 00000000`0bad8000   nimxlcpp.mxx
ModLoad: 00000000`6a7a0000 00000000`6a7b5000   nimxlc.dll
ModLoad: 00000000`36100000 00000000`36191000   variable.mxx
ModLoad: 00000000`0bcb0000 00000000`0bd5d000   ws_project_provider.mxx
ModLoad: 00000000`0bd60000 00000000`0bdd2000   lvMax.dll
ModLoad: 00000000`0bde0000 00000000`0be4f000   nidp_host_end.dll
ModLoad: 00000000`39b00000 00000000`39b78000   lvfpga_runt.dll
ModLoad: 00000000`1bfa0000 00000000`1bfc9000   nimaximp.dll
ModLoad: 00000000`0c0f0000 00000000`0c147000   nierInterface.dll
ModLoad: 00000000`0c170000 00000000`0c18a000   ni_traceengine.dll
ModLoad: 00000000`0de30000 00000000`0df5a000   lvanlys.dll
ModLoad: 00000000`0ea60000 00000000`0f16c000   LV130000_BLASLAPACK.dll
ModLoad: 00000000`0cd30000 00000000`0cd64000   niceipcore.dll
ModLoad: 00000000`69100000 00000000`6914f000   DataExchange.dll
ModLoad: 00000000`68ea0000 00000000`690f2000   d3d11.dll
ModLoad: 00000000`68d60000 00000000`68e9c000   dcomp.dll
ModLoad: 00000000`68cc0000 00000000`68d58000   dxgi.dll
ModLoad: 00000000`68b50000 00000000`68cb5000   twinapi.appcore.dll
ModLoad: 00000000`68b30000 00000000`68b4a000   RMCLIENT.dll
ModLoad: 00000000`12a50000 00000000`12b32000   mesa.dll
ModLoad: 00000000`68510000 00000000`6858d000   TextInputFramework.dll
ModLoad: 00000000`67e20000 00000000`67eab000   CoreMessaging.dll
ModLoad: 00000000`17d50000 00000000`17fad000   CoreUIComponents.dll
ModLoad: 00000000`6c1d0000 00000000`6c1f9000   NTMARTA.dll
ModLoad: 00000000`6b560000 00000000`6b636000   WinTypes.dll
ModLoad: 00000000`02b60000 00000000`02b6e000   imt-wrapper.dll
ModLoad: 00000000`02c60000 00000000`02c7b000   VCRUNTIME140D.dll
ModLoad: 00000000`187b0000 00000000`18924000   ucrtbased.dll
ModLoad: 00000000`02c80000 00000000`02c8f000   imt.dll 
(da80.6a6c): Break instruction exception - code 80000003 (first chance)
ntdll!DbgBreakPoint:
00007ffe`9f9fd8d0 cc              int     3
0:025> !gle
LastErrorValue: (Win32) 0 (0) - The operation completed successfully.
LastStatusValue: (NTSTATUS) 0 - STATUS_SUCCESS
Wow64 TEB status: 3702784
LastErrorValue: (Win32) 0 (0) - The operation completed successfully.
LastStatusValue: (NTSTATUS) 0 - STATUS_SUCCESS
0:025> .exr -1
ExceptionAddress: 00007ffe9f9fd8d0 (ntdll!DbgBreakPoint)
   ExceptionCode: 80000003 (Break instruction exception)
  ExceptionFlags: 00000000
NumberParameters: 1
   Parameter[0]: 0000000000000000
0:025> !analyze -v
*******************************************************************************
*                                                                             *
*                        Exception Analysis                                   *
*                                                                             *
*******************************************************************************

*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\Program Files (x86)\National Instruments\LabVIEW 2013\LabVIEW.exe - 
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for mgcore_SH_13_0.dll - 
GetUrlPageData2 (WinHttp) failed: 12007.

KEY_VALUES_STRING: 1


STACKHASH_ANALYSIS: 1

TIMELINE_ANALYSIS: 1

Timeline: !analyze.Start
    Name: <blank>
    Time: 2019-01-29T19:59:00.700Z
    Diff: 700 mSec

Timeline: Dump.Current
    Name: <blank>
    Time: 2019-01-29T19:59:00.0Z
    Diff: 0 mSec

Timeline: Process.Start
    Name: <blank>
    Time: 2019-01-29T19:50:02.0Z
    Diff: 538000 mSec

Timeline: OS.Boot
    Name: <blank>
    Time: 2019-01-29T03:10:58.0Z
    Diff: 60482000 mSec


DUMP_CLASS: 2

DUMP_QUALIFIER: 0

FAULTING_IP: 
ntdll!DbgBreakPoint+0
00007ffe`9f9fd8d0 cc              int     3

EXCEPTION_RECORD:  (.exr -1)
ExceptionAddress: 00007ffe9f9fd8d0 (ntdll!DbgBreakPoint)
   ExceptionCode: 80000003 (Break instruction exception)
  ExceptionFlags: 00000000
NumberParameters: 1
   Parameter[0]: 0000000000000000

FAULTING_THREAD:  00006a6c

BUGCHECK_STR:  BREAKPOINT

DEFAULT_BUCKET_ID:  BREAKPOINT

ERROR_CODE: (NTSTATUS) 0x80000003 - {EXCEPTION}  Breakpoint  A breakpoint has been reached.

EXCEPTION_CODE: (HRESULT) 0x80000003 (2147483651) - One or more arguments are invalid

EXCEPTION_CODE_STR:  80000003

EXCEPTION_PARAMETER1:  0000000000000000

WATSON_BKT_PROCSTAMP:  533c6210

WATSON_BKT_PROCVER:  13.0.1.4020

PROCESS_VER_PRODUCT:  National Instruments LabVIEW

WATSON_BKT_MODULE:  ntdll.dll

WATSON_BKT_MODSTAMP:  60d78cf9

WATSON_BKT_MODOFFSET:  9d8d0

WATSON_BKT_MODVER:  10.0.17134.376

MODULE_VER_PRODUCT:  Microsoft® Windows® Operating System

BUILD_VERSION_STRING:  17134.1.amd64fre.rs4_release.180410-1804

MODLIST_WITH_TSCHKSUM_HASH:  f200853ba633a847c8d03a15d7c62a09fff6b561

MODLIST_SHA1_HASH:  5529edf10d24079311335b0c868559c736add5c7

NTGLOBALFLAG:  0

PROCESS_BAM_CURRENT_THROTTLED: 0

PROCESS_BAM_PREVIOUS_THROTTLED: 0

APPLICATION_VERIFIER_FLAGS:  0

PRODUCT_TYPE:  1

SUITE_MASK:  272

DUMP_TYPE:  fe

PROCESS_NAME:  unknown

ANALYSIS_SESSION_HOST:  JEREMY-PC

ANALYSIS_SESSION_TIME:  01-29-2019 14:59:00.0700

ANALYSIS_VERSION: 10.0.17763.1 amd64fre

THREAD_ATTRIBUTES: 
OS_LOCALE:  ENU

PRIMARY_PROBLEM_CLASS:  BREAKPOINT

PROBLEM_CLASSES: 

    ID:     [0n321]
    Type:   [@APPLICATION_FAULT_STRING]
    Class:  Primary
    Scope:  DEFAULT_BUCKET_ID (Failure Bucket ID prefix)
            BUCKET_ID
    Name:   Omit
    Data:   Add
            String: [BREAKPOINT]
    PID:    [Unspecified]
    TID:    [Unspecified]
    Frame:  [0]

STACK_TEXT:  
00000000`02bdfc78 00007ffe`9fa29a4b : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!DbgBreakPoint
00000000`02bdfc80 00007ffe`9f9d147f : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!DbgUiRemoteBreakin+0x4b
00000000`02bdfcb0 00000000`00000000 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!RtlUserThreadStart+0x2f


THREAD_SHA1_HASH_MOD_FUNC:  7022ac660180cc117dbba4701e87bc997be1e021

THREAD_SHA1_HASH_MOD_FUNC_OFFSET:  8612d4bd97ca375e13535eeed5263302dc2a124c

THREAD_SHA1_HASH_MOD:  ec3b5fdb1c6f649ec34d8fd34d70509a58a63226

FOLLOWUP_IP: 
ntdll!DbgBreakPoint+0
00007ffe`9f9fd8d0 cc              int     3

FAULT_INSTR_CODE:  ccccc3cc

SYMBOL_STACK_INDEX:  0

SYMBOL_NAME:  ntdll!DbgBreakPoint+0

FOLLOWUP_NAME:  MachineOwner

MODULE_NAME: ntdll

IMAGE_NAME:  ntdll.dll

DEBUG_FLR_IMAGE_TIMESTAMP:  60d78cf9

STACK_COMMAND:  ~25s ; .cxr ; kb

BUCKET_ID:  MANUAL_BREAKIN

FAILURE_EXCEPTION_CODE:  80000003

FAILURE_IMAGE_NAME:  ntdll.dll

BUCKET_ID_IMAGE_STR:  ntdll.dll

FAILURE_MODULE_NAME:  ntdll

BUCKET_ID_MODULE_STR:  ntdll

FAILURE_FUNCTION_NAME:  DbgBreakPoint

BUCKET_ID_FUNCTION_STR:  DbgBreakPoint

BUCKET_ID_OFFSET:  0

BUCKET_ID_MODTIMEDATESTAMP:  60d78cf9

BUCKET_ID_MODCHECKSUM:  1df93f

BUCKET_ID_MODVER_STR:  10.0.17134.376

BUCKET_ID_PREFIX_STR:  MANUAL_BREAKIN

FAILURE_PROBLEM_CLASS:  BREAKPOINT

FAILURE_SYMBOL_NAME:  ntdll.dll!DbgBreakPoint

FAILURE_BUCKET_ID:  BREAKPOINT_80000003_ntdll.dll!DbgBreakPoint

WATSON_STAGEONE_URL:  http://watson.microsoft.com/StageOne/unknown/13.0.1.4020/533c6210/ntdll.dll/10.0.17134.376/60d78cf9/80000003/0009d8d0.htm?Retriage=1

TARGET_TIME:  2019-01-29T19:59:05.000Z

OSBUILD:  17134

OSSERVICEPACK:  1

SERVICEPACK_NUMBER: 0

OS_REVISION: 0

OSPLATFORM_TYPE:  x64

OSNAME:  Windows 10

OSEDITION:  Windows 10 WinNt SingleUserTS

USER_LCID:  0

OSBUILD_TIMESTAMP:  unknown_date

BUILDDATESTAMP_STR:  180410-1804

BUILDLAB_STR:  rs4_release

BUILDOSVER_STR:  10.0.17134.1.amd64fre.rs4_release.180410-1804

ANALYSIS_SESSION_ELAPSED_TIME:  1363

ANALYSIS_SOURCE:  UM

FAILURE_ID_HASH_STRING:  um:breakpoint_80000003_ntdll.dll!dbgbreakpoint

FAILURE_ID_HASH:  {1d20f983-583a-5d58-a854-5c812a87c587}

Followup:     MachineOwner
---------

In particular, the following segments are relevant:

ERROR_CODE: (NTSTATUS) 0x80000003 - {EXCEPTION}  Breakpoint  A breakpoint has been reached.

EXCEPTION_CODE: (HRESULT) 0x80000003 (2147483651) - One or more arguments are invalid

---

ModLoad: 00000000`02b60000 00000000`02b6e000   imt-wrapper.dll
ModLoad: 00000000`02c60000 00000000`02c7b000   VCRUNTIME140D.dll
ModLoad: 00000000`187b0000 00000000`18924000   ucrtbased.dll
ModLoad: 00000000`02c80000 00000000`02c8f000   imt.dll 
(da80.6a6c): Break instruction exception - code 80000003 (first chance)
ntdll!DbgBreakPoint:
00007ffe`9f9fd8d0 cc              int     3



imt-wrapper is the wrapper around the main dll, imt.dll.

 

Here's the main .cpp file for imt-wrapper.dll. Can provide full project files to build if need be, but it's pretty much the same code everyone else uses out on StackOverflow and otherwise.

// imt-wrapper-dll.cpp : Defines the entry point for the application.
//

#include <windows.h>
#include <string>
#include "imt-wrapper-dll.h"

const LPCSTR dll_path = "C:\\Users\\Jeremy\\Desktop\\LV_devel\\imt-c-controller\\win64\\lib\\Debug\\imt.dll";

/* Define a function pointer for our imported
 * function.
 * This reads as "introduce the new type f_funci as the type:
 *                pointer to a function returning an int and
 *                taking no arguments.
 *
 * Make sure to use matching calling convention (__cdecl, __stdcall, ...)
 * with the exported function. __stdcall is the convention used by the WinAPI
 */
typedef int(__cdecl *ctx_check_t)(const void *);

// could be templated in the future
__declspec(dllexport) int __cdecl LV_check_context(const void *ctx_ext)
{
	HINSTANCE hGetProcIDDLL = LoadLibrary(dll_path);

	if (!hGetProcIDDLL) {
		return -100;
	}

	// resolve function address here
	ctx_check_t ctx_check = (ctx_check_t)GetProcAddress(hGetProcIDDLL, "imt_check_context");
	BOOL fResult = FreeLibrary(hGetProcIDDLL);
	if (!fResult) {
		return -101;
	}
	if (!ctx_check) {
		return -102;
	}

	return ctx_check(ctx_ext);
}

All the header file has is the extern declaration for `LV_check_context`.

 

If it helps, both dll's are built with CMake 3.8, Visual Studio 2017 Community Edition, on a Debug release configuration.

0 Kudos
Message 1 of 5
(4,324 Views)

Here's the code within imt.dll that we're attempting to call. This all works fine in LabVIEW, by the way! I just need it to not lock the main DLL.

 

int imt_check_context(const void *ctx_ext)
{
	if(!ctx_ext) {
		return -1;
	}

	imt_context_t *ctx = (imt_context_t *) ctx_ext;
	// TODO: error codes, define them
	enum imt_error_t {
		I_OKAY = 0,
		I_CHK_WEIGHT,
		I_CHK_CONC,
		I_CHK_RANGE,
		I_CHK_CAP,
		I_CHK_CYCLE_LENGTH,
		I_CHK_XN,
		I_CHK_DEXVAR,
		I_CHK_INSVAR,
		I_CHK_MISC,
	};

#define CHK(var_, min_, max_, ret_) \
do {\
	if((ctx->var_) < (min_) || (ctx->var_) > (max_)) return ret_;\
} while(0)

	CHK(weight, 0.0, 500.0, I_CHK_WEIGHT);
	CHK(INS_concentration, 0.1, 10.0, I_CHK_CONC);
	CHK(DEX_concentration, 10.0, 100.0, I_CHK_CONC);
	CHK(Xmin, 60.0, 180.0, I_CHK_RANGE);
	CHK(Xmax, ctx->Xmin + 40.0, 200.0, I_CHK_RANGE);

	return I_OKAY;
}

and the definition for imt_context_t:

typedef double imt_float_t;
typedef int imt_int_t;

typedef struct imt_context_t {
	imt_float_t weight; // kg
	imt_float_t INS_concentration; // U/mL
	imt_float_t DEX_concentration; // g/100mL
	imt_float_t Xmin; // mg/dL
	imt_float_t Xmax; // mg/dL
	imt_float_t INS_flow_cap; // U/kg/hr
	imt_float_t DEX_flow_cap; // mg/kg/min
	imt_float_t long_cycle_length; // mins
	/* glucose variables */
	imt_float_t Xa;
	imt_float_t Xb;
	imt_float_t Xc;
	/* dextrose variables */
	imt_float_t DEXfp;
	imt_float_t DEXfn;
	imt_float_t DEXfn2c;
	imt_float_t DEXfn3c;
	imt_float_t DEX_bolus;
	imt_float_t DEX_bolus_minus1;
	imt_float_t DEX_bolus_minus2;
	imt_float_t DEX_bolus_minus3;
	imt_float_t DEX_pump;
	imt_float_t DEXfn3c_cap;
	imt_float_t DEX_pump_cap;
	/* insulin variables */
	imt_float_t INSfp_minus1;
	imt_float_t INSfp;
	imt_float_t INSfn;
	imt_float_t INSfn2c;
	imt_float_t INS_pump;
	imt_float_t INSfn2c_cap;
	imt_float_t INS_pump_cap;
	/* time controller variables */
	imt_int_t next_cycle_5min;
	imt_int_t _5min_bt_Xa_Xb;
	imt_int_t _5min_bt_Xb_Xc;
	/* flags */
	imt_int_t tertiary_active;
} imt_context_t;

As you can see, no breakpoints, all vanilla C, so no exceptions either.

 

I've also attached the VI I'm using to test the DLL, it's quite simple.

0 Kudos
Message 2 of 5
(4,322 Views)

Just tried to use LoadLibraryEx, as my DLL doesn't use a DLLMain function (which is allowed). No change, main DLL still locked.

 

	HINSTANCE hGetProcIDDLL = LoadLibraryEx(dll_path, NULL, DONT_RESOLVE_DLL_REFERENCES);
0 Kudos
Message 3 of 5
(4,305 Views)
Solution
Accepted by topic author ijustlovemath

Empty path will unload a dll. See this.

 

I would try something like this

dll unload.PNG

Message 4 of 5
(4,291 Views)

Thank you for saving me from WinDbg hell! This should be mentioned on the KB article that talks about how to build DLL's, avoiding the need to do this:

 

> Calling the DLL from another C program is also an excellent way to debug your DLL. By doing this, you have a means of testing your DLL independent of LabVIEW, thus helping you identify possible problems sooner.

 

http://www.ni.com/white-paper/4877/en/

0 Kudos
Message 5 of 5
(4,280 Views)