LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

SavePanelState crashes in 64-bit build

Solved!
Go to solution

I am coding the setup tab for a test application.  The user enters data into several fields on a main panel and clicks a button when finished.  I am trying to use the SavePanelState and RecallPanelState functions to save and restore the setup data to/from a file, but when I build my program as a 64-bit application, SavePanelState causes the program to crash.  When built as a 32-bit application it works fine. 

 

My code is attached.  I am running on Windows 7 Professional 64-bit OS.

 

Rich Ferrara

Telephonics

 

/*******************************************************************************
*
* Function:          SaveSetup
* 
* Description:       This function is the callback for the OK button.
*                    It saves the setup information and sets the new test mode.
*
* Input Parameters:  panel - ID of the panel activated
*                    control - ID of the control activated
*                    event - ID of the event triggered
*                    callbackData - extra data sent to the callback
*                    eventData1 - parameter sent to the callback
*                    eventData2 - parameter sent to the callback
*
* Output Parameters: returns 0
*
*******************************************************************************/
int CVICALLBACK SaveSetup (int panel, int control, int event,
        void *callbackData, int eventData1, int eventData2)
{
    char fileName[MAX_PATHNAME_LEN];
    char data[BUFFER_LEN];
    int index;
    int mode;
    FILE *ofp;
    
    switch (event)
    {
        case EVENT_COMMIT:
            // ===== Temporary unit test code: open a text file to =====
            // ===== save the panel settings                       =====
            //
            // ===== In the final PLATE, this will be saved to the =====
            // ===== summary and/or verbose log files              =====
            MakePathname(GetTempFolder(), "setup.txt", fileName);
            ofp = fopen(fileName, "w");
            
            // Save the test operator name
            GetLabelFromIndex(panel, MAIN_TEST_OPERATOR, 
                lastSelectedUserIndex, data);
            fprintf(ofp, "Test operator: %s\n", data);
            
            // Save the access level
            GetCtrlIndex(panel, MAIN_ACCESS_LEVEL, &index);
            GetLabelFromIndex(panel, MAIN_ACCESS_LEVEL, index, data);
            fprintf(ofp, "Access level: %s\n", data);
            
            // Save the test mode
            GetCtrlIndex(panel, MAIN_TEST_MODE, &index);
            GetLabelFromIndex(panel, MAIN_TEST_MODE, index, data);
            fprintf(ofp, "Test mode: %s\n", data);
            GetCtrlVal(panel, MAIN_TEST_MODE, &mode);
            
            // Save the PLATE system number
            GetCtrlVal(panel, MAIN_PLATE_SYS_NUM, data);
            fprintf(ofp, "PLATE system number: %s\n", data);
            
            // Save the PLATE hardware revision
            GetCtrlVal(panel, MAIN_PLATE_HW_REV, data);
            fprintf(ofp, "PLATE hardware revision: %s\n", data);
            
            // Save the PLATE software release
            GetCtrlVal(panel, MAIN_PLATE_SW_REL, data);
            fprintf(ofp, "PLATE software release: %s\n", data);
            
            // Save the test date
            GetCtrlVal(panel, MAIN_TEST_DATE, data);
            fprintf(ofp, "Test date: %s\n", data);
            
            // Save the test time
            GetCtrlVal(panel, MAIN_TEST_TIME, data);
            fprintf(ofp, "Test time: %s\n", data);
            
            // Save RDP data only if not entering Calibration mode
            if (mode != CALIBRATION)
            {
                // Save the RDP serial number
                GetCtrlVal(panel, MAIN_RDP_SERIAL_NUM, data);
                fprintf(ofp, "RDP serial number: %s\n", data);
                    
                // Save the RDP hardware revision
                GetCtrlVal(panel, MAIN_RDP_HW_REV, data);
                fprintf(ofp, "RDP hardware revision: 349-1000-%s\n", data);
            
                // Save the RDP software release
                GetCtrlIndex(panel, MAIN_RDP_SW_REL, &index);
                GetLabelFromIndex(panel, MAIN_RDP_SW_REL, index, data);
                fprintf(ofp, "RDP software release: %s\n", data);
            }
            
            // Save the comments
            GetCtrlVal(panel, MAIN_COMMENTS, data);
            fprintf(ofp, "Comments: %s\n", data);
            
            // Close the text file
            fclose(ofp);
            
            // Alert the user (this may be part of the final PLATE, or we may
            // just switch to another tab)
            MessagePopup("Setup", "Data saved.");
            
            // ===== End temporary unit test code =====
            
            // Save the state of all panel controls
            MakePathname(GetTempFolder(), SETUP_STATE_FILE, fileName);
            SavePanelState(panel, fileName, 0);
            break;
    }
    return 0;
}

 

