12-22-2015 02:49 PM
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.
12-22-2015 03:26 PM - edited 12-22-2015 03:31 PM
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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
12-22-2015 06:17 PM
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.
12-22-2015 08:35 PM
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!" 😄
12-23-2015 10:18 AM
@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.