9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] exec suicide: sys: bad address in syscall
@ 2022-05-08 17:38 istvan bak
  2022-05-08 19:53 ` ori
  2022-05-08 20:10 ` Amavect
  0 siblings, 2 replies; 4+ messages in thread
From: istvan bak @ 2022-05-08 17:38 UTC (permalink / raw)
  To: 9front

Hello. The below program suicides on a call to fork/exec. If I made
the mistake, then I can't see it. If I didn't, then I don't know how
to debug the kernel(?), and I don't have time to stare at it for days
on end :/.

If I remove the Waitmsg, it doesn't repro. If I remove the print(""),
it doesn't repro. if i inline the body, it doesn't repro. something
something callstack mumble address syscall mumble. It repros on amd64,
but not 386.

http://sysinfo.9front.org/src/460/body

term% mk 6.red
6c -FTVw red.c
6l  -o 6.red red.6
term% 6.red
term% 6.red 666: suicide: invalid address 0x7fff00000000/1 in sys call
pc=0x200216
6.red 666: suicide: sys: bad address in syscall pc=0x200216
6.red 667: suicide: invalid address 0x7fff00000000/1 in sys call pc=0x200216
6.red 667: suicide: sys: bad address in syscall pc=0x200216

term% acid 666
/proc/666/text:amd64 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/amd64
acid: lstk()
exec(a0=0x4009a0)+0xe /sys/src/libc/9syscall/exec.s:6
execl(f=0x4009a8)+0x13 /sys/src/libc/port/execl.c:8
rc(cmd=0x4009c1)+0x4f /usr/glenda/riv/nag/red.c:17
run()+0x19 /usr/glenda/riv/nag/red.c:29
	i=0x20014500000001
main()+0x9 /usr/glenda/riv/nag/red.c:69
_main+0x40 /sys/src/libc/amd64/main9.s:15
acid:
echo kill > /proc/666/ctl
term% cat red.c
#include <u.h>
#include <libc.h>

int
rc(char *cmd)
{
	int r;
	Waitmsg *w;

	SET(w); USED(w);
	r = fork();
	switch(r){
	case -1:
		return -1;
	case 0:
		execl("/bin/rc", "/bin/rc", "-c", cmd, 0);
		sysfatal("exec returned");
	}
	return 0;
}

void
run(void)
{
	int i;

	for(i = 0; i < 3; i++){
		rc("test");
		print("");
	}
}

void
run2(void)
{
	int i;
	int r;
	Waitmsg *w;

	SET(w); USED(w);
	for(i = 0; i < 3; i++){
		r = fork();
		switch(r){
		case -1:
			continue;
		case 0:
			execl("/bin/rc", "/bin/rc", "-c", "test", 0);
			sysfatal("exec returned");
		}
		print("");
	}
}

void
main()
{
	//to test: uncomment one of the below lines
	//reproduces on amd64, but not on 386


	// this reproduces
	run();


	// this doesnt
	//run2();


	exits(0);
}

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-08 21:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-08 17:38 [9front] exec suicide: sys: bad address in syscall istvan bak
2022-05-08 19:53 ` ori
2022-05-08 20:10 ` Amavect
2022-05-08 21:45   ` istvan bak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).