LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CVI 2009 More General Protection Faults

Hi,

After upgrading to LW/CVI 2009 I´v got massive problems with general protection faults. The system stops with a GPF message or hangs when calling functions from the User Interface Library.

I found the cause in a combination of DuplicateCtrl() and DiscardPanel() function calls in a code sequence used for creating reports and printouts.

Base code without any error handling is:

#define HEIGHT 110.0F    /* mm */
#define WIDTH  140.0F    /* mm */
#define DPI    300.0F    /* Dots per inch */
   
int height,width;
int hiResPanel,hiResGraph;
int bmpId;


width  = (int)(WIDTH  * DPI / 25.4F);
height = (int)(HEIGHT * DPI / 25.4F);


// Loading a blank panel
hiResPanel = LoadPanel(0,"report.uir",HIRES);


// Duplicate the graph control
hiResGraph = DuplicateCtrl(loResPanel,LORES_GRAPH,hiResPanel,"",0,0);


// Size panel and graph
SetPanelAttribute(hiResPanel,ATTR_HEIGHT,height);
SetPanelAttribute(hiResPanel,ATTR_WIDTH, width);

SetCtrlAttribute(hiResPanel,hiResGraph,ATTR_HEIGHT,height);
SetCtrlAttribute(hiResPanel,hiResGraph,ATTR_WIDTH, width);

RefreshGraph(hiResPanel,hiResGraph);


// Get a panel bitmap and save it to disk
GetPanelDisplayBitmap(hiResPanel,VAL_FULL_PANEL,VAL_ENTIRE_OBJECT,&bmpId);
SaveBitmapToBMPFile(bmpId,"Temp.bmp");
DiscardBitmap(bmpId);


// Discard Panel
DiscardPanel(hiResPanel);


// Insert the bitmap into Word document or List & Label project template.....


Executing the sequence above will lead to GPF in one of the next UI Lib functions if the duplicated control is a graph with Data Mode 'Retain' and option 'Copy original plot data' active.

Tracking the sequence in the Resources Window gives the following results:

- I can see the resources for the loResGraph and it´s plots before duplicating the graph control.
- The resource of the hiResGraph appears after DuplicateCtrl() but no resources for plots in it.
- When discarding the hiResGraph the plot resources of the loResGraph will be released !!!

I looks like that releasing the plot resources from the source graph control when discarding the copied graph control is responsible for the GPF´s.

Currently I can´t release my application to my customers.

Any ideas/workarounds ?


Regards

Bernhard

0 Kudos
Message 1 of 11
(4,656 Views)

You problem has some similarities to issues we had way back with CVI 6 or 7 and XP and Office 2002.  There was some issue with pasting a lot of bitmaps to Word and it would eventually crash.  We never did get to the bottom of it, but did get to the point where is seemed that it was a problem within Windows that was beyond our reach. The workaround was to chop up the report in to smaller (and sensible sized) separate documents.

 

If you have not done so already, I'd definitely try debugging without anything to do with Word (and then bitmaps) and see if the problem still occurs.  If you are running older versions of Word or Windows, it might be helpful to try a newer version.

 

Sorry I can't be of more help, but hopefully this will help you find a workaround.

 

--Ian

0 Kudos
Message 2 of 11
(4,644 Views)

Hey Bernhard - 

 

I've been unable to reproduce the GPF with the code you've supplied.  Would it be possible for you to either post some complete code (including the necessary UIRs) that I can run to reproduce this issue?  If you'd rather not make the code public, you can place it on our ftp site (ftp://ftp.ni.com/incoming) behind our firewalls. 

 

Thanks -

 

NickB

National Instruments 

0 Kudos
Message 3 of 11
(4,635 Views)

Hi Ian,

 

Thanks for your info.

 

I agree with you regarding the problems using Word as a reporting tool. Thats why we moved to a professional reporting toolkit (List & Label from combit). I debugged the code as it is shown in my first post with no calls to any other function. The GPF occurs only in graphs that will retain and copy the plot data.

 

Bernhard

0 Kudos
Message 4 of 11
(4,634 Views)

Hey NickB,

 

please find the attached sample. Clicking the Update button a couple of times will crash the program with a GPF.

 

Thanks

 

Bernhard

0 Kudos
Message 5 of 11
(4,607 Views)

Hello Bernhard,

 

Thanks for the example.  I was able to reproduce what you are seeing.  I'll start investigating if there's any way you be able to work around this issue, and I'll let you know as soon as I know something. 

 

Thanks again,

 

NickB

National Instruments 

0 Kudos
Message 6 of 11
(4,598 Views)

Hi NickB,

 

Any good news about the DuplicateCtrl()/DuplicatePanel() problem? I tried some workarounds but without success. We shifted an appointment for installation and commissioning at a gasturbine testbed by a week, but I have to go next week.

 

So any ideas or a fixed RTE for download would be very much appreciated.

 

 

Thanks, and sorry for pushing you.

 

Bernhard

 

0 Kudos
Message 7 of 11
(4,555 Views)

Hello Bernhard - 

 

Unfortunately, after looking through the cause of this issue, there is not a viable workaround available.  Do I have your permission to get your email address from our forum administrator, so that I can contact you concerning the next steps to get you a patch?

 

Thanks -

 

NickB

National Instruments 

0 Kudos
Message 8 of 11
(4,527 Views)

Hello Nick,

 

 

yes please go on.

 

 

Thanks a lot

 

Bernhard

0 Kudos
Message 9 of 11
(4,519 Views)
I'm seeing what may be a similar problem.  We have a panel with duplicated controls on it.  When we discard the panel in the environment, we get this non-fatal run time error:

"Attempt to free pointer to memory not allocated by malloc() or calloc()"

If we build a distrobution kit and run the software on the target machine it will crash at this point.  Not always the first time, but usually within the first few times.  

Is there a resolution to this problem?  Thanks.
0 Kudos
Message 10 of 11
(4,405 Views)