From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Refactored two classes, now my app crashes

Solved!
Go to solution

Ok so I'm stumped.  I refactored my main toolkit to reduce code duplication by creating a third class that implemented the duplicate code found in two separate classes, then changing the two original classes to inherit from the new class.  I updated the entire hierarchy in the two apps that use this toolkit and was very happy with everything; the larger app loads faster and runs just like it did before refactoring.  Then I tried to run the smaller app and I got a nice hard crash:

Access violation (0xC0000005) at EIP=0x055017CA

The crash seems to happen when I send a message to one particular child of one of the refactored classes that requires reading a typedef owned by the child class.  There are several messages that call typedefs, and it won't always crash on the same one.  I have no idea where to even start looking for the error.  Does anyone have tips or things to try?

CLAD
0 Kudos
Message 1 of 17
(6,024 Views)
Solution
Accepted by topic author testingHotAir

Welcome to labview classes and dependencies issues You're bound to see this message a few more times.

You might try clearing your object cache or looking for a circular dependency b/c of your typedefs.  You could also try moving your typdef outside of your class and see if that helps.  Try opening the classes outside of the project window starting with the highest level and working down in your class hierarchy.  Sometimes one of these will hard crash labview and you will know the issue is in the class.

Do you use version control? If so try rolling back to the last version that worked.  If you still see the error, its probably in your object cache. 

Some initial thoughts.

0 Kudos
Message 2 of 17
(4,094 Views)

Thanks for the reply, Jed.  I cleared the object cache, no change.  Moved the typedefs out of the classes and into the library that owns the classes, no change.  I can't load the problem classes individually because they all belong to the same lvlib.

CLAD
0 Kudos
Message 3 of 17
(4,094 Views)

Oh and unfortunately I don't use version control.  I started learning how to use it yesterday though, which is a nice bit of irony.

Also, how can I detect a circular dependency?

CLAD
0 Kudos
Message 4 of 17
(4,094 Views)

Ok so I think the problem went away.  I wanted to open all the classes individually, so I removed them from the owning library and resaved everything.  Then I cleared the object cache and opened each class individually.  None produced crashes or showed errors.  After adding them all back to the original owning library, the problem went away.

Is there a history of object mutations associated with the library or something?

CLAD
0 Kudos
Message 5 of 17
(4,094 Views)

Hi,

are you using LV<2013sp2?

My recommendation is not to use classes before that version.

If you are stuck with LV11, for example, next time you crash and burn try renaming the classes from X to Y and back to X again.

Good luck.

0 Kudos
Message 6 of 17
(4,094 Views)

I'm using LV2014.  I did encounter problems with LV2013 SP1 and earlier that were solved by renaming classes like that.

CLAD
0 Kudos
Message 7 of 17
(4,094 Views)

There are some thread floating around here and there highlighting issues like this.  There are some over at lavag.org as well. 


I'm not sure if its still considered a "best practice" to group child classes or actor classes in the same library.  I would recommend putting them in a virtual folder for organization as opposed to a library. 


Mixing libraries and classes seems to cause some un-needed headaches, but maybe there are some other suggestions others have that allow you to still use libraries.

0 Kudos
Message 8 of 17
(4,094 Views)

Yeah I'd really like to keep using libraries.  It's a real pain to pull in each class manually when I build a new project.

CLAD
0 Kudos
Message 9 of 17
(4,094 Views)

Well if those classes are children of the parent, they will automatically load, they will also already be listed in the dependencies of your project.   You can then drag them up into the project if you want them there. If you use any part of a class in a vi, then the entire class structure is loaded into memory at that time.  Basically a class is its own library structure.  If you load a child, you are going to get the parents loaded in the dependences. 

This solution may for everyone and there are a lot more experienced people then me on this forums but i've had lots of issues with libraries/classes. 

0 Kudos
Message 10 of 17
(4,094 Views)