0 Kudos
Message 1 of 7
(2,957 Views)

Hi Rich,

 

I hope you are doing well today!  I have a few questions regarding your setup.  First, what version of LabWindows/CVI are you using?  Also, does this produce any errors or warnings before it crashes?  Could you post some screenshots of error messages or dialogs that you are seeing when this occurs?  Does this happen in both the Debug and Release versions of your executable?  Can you run the executable from the Command Prompt and see the same behavior?  Thanks, Rich!  Have a great day!

Taylor G.
Product Support Engineer
National Instruments
www.ni.com/support
0 Kudos
Message 2 of 7
(2,944 Views)

Hi Taylor,

 

I am using LabWindows 2010 (10.0.1).

 

There are no errors or warnings displayed until the program crashes.  It happens using both the Release64 and Debug64 configurations, although the errors displayed are different (see attached files).  Running the program from a command prompt produces the same results.

 

I am also attaching our UIR file for reference, but I saw the same results running a simple GUI with only a few command buttons and a numeric input.

 

Rich

 

Download All
0 Kudos
Message 3 of 7
(2,936 Views)

Hi Rich,

 

Thank you for the detail and the screenshots.  Can you confirm that it is, in fact, the SavePanelState() function itself that causes the crash?  You could use breakpoints and other debugging techniques to step through your callback that contains the SavePanelState() function while running your code within LabWindows/CVI to see if it does, in fact, crash as soon as you step over this function.  Please verify that this is where the code is crashing and post your results when you get a chance.  Thanks, Rich!  Have a great day!

Taylor G.
Product Support Engineer
National Instruments
www.ni.com/support
0 Kudos
Message 4 of 7
(2,886 Views)

Taylor,

 

I set breakpoints at the SavePanelState line and at the break statement immediately following it.  I confirmed that the code reaches SavePanelState but crashes before reaching the break statement.

 

SavePanelState does appear to be saving the panel state file.  I see the file on my hard drive and it has data in it from the panel.

 

Rich

0 Kudos
Message 5 of 7
(2,873 Views)
Solution
Accepted by topic author richferrara

Rich,

 

Turns out this is a bug. I have filed a bug report (# 319377) that you can track. It should be fixed in a later release of CVI.

 

The bug affects the creation of a new save file, but only under 64-bit configuration. The crash occurs half way through creating the new file when writing some header information not specific to the state you are saving. It leave the file corrupted. The file is not a valid save file and will continue to cause problems if saved to or loaded from. The save file is correctly created under 32-bit configuration and this save file is actually compatible with the 64-bit version. What you can do for a workaround is create a save file with a 32-bit application (this can be any 32-bit application that even has a different UIR file), then reuse this file for saving states in your application. Since the file is already created, it avoids the bug in the file creation stage and successfully saves the state. I have actually attached one created in 32-bit application that you can use. When doing this make sure not to load a state that you did not save. You can just avoid ever loading state 1, or you can just be sure to overwrite state 1 with your application.

National Instruments
0 Kudos
Message 6 of 7
(2,839 Views)

Thanks for your help, it works now.

0 Kudos
Message 7 of 7
(2,826 Views)