Labview Crashes after DLL call

HI All,
I am working on to write a wrapper to a dll. The call to dll works fine an returns appropriate values but as soon as i close the VI the LabVIEW dev environment crashes. Any help on avoiding the same. I went through a lot of posts and tried varing the types of data being sent to the dll but still it gets crashed.
the dll function I am using is of the prototype(with C type call convention)
int functionName(Struct *cfg, UCHAR dNumber, UCHAR hTYPE)
The UCHAR varables I am passing as Unsigned 8-bit Integers.
For the structure I have made a cluster and am passing with Adapt to Type and as Handles.
The DLL executes fine and the VI stops too, but as soon as i try to close the VI the dev environment crashes. Please help.
Thanks.
Solved!
Go to Solution.

While nathand is right about possible other errors, the Struct that you fail to tell anything about is a big flag pole for something that might be going wrong. Show us the C header declaring the structure and function and attach the VI you created (please no BMP or other image! They do say a picture says more than thousend words, but in the case of a LabVIEW diagram a picture is not enough to show all aspects of a VI, especially things like how the Call Library Node is configured!)
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions

Similar Messages

  • LabVIEW crashes after VI (calls DLL to post Windows Msg) exits

    I built a DLL in Visual C++ and I use LabVIEW 7.1 to call it (using the Call Library function).
    When I run the LabVIEW VI without the 'post windows message' functionality in the DLL, it works fine and exits LabVIEW without a problem. If the DLL posts a message, and the code from the link below is used to catch the meassage, the VI appears to have executed and exit correctly, allowing other VIs to be run, etc, but when the VI is closed, LabVIEW stops responding. If it is the only VI open, then it closes leaving the LabVIEW window minimized (and unresponsive) in the Taskbar. Both DLLs successfully detached from LV before the VI stops running.
    http://sine.ni.com/apps/we/niepd_web_display.DISPLAY_EPD4?p_guid=B45EACE3E7AC56A4E034080020E74861&p_node=DZ52071&p_submitted=N&p_rank=&p_answer=&p_source=External

    Hi,
    can you post your code here so we can try to reproduce it?
    It sounds as if the handles aren't being released in the right order. i.e. LabVIEW will hold onto a DLL until the vi using it goes out of memory.
    I think from your description you have a DLL which posts a message, and then you're using the example code which was written for LabVIEW 5.0 to read that windows message?
    What message are you sending?
    When you say the DLL has detached, is that process detach or thread detach?
    What version of LabVIEW are you using?
    What operating system?
    What version of Visual C++?
    Thanks
    Sacha Emery
    National Instruments (UK)
    // it takes almost no time to rate an answer

  • After update to Firefox 15 it crashes after javascript call window.close();opener.alert('test');. Is this working as intended or is it a bug?

    After update to Firefox 15 it crashes after javascript call from a popup window.close();opener.alert('test');. Is this working as intended or is it a bug?

    According to the pages linked to the crash ID, there is a bug report on this.
    Does the crash occur as soon as you run those two lines of code, or after dismissing the alert()?
    If this is your application, why are you running script commands after calling window.close()? Could you avoid the problem by using an approach like this:
    <br>window.setTimeout(function(){opener.alert('test'},250);
    window.close();

  • Phone crashes after every call

    My Droid crashes after every call.  I have to remove the battery and reboot the phone.  (Am running Droid 2.1).
    Verizon - this isn't even funny any more.  What's up with this?

    I haven't seen this before and it sounds really strange.
    Have you tried restoring you phone to "factory defaults". It is quite possible something that you have installed is conflicting somewhere, but it's really hard to guess what it might be.
    Also, while some of the VZW technical people do hang out here and answer questions, you're probably better off contacting VZW Customer Service with this one. You can reach them by dialing 611 on your mobile (which, in this case I wouldn't recommend) or at (800) 922-0204.
    jason

  • Labview crashing - running dll. motorbee

    Hi, I'm a student doing my masters project.
    I'm trying to run a dc motor with the driver board and software called motorway from pc-control.co.uk
    The board came with some software to run it and I have the dll. and header files.
    I have managed to import the files, however whenever I try and run the "set motors" vi, labview crashes for no reason and doesn't give an error code.
    The files can be found here https://www.dropbox.com/sh/0nbrx0ncyfg58y0/rKMy9iMAKE
    Thanks a lot for any help as I don't have much time to complete my project!
    Cheers
    Henry
    Attachments:
    mt.h ‏1 KB

    Hello, can you please post your LabVIEW code so I can look at the error in order to be able to help.
    Thank you

  • Anyone can prove JNI is safe? My application crashes after many calls.

    I heard that JNI is not safe. In fact I made an application base on many JNI calls.
    C level is API supplied by IBM. And I was told the C API is tested and safe.
    Java application and JNI calls is writen by myself. It crashed after about 3000 times call. I tried other JDK and other OS. On some platform, the thread hold there after many calls. No error, no crash. But others crashed even early.
    Here's my JNI call's code:
    JNIEXPORT void JNICALL Java_com_ibm_mm_sdk_cim_internal_PServiceFACImp_cEvaluate
    (JNIEnv *env, jclass jobj, jlong jhandle, jstring jmanualedListFilename, jstring jclassedListFileName, jstring jresultFilename){
         char *manualedListFilename = jstringToWindows(env, jmanualedListFilename);
         char *classedListFileName = jstringToWindows(env, jclassedListFileName);
         char *resultFilename = jstringToWindows(env, jresultFilename);
         int rc;                         // API return code
         void* handle;               // FAC Handle
         // convert C pointer from java long type
         handle = (void*)jhandle;
         rc = KmFAC_Evaluate(
              handle,                                   // FAC Handle
              (char*)manualedListFilename,     // File name of list of files
              (char*)classedListFileName,          // File name of list of files
              (char*)resultFilename               // Result file
         if (manualedListFilename)
              free(manualedListFilename);
         if (classedListFileName)
              free(classedListFileName);
         if (resultFilename)
              free(resultFilename);
         if (rc != KM_RC_OK) {
              //Throw exception
              jclass exceptClass;          // JNI exception class
              char errorMsg[256];          // Used to build error msg for exceptions
              jmethodID methodid;          // Exception constructor method id
              sprintf(errorMsg, "KmFAC_Evaluate() [CKM=%d]", (int)rc);
              exceptClass = env->FindClass("com/ibm/mm/sdk/cim/DKServiceExceptionCIM");
              methodid = env->GetMethodID(exceptClass,"<init>","(Ljava/lang/String;II)V");
              jstring str = env->NewStringUTF(errorMsg);
              jthrowable excobj = (jthrowable)env->NewObject(exceptClass,methodid,str,100, (int)rc);
              env->Throw(excobj);
         return;

    I agree with fury88. Try the code below it works fine!
    // **************** Java portion ************************
    public class Test {
    // Load the dll that exports functions callable from java
    static {System.loadLibrary("TestImp");}
    // Imported function declarations
    public native void print(String msg);
    public void Test() {
    public static void main(String [] args) {
    Test t = new Test();
    // Printf example
         t.print("->Testing JNI - Hello from c++\n");
    // **************** Windows portion - TestImp.dll **********************
    // Exported function
    JNIEXPORT void JNICALL Java_Test_print(JNIEnv *env, jobject obj, jstring msg)
    const char *str = env->GetStringUTFChars(msg, 0);
    printf("%s\n", str);
    env->ReleaseStringUTFChars(msg, str);
    // Entry point
    BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
         switch(ul_reason_for_call)
              case DLL_PROCESS_ATTACH:
                   return TRUE;
              case DLL_PROCESS_DETACH:
                   return TRUE;
    return TRUE;
    }

  • Skype crashes after answering call in windows 8.1

    My skype crashes after I answer a skype call in my brand new computer.
    Intel core i7 4790 
    Amd radeon 255 2 gb
    8 gb ram
    i'll leave my dxdiag file here.. please help me..
    Attachments:
    DxDiag.zip ‏12 KB

    Uninstall the currently installed Skype version and install the 6.14.0.104 version using the download links provided here:
    http://community.skype.com/t5/Windows-desktop-client/ASUS-USB2-0-Webcam-not-recognized-by-Skype-6-18...
    Make sure to disable automatic updates:
    Tools -> Options -> Advanced -> Automatic updates ->Turn off automatic updates

  • Iphone crashes after phone call

    My iphone 3gs will crash immediately after completing a phone call. I don't even hit "end call". Crashes as my lower the iphone from my ear. Need to do a reset each time. Any suggestions?

    Do you have a case on it?
    Try removing it and see if that helps. A case can block the proximity sensor.
    You can try a restore as well.
    http://manuals.info.apple.com/enUS/iPhone_UserGuide.pdf

  • LAbview crashing after long test

    Hi,
    I was wondering if anyone else has experienced this problem. I am
    running a long test (about 6 hours) and I am finding before it gets to
    the end, Labview shuts down. It is fine if I run the shorter version of
    the test and I am 99% sure it isn't anything in my program since it is
    all just repeating the same loop over and over again for different
    permutations of data (and since it doesn't crash in one particular
    spot).
    Any ideas? Suggestions?
    Thanks
    Jenni
    Sent via Deja.com http://www.deja.com/
    Share what you know. Learn what you don't.

    Thanks for your reply!
    Yes, I did check all of those things that you mentioned and don't think
    that any of them really apply. Do you think that it could be because of
    insufficient memory and/or Virtual memory since so many resources would
    likely be allocated during a long test?
    Thanks
    jenni
    In article <7nmuvd$hsv$[email protected]>,
    "Richard Jones" wrote:
    > Other things outside of Labview might be causing it.
    > Have you checked things like screensavers, automated virus scans, misc
    > network activity, bored security guard using PC to surf net after
    hours...
    > Just some ideas...
    >
    > [email protected] wrote in message <7nmsid$ppi$[email protected]>...
    > >Hi,
    > >
    > >I was wondering if anyone else has experienced this p
    roblem. I am
    > >running a long test (about 6 hours) and I am finding before it gets
    to
    > >the end, Labview shuts down. It is fine if I run the shorter version
    of
    > >the test and I am 99% sure it isn't anything in my program since it
    is
    > >all just repeating the same loop over and over again for different
    > >permutations of data (and since it doesn't crash in one particular
    > >spot).
    > >
    > >Any ideas? Suggestions?
    > >
    > >Thanks
    > >Jenni
    > >
    > >
    > >Sent via Deja.com http://www.deja.com/
    > >Share what you know. Learn what you don't.
    >
    >
    Sent via Deja.com http://www.deja.com/
    Share what you know. Learn what you don't.

  • Iphone crashes after missed calls or not answered calls

    Hi,
    I have an iphone5, version 6.1.4 and when I don't answer a call, y always found my iphone freeze, crashed!.
    You can see the information about the lost call in the screen, but the iphone doesn't work, you can only restart the iphone, but it's so irritating.
    I have asked some friends about the behaivor about their iphones and all of them told me that they have the same problem, with iphone4S, IOS7, etc.
    This problems starts since IOS 5 upgrade i think.
    Please can you help me?
    Regards
    Hugo Rosas

    Did you do any of the basic troubleshooting steps described in the User Guide?
    Restart
    Reset
    Restore in iTunes using a backup
    Restore as a new iPhone, without a backup

  • LabVIEW crashes when calling a dll

    I am trying to call a dll through my LabVIEW program. The dll implements a routine to access an ftp server. When the server is found, everything works as expected. However, if there is a delay in finding the server, LabVIEW throws an error � �An exception occured within the external code called by the Call Library Node�. The detailed error message is attached here.
    The dll function times out after 25 seconds if the server is not found (it returns a signed integer). This error message pops up after roughly 20 seconds.
    The dll was created in VC++ 6.0. It uses standard MFC calls.
    Any information about why this could be happening will be appreciated.
    Thanks.
    Attachments:
    LabVIEW_error.jpg ‏14 KB

    Hi,
    If you call a dll, everything should be just right, or it will crash (if you
    use LV7, you're lucky, most of the times LV stays alive, and only gives a
    message).
    The first thing that should be checked is the calling convention. This
    should probably be "stdcall (API)". This changes the way the parameters and
    return address are pushed to the stack.
    The second point are the parameters. Pointers should be set to pointers,
    LONG to i32 etc. The return parameter can always be set to i32, or to
    nothing.
    My best guess is (since the dll crashes after a while), there should be a
    pointer to a buffer (most likely a cluster, but could be a reference). The
    connection succeeds, and the dll copies the information to the pointer. If
    the pointer is not valid (the memory does
    not belong to LabVIEW), an
    exception is raised.
    Perhaps you can give a function prototype? The prototype is the way to
    start.
    Regards,
    Wiebe.
    "gopinath" wrote in message
    news:[email protected]..
    I am trying to call a dll through my LabVIEW program. The dll
    implements a routine to access an ftp server. When the server is
    found, everything works as expected. However, if there is a delay in
    finding the server, LabVIEW throws an error - "An exception occured
    within the external code called by the Call Library Node". The
    detailed error message is attached here.
    The dll function times out after 25 seconds if the server is not found
    (it returns a signed integer). This error message pops up after
    roughly 20 seconds.
    The dll was created in VC++ 6.0. It uses standard MFC calls.
    Any information about why this could be happening will be appreciated.
    Thanks.

  • Why does LabView crash when unloading my DLL (reentrant calls)?

    I have written a DLL in Borland Delphi using multiple threads that exports several functions (stdcall). I am using LabVIEW 6i on a WinXP machine.  All functions in the DLL work as expected and return correct values. Everything works fine if I set all Call Library Function Nodes to 'UI-Thread', but as soon as I set one Function Node to 'Reentrant', LabView crashes when I close the VI after it has been executed. I assume the error is caused by the DLL unloading mechanism of LabView. Other C++/Delphi programs using the DLL reentrantly work fine, this only occurs in LabView. In which thread does LabView call FreeLibrary/DLL_PROCESS_DETACH? Has anyone experienced similar problems?

    I have never run into this situation myself, but I do know that calling a multi-threaded DLL or CIN from LabVIEW does depend upon the following criteria:
    If your CIN/DLL doesn't have any global data storage (global variables, files on disk, etc.), AND it doesn't access any hardware (register-level programming) AND it doesn't call any functions/DLLs/Drivers that are thread-unsafe.
    OR
    Your CIN/DLL protects (with semaphores or mutex's) access to those global resources.
    OR
    Your DLL is only called from one, non-reentrant VI
    OR
    Your CIN is only called from one, non-reentrant VI AND you don't access any global resources from CINInit, CINAbort, CINDispose, etc. procedures.
    Hopefully this information can help you out in some way.
    J.R. Allen

  • Creating dll and calling it in labview crashing the program

    Hi All,
    I am using labview from quite a long time.But this time i am stuck with dll.Not able to solve this issue.
    I have to communicate with FTDI chip.
    I have a VC++ Project to communicate with SPI of FTDI.That Code is working perfectly fine.
    Now I Have to automate that through LabVIEW. VISA Drivers i cant use in this. So Last option left is either to create dll or to make EXE out of it.
    I have tried by creating DLL and then calling it in LabVIEW by using Call Library Function Node.But its not helping me out every time LabVIEW is getting Crashed.
    Is there error in creation of dll or something i am not doing properly while calling?
    Thanks In Advance 
    Shweta
    Attachments:
    old_dolphin_sub_spi_func_ftdi.c ‏21 KB
    ftdi_write_read.vi ‏15 KB

    Which function call crashes LabVIEW?
    Have you tried switching the calling convention from stdcall to C for all of the DLL calls?
    Why are you converting a string to a number, instead of using a numeric constant directly? If you want a number in hex, you can right-click a numeric constant, make the radix visible, and switch it to hex display.

  • Failure: "gnrclist.cpp" after a DLL call

    Forum:
    Since adding dll calls in a VI, LabVIEW is frequently crashing, both during VI execution and after exiting the application.
    Generally, what issues need to be considered when making successful dll calls (using the "call library function").
    Jordan

    Hi Jordan,
    It sounds like this issue is due to the fact that you are not allocating memory for the dll in advance. This is the most common mistake when implementing a dll in LabVIEW.
    For instance, if your dll is going to output an array of 100 double-precision numbers, then you need to allocate this place in memory by passing the dll a dummy array of 100 double-precision numbers that it can operate on. Also be careful not to expand the size of the array. LabVIEW doesn't support dynamic memory allocation within a dll in most circumstances. If you don't allocate a place in memory in advance, LabVIEW may crash when you exit the program and LabVIEW tries to deallocate memory.
    A really good example of allocating various types of data for use in a dll is available from the Example Finder (Help >> Find Examples from LabVIEW).  Click the Search tab and search for the term DLL. The Example is called Call DLLs. It contains c code that corresponds to various dll functions that operate on various data types, and it shows you how to call these dll functions properly from LabVIEW. For a more comprehensize overview of the process, refer to the document Using External Code in LabVIEW, available here, or browse through these Developer Zone examples and applications notes.
    Jarrod S.
    National Instruments

  • Call function in LabView from a DLL, then access global variable from DLL

    I have created a DLL in LabWindows with a function and a structure.  I want to call the function from within LabView and then access the global structure.  I am able to call the function from the DLL with a "Call Library Function Node" and can access the return value, but I cannot figure out how to access the global structure.  The structure is declared in the DLL header file with __declspec(dllimport) struct parameters.
    Is there any way of accessing this structure without using the Network Variable Library?
    Solved!
    Go to Solution.

    dblok wrote:
    When you say "access to" or "the address of" the global variable, do you mean to pass the variable as an argument to the function call in the DLL?  If so, then I was not really sure how to pass a cluster from LabView by using the "Call Library Function Node".
    Yes, that's exactly right.  I would include a pair of helper functions in the DLL to read and write the global variable.  Alternatively you might write separate helper functions for each field inside the global structure, depending on the number of fields and whether you want to do any validation on the values.
    You can pass a cluster by reference to a function that expects a struct by setting the parameter to Adapt to Type, so long as the cluster does not contain any variable-length elements (strings or arrays).  The cluster needs to match the struct exactly, and sometimes that involves adding extra padding bytes to make the alignment work.  Variable-length elements in LabVIEW need to be converted to clusters containing the same number of elements as the struct definition (for example, if your struct contains char name[12], you would create a cluster of 8 U8 values, and you could use String to Array of Bytes followed by Array to Cluster to convert a LabVIEW string into that format).  If the struct contains pointers it gets more complicated, and it may be easier to write functions in the DLL to access those specific elements individually.
    If you can't get this working or need help, post your code and an explanation of the error or problem you're seeing.
    EDIT: it is also possible to include a single function in the DLL that returns the address of the global variable, which LabVIEW can then use to access and modify the data, but that's more complicated and likely to lead to crashes if you don't get the memory addressing exactly right.

Maybe you are looking for