9front - general discussion about 9front
 help / color / mirror / Atom feed
From: ori@eigenstate.org
To: qwx@sciops.net, 9front@9front.org
Subject: Re: [9front] 5l breakage on zynq
Date: Tue, 12 May 2020 08:08:56 -0700	[thread overview]
Message-ID: <4B65C95D9EB2FB2BF18754CBF0C978B7@eigenstate.org> (raw)
In-Reply-To: <8F1A64ADC8E4F80F6A3D24542B087636@wopr.sciops.net>


> 
> ; hg revert -r 7667 /sys/src/cmd/^(5a 5c 5l cc 6c 6a 6l)
> 
> ... and rebuilding compilers/loaders and libc/libbio.
> 
> Any idea what broke?
> 
> Thanks,
> 

Yeah -- I think I see it:
	
	 1106		s = (Sym*)hunk;
	 1107		nhunk -= sizeof(Sym);
	 1108		hunk += sizeof(Sym);
	 1109	
	>1110		s->name = malloc(l);

This assumes that hunk is aligned, but the change to
malloc in the commit you flagged may leave it unaligned:

	void*
	alloc(long n)
	{
		void *p;
	
		while((uintptr)hunk & 7) {
			hunk++;
			nhunk--;
		}
		while(nhunk < n)
			gethunk();
		p = hunk;
		nhunk -= n;
		hunk += n;
		return p;
	}

Here, we always align the hunk on entry, but we ma
leave hunk unaligned on exit, if n is not a multiple
of 8. Then, when it's used directly, 's' is misaligned.

Try this patch, which aligns 'n' to a multiple of 8
before we allocate:

diff -r 965e0f59464d sys/src/cmd/cc/compat
--- a/sys/src/cmd/cc/compat	Sun May 10 22:51:40 2020 +0200
+++ b/sys/src/cmd/cc/compat	Tue May 12 08:02:58 2020 -0700
@@ -107,6 +107,7 @@
 {
 	void *p;
 
+	n = (n + 7) & (~7);
 	while((uintptr)hunk & 7) {
 		hunk++;
 		nhunk--;



  reply	other threads:[~2020-05-12 15:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-12 14:08 qwx
2020-05-12 15:08 ` ori [this message]
2020-05-12 20:09   ` [9front] " cinap_lenrek
2020-05-12 20:17     ` qwx

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=4B65C95D9EB2FB2BF18754CBF0C978B7@eigenstate.org \
    --to=ori@eigenstate.org \
    --cc=9front@9front.org \
    --cc=qwx@sciops.net \
    /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).