xdag icon indicating copy to clipboard operation
xdag copied to clipboard

abnormal exit 4

Open xrdavies opened this issue 7 years ago • 3 comments

Version: 0.3.0

Platform: Mac OS 10.13

Description:

When tried to load test net storage files, it reported exit 4 in the subprocess.

The code

static void angelize(void)
{
#if !defined(_WIN32) && !defined(_WIN64)
	int stat = 0;
	pid_t childpid;
	while((childpid = fork())) {
		signal(SIGINT, SIG_IGN);
		signal(SIGTERM, SIG_IGN);
		if(childpid > 0) while(waitpid(childpid, &stat, 0) == -1) {
			if(errno != EINTR) {
				xdag_err("abort on error");
				abort();
			}
		}
		if(stat >= 0 && stat <= 5) {
			xdag_err("exit %d", stat);
			exit(stat);
		}
		sleep(10);
	}
#endif
}

The storage files: http://corpopool.com/download/xdagtest.tar.gz

xrdavies avatar Oct 13 '18 15:10 xrdavies

on linux i don't have this issue, at which block number it happens?

if i understood it correctly this should happen only if child exited with success:

		if(stat >= 0 && stat <= 5) {
			xdag_err("exit %d", stat);
			exit(stat);
		}

in other cases it does another fork, restart (that's why when xdag crash it usually restart) stat value is implementation dependent, so it cannot be read directly, https://linux.die.net/man/2/waitpid here the macros to read stat correctly. But i don't know what he mean with stat >= 0 && stat <= 5, it may be the argument of exit() of the child.. so it should be WEXITSTATUS(stat) >= 0 && WEXITSTATUS(stat) <= 5...

sgaragagghu avatar Oct 18 '18 07:10 sgaragagghu

@sgaragagghu According to the explanation of waitpid, the least significant 8 bits store the signal. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/kernel/exit.c?h=v4.18.16

Tried to catch the stats with

if(WIFSIGNALED(stat)) {
			printf("killed by signal %d\n", WTERMSIG(stat));
		}

and it's signal 4.

xdag> killed by signal 4

signal 4 is #define SIGILL 4 /* illegal instruction (not reset when caught) */

Still have no idea what causes this signal yet.

xrdavies avatar Oct 22 '18 19:10 xrdavies

interesting... it doesn't happen on linux (at least on my computer) so it hard is for me to catch the cause of the issue :/

sgaragagghu avatar Oct 22 '18 19:10 sgaragagghu