9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Fwd: plan9 go output faults on 9vx with rfork
       [not found]       ` <AANLkTiky+x0gBcr84_p0Mf9HKqGVoTFcyNrdofEMS9_a@mail.gmail.com>
@ 2011-01-19  2:37         ` ron minnich
  0 siblings, 0 replies; 2+ messages in thread
From: ron minnich @ 2011-01-19  2:37 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Pavel built a reproducer and sent it to me:


---------- Forwarded message ----------
From: Pavel Zholkover <paulzhol@gmail.com>
Date: Mon, Jan 17, 2011 at 12:24 PM
Subject: Re: plan9 go output faults on 9vx with rfork
To: ron minnich <rminnich@gmail.com>


Hi Ron!

I think I've traced the cause of the crash. It is unfortunately the
syscall semacquire.
The following C program will crash vanilla 0.12 9vx and the one I
compiled from your branch:

#include <u.h>
#include <libc.h>

static long l=1;

void main(int argc, char *argv[]) {
       int i;

       semacquire(&l, 1);

       for(i=0; i < 999999; i++)
               ;

       semrelease(&l, 1);
       exits(nil);
}

---

Got peace and quite and a bulkhead seat to PHX, so had time to look.

The problem was that cmpswap was never set to anything in 9vx, so the
first time canacquire was used, well,
kaboom, since canacquire was NULL.

Changes can be seen here:
https://bitbucket.org/rminnich/vx32/changeset/c7ba21bd847c

My fix is in 9vx/main.c to do this:
	cmpswap = oscmpswap;

What's oscmpswap? Well, for darwin, it is defined in 9vx/os/cmpswap.c

You can see the rest of the changes; you can also see that this won't
build on Linux until we fix it; left as an exercise for the reader, or
until I get back home and fix it.

The reproducer no longer crashes 9vx. Now, the question is, what's
next to make Go work on 9vx?

ron



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

* [9fans] Fwd: plan9 go output faults on 9vx with rfork
       [not found]   ` <AANLkTikUa1KF+8NP54BHicus++YbeZbD48E7z=1H0Y5V@mail.gmail.com>
@ 2011-01-19 15:52     ` ron minnich
  0 siblings, 0 replies; 2+ messages in thread
From: ron minnich @ 2011-01-19 15:52 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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

Pavel sent me sieve, and it is up to 11083 on my 9vx on darwin. I
declare go on 9vx on darwin fixed.

Linux is next.

ron

[-- Attachment #2: sieve --]
[-- Type: application/octet-stream, Size: 130480 bytes --]

[-- Attachment #3: sieve.go --]
[-- Type: application/octet-stream, Size: 1027 bytes --]

// $G $F.go && $L $F.$A  # don't run it - goes forever

// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import "runtime"

// Send the sequence 2, 3, 4, ... to channel 'ch'.
func Generate(ch chan<- int) {
	for i := 2; ; i++ {
		ch <- i // Send 'i' to channel 'ch'.
	}
}

// Copy the values from channel 'in' to channel 'out',
// removing those divisible by 'prime'.
func Filter(in <-chan int, out chan<- int, prime int) {
	for {
		i := <-in // Receive value of new variable 'i' from 'in'.
		if i%prime != 0 {
			out <- i // Send 'i' to channel 'out'.
		}
	}
}

// The prime sieve: Daisy-chain Filter processes together.
func Sieve() {
	ch := make(chan int) // Create a new channel.
	go Generate(ch)      // Start Generate() as a subprocess.
	for {
		prime := <-ch
		print(prime, "\n")
		ch1 := make(chan int)
		go Filter(ch, ch1, prime)
		ch = ch1
	}
}

func main() {
	runtime.GOMAXPROCS(4)
	Sieve()
}

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

end of thread, other threads:[~2011-01-19 15:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <AANLkTinx9AiBN4=7knPEK8sKuuCUe+mhhNaP-yZzqVSS@mail.gmail.com>
     [not found] ` <AANLkTikf4cgk7hab5rLLFWyv-c-0XU6WPJW0Ahm4JehM@mail.gmail.com>
     [not found]   ` <AANLkTi=PdAFFDw=ps6DcR38xno_mNb8eGZRJGxL0VpQC@mail.gmail.com>
     [not found]     ` <AANLkTinDengSNpD6pEg_cF6xivxc3qU3=tQFW7Wyo769@mail.gmail.com>
     [not found]       ` <AANLkTiky+x0gBcr84_p0Mf9HKqGVoTFcyNrdofEMS9_a@mail.gmail.com>
2011-01-19  2:37         ` [9fans] Fwd: plan9 go output faults on 9vx with rfork ron minnich
     [not found] <AANLkTikJ3y5exFtTic+8dhUsUqeZBDmR=S-8VzKDK0GH@mail.gmail.com>
     [not found] ` <AANLkTink4CrELJfGf3W15caSYX8Se5ygsm_WeMRdCBz=@mail.gmail.com>
     [not found]   ` <AANLkTikUa1KF+8NP54BHicus++YbeZbD48E7z=1H0Y5V@mail.gmail.com>
2011-01-19 15:52     ` ron minnich

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