9front - general discussion about 9front
 help / color / mirror / Atom feed
From: istvan bak <bdhpfl@gmail.com>
To: 9front <9front@9front.org>
Subject: [9front] exec suicide: sys: bad address in syscall
Date: Sun, 8 May 2022 17:38:27 +0000	[thread overview]
Message-ID: <CAO+DOcqq4RSa_vyhEHBxjGgmJ-ux_B3ShWMN-cy5YquWnaChtw@mail.gmail.com> (raw)

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);
}

             reply	other threads:[~2022-05-08 17:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-08 17:38 istvan bak [this message]
2022-05-08 19:53 ` ori
2022-05-08 20:10 ` Amavect
2022-05-08 21:45   ` istvan bak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAO+DOcqq4RSa_vyhEHBxjGgmJ-ux_B3ShWMN-cy5YquWnaChtw@mail.gmail.com \
    --to=bdhpfl@gmail.com \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).