pros
pros copied to clipboard
BUG: Multiple threads writing to stdout can cause encoding errors
Multiple threads writing to stdout can cause utf-8 encoding errors. This is likely due to stdout not being atomic, or maybe the design of our VFS. A closer look needs to be taken to determine the issue here.
Program to replicate bug:
#include <iostream>
#include "main.h"
using namespace pros;
void my_task(void* str) {
pros::Vision vision(20);
while (true) {
std::cout << (char*)str << std::endl;
std::cout << vision.get_object_count() << std::endl;
pros::delay(20);
}
}
void opcontrol() {
{
std::string s = "Hello world";
pros::rtos::Task t(my_task, (void*)(s.c_str()));
}
while (true) {
pros::Motor(11).move(pros::Controller(E_CONTROLLER_MASTER).get_analog(E_CONTROLLER_ANALOG_LEFT_Y));
pros::Motor(1).move(-pros::Controller(E_CONTROLLER_MASTER).get_analog(E_CONTROLLER_ANALOG_RIGHT_Y));
std::cout << ("Hello from opcontrol\n") << std::endl;
pros::Task::delay(20);
}
}
