Unable to run compiled C++ programs on first execution

Viewed 144

Ever since upgrading to Mac OS Catalina, any time I compile a C++ program, it does not run the first time. The program compiles as expected and the executable is created and appears normal in all regards. However, when I run the program it immediately prints:

-bash: ./a.out: Input/output error

Immediately running the program again works exactly as expected. Below is a screenshot of the flow and the simple program used to generate the errors.

#include <iostream>

int main ()
{
    std::cout << "test\n";
    return 0;
}

enter image description here

2 Answers

After days of digging, I was able to resolve the issue. The problem was that my organization uses Cylance, and advanced threat mitigation tool. After Catalina upgrade, Cylance lost its Full Disk Access under the security settings in system preferences. I granted the permissions and was able to get an updated policy that fixed the problem.

I had run sudo dmesg and noticed the line:

hook_thread_userret calledCyProtectDrv.MemDef ERROR

which seemed like a potential issue. I searched for that string and saw that the first result was Cylance related. That is what led me down this very specific path to a solution. I hope this saves someone else a bunch of hours.

Input/output error is probably due to problems in the filesystem. If youre using a outdated version from a long time and dont have required free storage and RAM, this problem can occur.

Try rebooting your computer. If that doesnt work try reinstalling the OS again if possible.

Related