LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"Using a CIN to Create an Array of Strings in LabVIEW" example crashes LV on Linux

Tried to utilize this NI example: "Using a CIN to Create an Array of Strings in LabVIEW" (http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B4B282BE7EF907C8E034080020E74861&p_node=&p_source=External)

Compiles OK with the makefile made by the LV's lvmkmf utility. Nevertheless when I try to run the VI (with the code loaded into the CIN, of course), LabVIEW 7.1.1 on a SUSE 9.3 Linux machine crashes:

LabVIEW caught fatal signal
7.1.1 - Received SIGSEGV
Reason: address not mapped to object
Attempt to reference address: 0x0
Segmentation fault

Any ideas? Did anybody try this on a Windows machine?
0 Kudos
Message 1 of 9
(3,180 Views)

@H View Labs wrote:
Tried to utilize this NI example: "Using a CIN to Create an Array of Strings in LabVIEW" (http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B4B282BE7EF907C8E034080020E74861&p_node=&p_source=External)

Compiles OK with the makefile made by the LV's lvmkmf utility. Nevertheless when I try to run the VI (with the code loaded into the CIN, of course), LabVIEW 7.1.1 on a SUSE 9.3 Linux machine crashes:

LabVIEW caught fatal signal
7.1.1 - Received SIGSEGV
Reason: address not mapped to object
Attempt to reference address: 0x0
Segmentation fault

Any ideas? Did anybody try this on a Windows machine?




This code is badly broken. In addition to resizing the actual handle to hold the number of string handles you also would need to create the string handles itself before attempting to write into them. NumericArrayResize is the fucntion to use as it will either resize an existing handle (if any) or create a new one if the value is uninitialized (NULL).


/* resize strarr to hold handles to NUMSTRINGS strings */
err = SetCINArraySize((UHandle)strarr, 0, NUMSTRINGS);
if (err)
goto out;

/* perform this loop once for each element */
/* of array of strings being created */
for (i = 0; i < NUMSTRINGS;) {
LStrHandle handle = (*strarr)->arg1[i];

/* determine length of string that will be element of strarr */
strsize = StrLen(str[i]);

err = NumericArrayResize(uB, 1, &handle, strsize);
if (err)
goto out;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/* moves strsize bytes from the address pointed to */
/* by str[i] to the address pointed to by the data pointer in the handle */
MoveBlock(str[i], LStrBuf(*handle), strsize);

/* manually set size of string pointed to by *strarr */
(*((*strarr)->arg1[i]))->cnt = strsize;

/* manually set dimSize of strarr */
(*strarr)->dimSize = ++i;
}

return noErr;

out:
return err;


Rolf Kalbermatter

Message Edited by rolfk on 06-30-2005 03:15 AM

Rolf Kalbermatter
My Blog
Message 2 of 9
(3,172 Views)
Thanks for the quick answer, Rolf.

I know you are a real expert (have you written the book yet?) in this but didn't expect you to answer ME (;-))so fast.

Despite I never had done CINs before, I figured it out myself yesterday too. Didn't want to wait for the answer, so I started digging. Actually, all it took was just a look at another example that manipulated strings. Indeed, they resize the array (handles) but do not resize the strings (handles) themselves! So, they didn't follow their own manual on integrating external code. Thank you very much, anyways.

Am I lucky, or what? This is the second example I bust NI on this week!

Stan
0 Kudos
Message 3 of 9
(3,165 Views)


@H View Labs wrote:
Thanks for the quick answer, Rolf.

I know you are a real expert (have you written the book yet?) in this but didn't expect you to answer ME (;-))so fast.


No hard feelings here 😉 Just because I don't agree with you on some areas, does not mean that I wouldn't give advise where I know something about.


Am I lucky, or what? This is the second example I bust NI on this week!


I wouldn't try to interprete anything into this. The people at NI are also just that, people. They make errors as we all do. I have posted examples in the past which turned out to be buggy too 😉

Rolf Kalbermatter
Rolf Kalbermatter
My Blog
Message 4 of 9
(3,162 Views)
I refuse to believe YOU have have posted something that would be plain wrong. Maybe your code didn't work under some particular coditions - I can accept that possibility. However this code just never works! Means they didn't bother to run it even once before posting.

Do you think we should submit the correct example as an EXAMPLE (name it almost the same but add "(really working)" or something), so that other people don't stumble on the wrong one anymore, or this post would be enough?

Stan
0 Kudos
Message 5 of 9
(3,158 Views)


@H View Labs wrote:
I refuse to believe YOU have have posted something that would be plain wrong. Maybe your code didn't work under some particular coditions - I can accept that possibility. However this code just never works! Means they didn't bother to run it even once before posting.

It is easy to be so sure that something is correct that you do not try it again after a last tweak, especially if there are 200 other things which should be done as well.

Do you think we should submit the correct example as an EXAMPLE (name it almost the same but add "(really working)" or something), so that other people don't stumble on the wrong one anymore, or this post would be enough?

Stan




The proper way would be to go to the original web page, where this sample is posted and then go down on the page and select "Add Comment". If you feel inclined to do, you could also add a bad Quality rating, but I personally wouldn't do that.

That way someone is directly informed about the problem, with a direct link to the document in question and can take action. Posting a different example might leave that not working one in the database for a long time.

Rolf Kalbermatter
Rolf Kalbermatter
My Blog
Message 6 of 9
(3,154 Views)
I have added the comments, but doesn't look like they are gonna be displayed on the page. So the only hope is that NI will pay attention to the comment and correct the example themselves. Until they do, people will stumble on it.
0 Kudos
Message 7 of 9
(3,147 Views)


@H View Labs wrote:
I have added the comments, but doesn't look like they are gonna be displayed on the page. So the only hope is that NI will pay attention to the comment and correct the example themselves. Until they do, people will stumble on it.




Yes, the comment will be sent to some website maintainer, who then hopefully will take action. I added a comment too, maybe that increases the chance of someone noticing it soon.

Rolf Kalbermatter
Rolf Kalbermatter
My Blog
Message 8 of 9
(3,141 Views)
Our comments have been displayed on the bottom of that example's page.
0 Kudos
Message 9 of 9
(3,111 Views)