9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] leak(1): document how to generate pool.$objtype.acid required for leak
@ 2021-11-04 23:31 igor
  2021-11-05  7:45 ` Humm
  0 siblings, 1 reply; 3+ messages in thread
From: igor @ 2021-11-04 23:31 UTC (permalink / raw)
  To: 9front; +Cc: igor

[-- Attachment #1: Type: text/plain, Size: 2918 bytes --]

/sys/lib/acid/leak requires /sys/src/libc/port/pool.$objtype.acid
which is not present by default.

The attached patch adds an acid target to /sys/src/libc/port/mkfile
that generates pool.$objtype.acid and refers to it in leak(1).

With the right pool.$objtype.acid file present and its usage
documented, finding leaks in programs works. Here some leaks
present in acme (NOTE how one can use the `src(addr)` printed
by leak in an acid session to print to source of leak with
some context):
	% leak -s acme|rc
	src(0x0020db61); // 18
	src(0x0020db82); // 18
	src(0x0020db95); // 18
	src(0x0020dbc3); // 18
	src(0x0020dbde); // 18
	src(0x0020de5f); // 17
	src(0x0020db70); // 17
	src(0x0020ebbc); // 7
	src(0x0020ebcb); // 7
	src(0x0020ec39); // 7
	src(0x0020ec1e); // 6
	src(0x0020ebdd); // 5
	src(0x0020ebf0); // 5
	src(0x00221607); // 5
	src(0x0022578c); // 5
	src(0x002000cb); // 1
	term% acid 1179
	/proc/1179/text:amd64 plan 9 executable
	/sys/lib/acid/port
	/sys/lib/acid/amd64
	acid: src(0x0020db61)
	/sys/src/cmd/acme/exec.c:343
	 338			return;
	 339		if(flag1 || et->w->body.file->ntext>1 || winclean(et->w, FALSE)){
	 340			w = et->w;
	 341			name = getname(&w->body, argt, arg, narg, TRUE);
	 342			if(name && plumbsendfd >= 0){
	>343				pm = emalloc(sizeof(Plumbmsg));
	 344				pm->src = estrdup("acme");
	 345				pm->dst = estrdup("close");
	 346				pm->wdir = estrdup(name);
	 347				if(p = strrchr(pm->wdir, '/'))
	 348					*p = '\0';
	acid: 

Looks like there are some small leaks in acme ☺.

<snip>
From: Igor Böhm <igor@9lab.org>
Date: Thu, 04 Nov 2021 23:11:56 +0000
Subject: [PATCH] leak: document how to generate pool.$objtype.acid


/sys/lib/acid/leak requires /sys/src/libc/port/pool.$objtype.acid
which is not present by default.

Add acid target to /sys/src/libc/port/mkfile that generates
pool.$objtype.acid and refer to it in leak(1).
---
diff ca73f673473457152d6f1b2e9030495f8dec5c49 2c38083b6c34c72b5417f29dc6002aa445212ae5
--- a/sys/man/1/leak	Mon Nov  1 18:07:28 2021
+++ b/sys/man/1/leak	Fri Nov  5 00:11:56 2021
@@ -218,7 +218,17 @@
 .I kmem
 depend on the internal structure of the
 libc pool memory allocator (see 
-.IR pool (2)).
+.IR pool (2))
+and require
+.B /sys/src/libc/port/pool.$objtype.acid
+to be present and generated from
+.BR pool.c 
+as follows:
+.IP
+.EX
+% cd /sys/src/libc/port && mk acid
+.EE
+.PP
 Since the ANSI/POSIX environment uses a different
 allocator,
 .I leak
@@ -228,8 +238,5 @@
 is not speedy, and
 .I acidleak
 can consume more memory than the process(es) being examined.
-.PP
-These commands require
-.B /sys/src/libc/port/pool.acid
-to be present and generated from
-.BR pool.c .
+
+
--- a/sys/src/libc/port/mkfile	Mon Nov  1 18:07:28 2021
+++ b/sys/src/libc/port/mkfile	Fri Nov  5 00:11:56 2021
@@ -127,3 +127,6 @@
 </sys/src/cmd/mksyslib
 
 profile.$O: /sys/include/tos.h
+
+acid:V:
+	$CC -a -w pool.c > pool.$objtype.acid
</snap>

Cheers,
Igor

[-- Attachment #2: leak.patch --]
[-- Type: text/plain, Size: 1378 bytes --]

From: Igor Böhm <igor@9lab.org>
Date: Thu, 04 Nov 2021 23:11:56 +0000
Subject: [PATCH] leak: document how to generate pool.$objtype.acid


/sys/lib/acid/leak requires /sys/src/libc/port/pool.$objtype.acid
which is not present by default.

Add acid target to /sys/src/libc/port/mkfile that generates
pool.$objtype.acid and refer to it in leak(1).
---
diff ca73f673473457152d6f1b2e9030495f8dec5c49 2c38083b6c34c72b5417f29dc6002aa445212ae5
--- a/sys/man/1/leak	Mon Nov  1 18:07:28 2021
+++ b/sys/man/1/leak	Fri Nov  5 00:11:56 2021
@@ -218,7 +218,17 @@
 .I kmem
 depend on the internal structure of the
 libc pool memory allocator (see 
-.IR pool (2)).
+.IR pool (2))
+and require
+.B /sys/src/libc/port/pool.$objtype.acid
+to be present and generated from
+.BR pool.c 
+as follows:
+.IP
+.EX
+% cd /sys/src/libc/port && mk acid
+.EE
+.PP
 Since the ANSI/POSIX environment uses a different
 allocator,
 .I leak
@@ -228,8 +238,5 @@
 is not speedy, and
 .I acidleak
 can consume more memory than the process(es) being examined.
-.PP
-These commands require
-.B /sys/src/libc/port/pool.acid
-to be present and generated from
-.BR pool.c .
+
+
--- a/sys/src/libc/port/mkfile	Mon Nov  1 18:07:28 2021
+++ b/sys/src/libc/port/mkfile	Fri Nov  5 00:11:56 2021
@@ -127,3 +127,6 @@
 </sys/src/cmd/mksyslib
 
 profile.$O: /sys/include/tos.h
+
+acid:V:
+	$CC -a -w pool.c > pool.$objtype.acid

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

end of thread, other threads:[~2021-11-05 10:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-04 23:31 [9front] leak(1): document how to generate pool.$objtype.acid required for leak igor
2021-11-05  7:45 ` Humm
2021-11-05  9:25   ` igor

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).