Search code examples
c++visual-studioaccess-denied

Can not debug C++ code in Visual Studio 2019 ("Source Not Available"/"Unable to start program: *.exe" issues)


I am using Windows 7 Professional.

I am trying to debug a simple C code in a C++ project in Visual Studio 2019. Here is the code:

#include <stdio.h>
#include <stdlib.h>

int main(void) {
    printf("#########################################\n");
    // n: day that the query stops
    int n = 5;
    printf("Day to stop receiving queries: %d\n", n);
    // q is the number of queries received by day
    // ql is the amount of queries left to the next day
    // k is the max of queries replied by day
    long long int q = 0, ql = 0, k = 250;
    printf("Max queries to read per day: %lld\n", k);
    // day is the current day
    int day = 1;
    while (1) {
        printf("#########################################\n");
        if (day > n) {
            q = 0;
        }
        else {
            printf("Enter the number of queries received today\n");
            scanf("%lld", &q);
        }
        printf("Day: %d\nQueries received today: %lld\nTotal of queries to read today: %lld\n", day, q, (ql + q));
        if ((q + ql) > k) {
            ql = q + ql - k;
            printf("q: %lld\n", q);
            printf("ql: %lld\n", ql);
            printf("k: %lld\n", k);
        }
        else {
            ql = 0;
            break;
        }
        printf("Left queries to the next day: %lld\n", ql);
        day++;
    }
    printf("#########################################\n");
    printf("#########################################\n");
    printf("Day with free time: %d\n", day);
    printf("#########################################\n");
    printf("#########################################\n");
    return 0;
}
  1. If I try to debug with x64 option, I get the "Source Not Available" message:

"Source Not Available" message

I have put a break point at the beginning of the code and notice it throws an exception at the line "scanf("%lld", &q);". Here is the exception information: "Exception thrown at 0x0000000076E6756E (ntdll.dll) in ChefAndEasyQueries.exe: 0xC0000005: Access violation writing location 0x0000000000000000."

  1. If I try to debug with x86 option, I get the "Unable to start program *.exe / Access is denied" error message (it is in Portuguese):

"Unable to start program" message

The .exe file is not in specified directory. I do not know if the Visual Studio is not creating the file or if my PC is somehow deleting it.


Solution

  • I think my antivirus is deleting the *.exe file. I don't have privileges to stop or uninstall the antivirus so I will not be able to fix the issue in this PC.