ROBOTC.net forums
http://robotc.net/forums/

Boolean Variables Memory Corruption
http://robotc.net/forums/viewtopic.php?f=63&t=10274
Page 1 of 1

Author:  FTC_359 [ Thu Jan 15, 2015 9:42 pm ]
Post subject:  Boolean Variables Memory Corruption

I came across this bug while using my menu from my autonomous header. This menu takes various variables and then stores them into void pointers. While this menu is still buggy, the point is that it causes the NXT to freeze.
Example code:
Code:
#include "Autonomous_Funcs.h"

bool ramp = true;
bool fill;
bool kickstand = false;
bool test1 = true;
bool test2 = false;
bool test3 = true;
//4 is unlucky :P
bool test5 = true;
bool test6 = false;
bool test7 = true;

task main()
{
   configLine("", &ramp, "", "Ramp","Parking Zone");
   configLine("", &kickstand, "", "Yes", "No");
   configLine("", &test1, "", "Yes", "No");
   configLine("", &test2, "", "Yes", "No");
   configLine("", &test3, "", "Yes", "No");
   configLine("", &test5, "", "Yes", "No");
   configLine("", &test6, "", "Yes", "No");
   startDisplay(true, true);
   while(true){}
}


This program would cause the NXT to freeze upon getting to the point where it tries to access the value of the boolean via (bool *).
The following program does work:
Code:
#include "Autonomous_Funcs.h"

bool ramp = true;
bool fill;
bool kickstand = false;
bool fill1;
bool test1 = true;
bool fill2;
bool test2 = false;
bool fill3;
bool test3 = true;
bool fill5;
bool test5 = true;
bool fill6;
bool test6 = false;
bool fill7;
bool test7 = true;

task main()
{
   configLine("", &ramp, "", "Ramp","Parking Zone");
   configLine("", &kickstand, "", "Yes", "No");
   configLine("", &test1, "", "Yes", "No");
   configLine("", &test2, "", "Yes", "No");
   configLine("", &test3, "", "Yes", "No");
   configLine("", &test5, "", "Yes", "No");
   configLine("", &test6, "", "Yes", "No");
   startDisplay(true, true);
   while(true){}
}


In this program, I put in "filler" boolean variables and then kept the same code within the main task. This did work, and further testing led me to believe that every other boolean variable's memory address is corrupted. This did not happen with any other variable type.

To recreate this problem, all you must do is make a simple test program like the ones above and include the autonomous function.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/