Page 1 of 1
[NXC] Insane offset?
Posted: 15 Feb 2011, 17:02
by spillerrec
When trying to run a program like this:
Code: Select all
struct point{
int X;
int Y;
byte Z;
};
point temp[1][1];
task main(){
NumOut( 0, LCD_LINE1, temp[0][0] );
}
I get a "File error! -9".
Looking it up in "NBCCommon.h" I find this:
Insane offset? Does anyone have an idea of what this means?
After a bit of experimenting, it seems this error happens when the struct in the 2D array is larger than 4 bytes. If one of the ints are changed to byte or one of the variables are removed, it stops complaining...
Re: [NXC] Insane offset?
Posted: 15 Feb 2011, 17:27
by h-g-t
Looked interesting so I did a search and found this from the national Instruments website :-
"This message means that an object in LabVIEW such as a wire or a loop tunnel does not pass an internal test known as a sanity check. If the errors are serious enough, LabVIEW exits because something has become very corrupted. Sanity checks occur before each save, to ensure that corrupted VIs are not written over good VIs."
Absolutely no idea why the error occurred though!
Re: [NXC] Insane offset?
Posted: 15 Feb 2011, 18:52
by m-goldberg
I don't think you should be passing a struct as the third argument to NumOut. Doesn't NumOut only accept a scalar for its third argument? If so, since no scalar can be bigger than four bytes, that might explain the error message.
Re: [NXC] Insane offset?
Posted: 15 Feb 2011, 19:05
by spillerrec
I did notice it and fixed it in my test copy, but I left it there as a treat for your guys. It does no change whatsoever, it seems to happen at the ArrayInit() call. But if the type is wrong, it usually just returns 0, I have never experienced it to crash the program.
It is a bit unexpected that it accepts the value though, but I didn't test if it could actually display it properly. Who knows... But there was also a similar case with pow(), I could pass an array of float into it, while it clearly didn't support it... (Again, no crash, it just returned 0.)
Re: [NXC] Insane offset?
Posted: 16 Feb 2011, 00:57
by afanofosc
I spent way too long trying to figure this out today and ended up not making any real progress. The compiler is definitely generating a bad RXE file if you have a struct longer than 4 bytes in a 2d array. It is setting the offset to the first Dope Vector to 4 bytes greater than it should be and that causes one of the file header offsets to be 4 bytes too large which is causing the parsing of the RXE by the firmware to abort with the insane offset error.
If anyone would like to help me figure out what I am doing wrong I would be grateful.
John Hansen
Re: [NXC] Insane offset?
Posted: 27 Feb 2011, 05:21
by muntoo
Just in case this will save anyone some trouble, here's the code I used:
Code: Select all
struct point{
int X;
int Y;
byte Z;
};
point temp[1][1];
task main(){
NumOut( 0, LCD_LINE1, temp[0][0].X );
}
And here's the NBC:
Code: Select all
dseg segment
;------- definitions -------
__ArrHelper__mainpoint_219_0_def struct
X sword
Y sword
Z byte
__ArrHelper__mainpoint_219_0_def ends
____temp_2_0_def struct
X sword
Y sword
Z byte
____temp_2_0_def ends
Location_def struct
X sword
Y sword
Location_def ends
__TextOutArgs_def struct
Result sbyte
Location Location_def
Text byte[]
Options dword
__TextOutArgs_def ends
__temp_2_type_def struct
X sword
Y sword
Z byte
__temp_2_type_def ends
__ArrHelper__mainpoint_228_0_type_def struct
X sword
Y sword
Z byte
__ArrHelper__mainpoint_228_0_type_def ends
temp_type_type_def struct
X sword
Y sword
Z byte
temp_type_type_def ends
;------- declarations -------
__signed_stack_002main sdword
__signed_stack_001main sdword
__signed_stack_004main sdword
__signed_stack_003main sdword
__D0main sdword
__constVal1 sbyte 1
____initialize_global_data_return byte
__ArrHelper__mainpoint_219_0 __ArrHelper__mainpoint_219_0_def
____temp_2_0 ____temp_2_0_def
__TextOutArgs __TextOutArgs_def
__temp_2 __temp_2_type_def[]
__ArrHelper__mainpoint_228_0 __ArrHelper__mainpoint_228_0_type_def[]
temp temp_type_type_def[][]
dseg ends
;------- code -------
thread main
subcall __initialize_global_data, ____initialize_global_data_return
set __signed_stack_001main, 0
set __signed_stack_002main, 56
set __signed_stack_003main, 0
index __ArrHelper__mainpoint_228_0, temp, __signed_stack_003main
set __signed_stack_004main, 0
index __ArrHelper__mainpoint_219_0, __ArrHelper__mainpoint_228_0, __signed_stack_004main
mov __D0main, __ArrHelper__mainpoint_219_0.X
mov __TextOutArgs.Location.X, __signed_stack_001main
mov __TextOutArgs.Location.Y, __signed_stack_002main
set __TextOutArgs.Options, 0
numtostr __TextOutArgs.Text, __D0main
syscall 13, __TextOutArgs
mov __D0main, __TextOutArgs.Result
exit -1, -1
endt
;------------------------
subroutine __initialize_global_data
arrinit __temp_2, ____temp_2_0, __constVal1
arrinit temp, __temp_2, __constVal1
subret ____initialize_global_data_return
ends
;------------------------
Re: [NXC] Insane offset?
Posted: 27 Feb 2011, 09:09
by rghansen
afanofosc wrote:
If anyone would like to help me figure out what I am doing wrong I would be grateful.
John Hansen
Hi John,
After all you've done for us (and me) I'd love to help you with this but as I recall your compiler is written in Pascal and I'm not sure I can get it running on my Mac. But I'm a pretty good code reader.