LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Access Violation

I was playing around with user events and managed to produce some code that reliably crashed LabVIEW.  Thought I'd share (mainly because it amused me)

 

Note:  This was me playing around because I was curious to see if it would actually fire the event.

Access Violation.png

0 Kudos
Message 1 of 5
(3,127 Views)

Yeah what you did was bad, and I'm not surprised it results in a crash.  You make a user event that uses the error as the data type.  Then you turn that user event into a variant.  Then pull out the Type and String, then you try to convert it back to a variant, but you use a different type.  Then you try to convert that variant into a user event of a different type (not using the error as the payload) then you try to generate that event.

 

If you remove the type constant, and instead use the output of the Variant to Flatten String type, then no crash happens, and as expected you get run time errors saying the conversion can't take place the way you want.

 

Part of the reason why the crash happens, is that you asked LabVIEW to interpret data in ways that it can't perform without some kind of mutation.  Then that converted data happened to be a reference which you were trying to act on.  LabVIEW can perform the data conversion the way you asked it interpreting memory as a different type of memory isn't the problem, it is when that new type of memory is meant to be a pointer somewhere.  Memory might truncate early, or spill over in a part of memory that just wasn't intended to be accessed.

0 Kudos
Message 2 of 5
(3,107 Views)

I'm not surprised it crashed either.  Actually, the first case I did worked (I think I did String initialize and translate to Error or something like that) and that DID surprise me.  I switched it around a bit and it started crashing.

0 Kudos
Message 3 of 5
(3,073 Views)

Please note that I'm not trying to be facetious here, but what was the point of this exercise?  No programming language can guard against everything.  Of course, you could be pointing out just how difficult it is to make LabVIEW throw up its hands and say, "I quit!"  😄

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 5
(3,059 Views)

@billko wrote:

Please note that I'm not trying to be facetious here, but what was the point of this exercise?  No programming language can guard against everything.  Of course, you could be pointing out just how difficult it is to make LabVIEW throw up its hands and say, "I quit!"  😄


I wouldn't say that there really was a "point" aside from playing around. It started out as an exercise to see if I could make a SubVI fire any user event that was passed in regardless of data type.  I didn't expect it to work at the start.

 

That having been said, this is actually the first time I've managed to make the LabVIEW produce a repetable memory access violation in the 6+ years I've been programming LabVIEW - and it took some very stupid code to make happen.  All in all that is actually quite impressive on NI's part.

Message 5 of 5
(3,018 Views)