2

Doing different basics in C, I found an error for which no answer was found so far on the web.

Using TCC on Windows 10 in cmd prompt:

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

int main(int argc, char **argv) {
    abort(); //or assert()
    return 0;
}

The problem first occurred with some dummy expression in assert() (like assert(1==0); ), which calls abort(). The rest of the code, before the abort(), is only a list of printfs with several sizeof, and nothing went wrong before I added the assert/abort. The program terminates where it should. Then, I can't write (recompile) or delete the .exe. Looking in the tasklist, the program is listed as many times as it has been run. It seems stuck «somewhere». %ERRORLEVEL% gives 3. I have to taskkill them with administrator privilege.

(I tried the code on Ubuntu with gcc and it went well.)

Nate Eldredge
  • 48,811
  • 6
  • 54
  • 82
Sébastien
  • 78
  • 5
  • Can you say precisely how you are running the program? – Nate Eldredge Oct 04 '20 at 02:26
  • I think it's normal that you can't delete or overwrite the exe file while the program is running. So the question is why it is still running. I don't know a lot about Windows, but I would wonder if there is some crash-reporting feature that is keeping it alive while it logs the crash or perhaps waits for some sort of acknowledgement. – Nate Eldredge Oct 04 '20 at 02:28
  • https://stackoverflow.com/questions/37019889/strange-behavior-of-c-abort-function-on-mingw-w64 suggests that calling `abort()` on Windows causes a message box to pop up. I wonder if the program waits to terminate until the box is dismissed, and if perhaps you are not seeing the box (e.g. it's on another display or obscured by other windows). – Nate Eldredge Oct 04 '20 at 03:00
  • @Nate Eldredge I am running the program from the command prompt. I also tried to run by clicking on the .exe from the explorer. I rebooted my computer, and the task that were not killed are still running. – Sébastien Oct 04 '20 at 11:22
  • Some of the instances cannot be killed even with administrator privilege. – Sébastien Oct 04 '20 at 11:41
  • 1
    Maybe relevant ... what is "TCC"? [Tiny C Compiler](https://en.wikipedia.org/wiki/Tiny_C_Compiler)? [Turbo C Compiler](https://en.wikipedia.org/wiki/Borland_Turbo_C)? something else? – pmg Oct 04 '20 at 15:03
  • So to clarify, does the issue arise with the minimal example you posted, or only with a different example (with the printfs, etc)? – Nate Eldredge Oct 04 '20 at 16:05

1 Answers1

0

I uninstalled ZoneAlarm and everything went back to normal. It seems that by default, this firewall may keeping active the command prompt which return a value on exit ().

Sébastien
  • 78
  • 5