Code Monkey home page Code Monkey logo

archived-findings's Issues

kojhliang/hyperledger-fabric-resolve-make-docker-error: fabric/core/committer/txvalidator/validator.go; 13 LoC

Found a possible issue in kojhliang/hyperledger-fabric-resolve-make-docker-error at fabric/core/committer/txvalidator/validator.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 13 line(s) of Go which triggered the analyzer.
		for tIdx, d := range block.Data.Data {
			// ensure that we don't have too many concurrent validation workers
			v.Support.Acquire(context.Background(), 1)

			go func(index int, data []byte) {
				defer v.Support.Release(1)

				v.validateTx(&blockValidationRequest{
					d:     data,
					block: block,
					tIdx:  index,
				}, results)
			}(tIdx, d)
		}

commit ID: d7b48f7fade746555e3c01cdea452a89b63e2ae1

venon2fork/bundleCourseVidYouProjet: ch10/cloGo.go; 4 LoC

Found a possible issue in venon2fork/bundleCourseVidYouProjet at ch10/cloGo.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 4 line(s) of Go which triggered the analyzer.
	for i := 0; i <= 20; i++ {
		go func() {
			fmt.Print(i, " ")
		}()
	}

commit ID: 80b6ca122fe4a52943823c8931f7a190c578faa4

rrreeeyyy/exporter_proxy: vendor/github.com/lestrrat/go-server-starter/starter.go; 9 LoC

Found a possible issue in rrreeeyyy/exporter_proxy at vendor/github.com/lestrrat/go-server-starter/starter.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 9 line(s) of Go which triggered the analyzer.
				for _, sig := range sigs {
					// we need to resend these signals so it can be caught in the
					// main routine...
					go func() { sigCh <- sig }()
					if sysSig, ok := sig.(syscall.Signal); ok {
						if sysSig != syscall.SIGHUP {
							gotSig = true
						}
					}
				}

commit ID: 9b293bb52b1d64484dcc2785959d24979bb16652

luizbafilho/fusis: vendor/github.com/coreos/etcd/clientv3/client_test.go; 27 LoC

Found a possible issue in luizbafilho/fusis at vendor/github.com/coreos/etcd/clientv3/client_test.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 27 line(s) of Go which triggered the analyzer.
	for i, cfg := range testCfgs {
		donec := make(chan error)
		go func() {
			// without timeout, dial continues forever on ipv4 black hole
			c, err := New(cfg)
			if c != nil || err == nil {
				t.Errorf("#%d: new client should fail", i)
			}
			donec <- err
		}()

		time.Sleep(10 * time.Millisecond)

		select {
		case err := <-donec:
			t.Errorf("#%d: dial didn't wait (%v)", i, err)
		default:
		}

		select {
		case <-time.After(5 * time.Second):
			t.Errorf("#%d: failed to timeout dial on time", i)
		case err := <-donec:
			if err != context.DeadlineExceeded {
				t.Errorf("#%d: unexpected error %v, want %v", i, err, context.DeadlineExceeded)
			}
		}
	}

commit ID: 22c38b193875a17eeeaf1fd1efd40698ed5ad424

grufwub/ircg: ircg.go; 24 LoC

Found a possible issue in grufwub/ircg at ircg.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 24 line(s) of Go which triggered the analyzer.
    for _, listener := range Serv.Listeners {
        log.Printf("Now serving on: %s\n", listener.Listener.Addr().String())
        go func() {
            for {
                /* Accept new connection */
                conn, err := listener.Accept()
                if err != nil {
                    log.Printf("Accept connection failed: %s\n", err.Error())
                }

                /* Run this in a separate goroutine to get straight back to accepting */
                go func() {
                    /* Setup new client */
                    client := NewIrcClient(conn)
                    client.Init()

                    /* Add the client to the server client map */
                    Server.AddClient(client)

                    /* Start the client loop :) */
                    go client.Serve()
                }()
            }
        }()
    }

commit ID: 40d6d4176216e8a66c3df3048c0747f6db975b52

nxgtw/dp-etcd: clientv3/client_test.go; 27 LoC

Found a possible issue in nxgtw/dp-etcd at clientv3/client_test.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 27 line(s) of Go which triggered the analyzer.
	for i, cfg := range testCfgs {
		donec := make(chan error)
		go func() {
			// without timeout, dial continues forever on ipv4 black hole
			c, err := New(cfg)
			if c != nil || err == nil {
				t.Errorf("#%d: new client should fail", i)
			}
			donec <- err
		}()

		time.Sleep(10 * time.Millisecond)

		select {
		case err := <-donec:
			t.Errorf("#%d: dial didn't wait (%v)", i, err)
		default:
		}

		select {
		case <-time.After(5 * time.Second):
			t.Errorf("#%d: failed to timeout dial on time", i)
		case err := <-donec:
			if err != context.DeadlineExceeded {
				t.Errorf("#%d: unexpected error %v, want %v", i, err, context.DeadlineExceeded)
			}
		}
	}

commit ID: 4a9fee46e159791069546a12abe8a0d099b423b7

ehazlett/cni-marengo: vendor/golang.org/x/net/internal/netreflect/socket_test.go; 26 LoC

Found a possible issue in ehazlett/cni-marengo at vendor/golang.org/x/net/internal/netreflect/socket_test.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 26 line(s) of Go which triggered the analyzer.
	for _, network := range []string{"tcp", "unix", "unixpacket"} {
		if !nettest.TestableNetwork(network) {
			continue
		}
		ln, err := nettest.NewLocalListener(network)
		if err != nil {
			t.Error(err)
			continue
		}
		defer func() {
			path := ln.Addr().String()
			ln.Close()
			if network == "unix" || network == "unixpacket" {
				os.Remove(path)
			}
		}()
		c, err := net.Dial(ln.Addr().Network(), ln.Addr().String())
		if err != nil {
			t.Error(err)
			continue
		}
		defer c.Close()
		if _, err := netreflect.SocketOf(c); err != nil {
			t.Error(err)
			continue
		}
	}

commit ID: fa2b6aee930ee7c33464c36b2aba9fa7f8b4e8ff

iyacontrol/add-ebs-tags-controller: vendor/k8s.io/client-go/rest/watch/decoder_test.go; 50 LoC

Found a possible issue in iyacontrol/add-ebs-tags-controller at vendor/k8s.io/client-go/rest/watch/decoder_test.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 50 line(s) of Go which triggered the analyzer.
	for _, eventType := range table {
		out, in := io.Pipe()

		decoder := restclientwatch.NewDecoder(streaming.NewDecoder(out, getDecoder()), getDecoder())

		expect := &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "foo"}}
		encoder := json.NewEncoder(in)
		go func() {
			data, err := runtime.Encode(scheme.Codecs.LegacyCodec(v1.SchemeGroupVersion), expect)
			if err != nil {
				t.Fatalf("Unexpected error %v", err)
			}
			event := metav1.WatchEvent{
				Type:   string(eventType),
				Object: runtime.RawExtension{Raw: json.RawMessage(data)},
			}
			if err := encoder.Encode(&event); err != nil {
				t.Errorf("Unexpected error %v", err)
			}
			in.Close()
		}()

		done := make(chan struct{})
		go func() {
			action, got, err := decoder.Decode()
			if err != nil {
				t.Fatalf("Unexpected error %v", err)
			}
			if e, a := eventType, action; e != a {
				t.Errorf("Expected %v, got %v", e, a)
			}
			if e, a := expect, got; !apiequality.Semantic.DeepDerivative(e, a) {
				t.Errorf("Expected %v, got %v", e, a)
			}
			t.Logf("Exited read")
			close(done)
		}()
		<-done

		done = make(chan struct{})
		go func() {
			_, _, err := decoder.Decode()
			if err == nil {
				t.Errorf("Unexpected nil error")
			}
			close(done)
		}()
		<-done

		decoder.Close()
	}

commit ID: 639fe4729f4b638f9d2a8514ff3a3c334bf7a498

browserflood/browserflood: cmd_spawn.go; 6 LoC

Found a possible issue in browserflood/browserflood at cmd_spawn.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 6 line(s) of Go which triggered the analyzer.
	for i := 0; i < int(n); i++ {
		go func() {
			r, e := spawn(s, i, p)
			results <- r
			errs <- e
		}()
	}

commit ID: 708ffaeeee69fff8d047712164e7c0302b75df10

RTradeLtd/go-ipfs-plugin-i2p-gateway: vendor/gx/ipfs/QmTJCJaS8Cpjc2MkoS32iwr4zMZtbLkaF9GJsUgH1uwtN9/go-libp2p-swarm/swarm_test.go; 110 LoC

Found a possible issue in RTradeLtd/go-ipfs-plugin-i2p-gateway at vendor/gx/ipfs/QmTJCJaS8Cpjc2MkoS32iwr4zMZtbLkaF9GJsUgH1uwtN9/go-libp2p-swarm/swarm_test.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 110 line(s) of Go which triggered the analyzer.
	for _, s1 := range swarms {
		log.Debugf("-------------------------------------------------------")
		log.Debugf("%s ping pong round", s1.LocalPeer())
		log.Debugf("-------------------------------------------------------")

		_, cancel := context.WithCancel(ctx)
		got := map[peer.ID]int{}
		errChan := make(chan error, MsgNum*len(swarms))
		streamChan := make(chan inet.Stream, MsgNum)

		// send out "ping" x MsgNum to every peer
		go func() {
			defer close(streamChan)

			var wg sync.WaitGroup
			send := func(p peer.ID) {
				defer wg.Done()

				// first, one stream per peer (nice)
				stream, err := s1.NewStream(ctx, p)
				if err != nil {
					errChan <- err
					return
				}

				// send out ping!
				for k := 0; k < MsgNum; k++ { // with k messages
					msg := "ping"
					log.Debugf("%s %s %s (%d)", s1.LocalPeer(), msg, p, k)
					if _, err := stream.Write([]byte(msg)); err != nil {
						errChan <- err
						continue
					}
				}

				// read it later
				streamChan <- stream
			}

			for _, s2 := range swarms {
				if s2.LocalPeer() == s1.LocalPeer() {
					continue // dont send to self...
				}

				wg.Add(1)
				go send(s2.LocalPeer())
			}
			wg.Wait()
		}()

		// receive "pong" x MsgNum from every peer
		go func() {
			defer close(errChan)
			count := 0
			countShouldBe := MsgNum * (len(swarms) - 1)
			for stream := range streamChan { // one per peer
				defer stream.Close()

				// get peer on the other side
				p := stream.Conn().RemotePeer()

				// receive pings
				msgCount := 0
				msg := make([]byte, 4)
				for k := 0; k < MsgNum; k++ { // with k messages

					// read from the stream
					if _, err := stream.Read(msg); err != nil {
						errChan <- err
						continue
					}

					if string(msg) != "pong" {
						errChan <- fmt.Errorf("unexpected message: %s", msg)
						continue
					}

					log.Debugf("%s %s %s (%d)", s1.LocalPeer(), msg, p, k)
					msgCount++
				}

				got[p] = msgCount
				count += msgCount
			}

			if count != countShouldBe {
				errChan <- fmt.Errorf("count mismatch: %d != %d", count, countShouldBe)
			}
		}()

		// check any errors (blocks till consumer is done)
		for err := range errChan {
			if err != nil {
				t.Error(err.Error())
			}
		}

		log.Debugf("%s got pongs", s1.LocalPeer())
		if (len(swarms) - 1) != len(got) {
			t.Errorf("got (%d) less messages than sent (%d).", len(got), len(swarms))
		}

		for p, n := range got {
			if n != MsgNum {
				t.Error("peer did not get all msgs", p, n, "/", MsgNum)
			}
		}

		cancel()
		<-time.After(10 * time.Millisecond)
	}

commit ID: f8e40a1c034fb8bdaf0c4af6a395a787bade270b

luizbafilho/fusis: vendor/github.com/coreos/etcd/integration/v3_watch_test.go; 85 LoC

Found a possible issue in luizbafilho/fusis at vendor/github.com/coreos/etcd/integration/v3_watch_test.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 85 line(s) of Go which triggered the analyzer.
	for i, tt := range tests {
		clus := NewClusterV3(t, &ClusterConfig{Size: 3})

		wAPI := toGRPC(clus.RandClient()).Watch
		ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
		defer cancel()
		wStream, err := wAPI.Watch(ctx)
		if err != nil {
			t.Fatalf("#%d: wAPI.Watch error: %v", i, err)
		}

		err = wStream.Send(tt.watchRequest)
		if err != nil {
			t.Fatalf("#%d: wStream.Send error: %v", i, err)
		}

		// ensure watcher request created a new watcher
		cresp, err := wStream.Recv()
		if err != nil {
			t.Errorf("#%d: wStream.Recv error: %v", i, err)
			clus.Terminate(t)
			continue
		}
		if !cresp.Created {
			t.Errorf("#%d: did not create watchid, got %+v", i, cresp)
			clus.Terminate(t)
			continue
		}
		if cresp.Canceled {
			t.Errorf("#%d: canceled watcher on create %+v", i, cresp)
			clus.Terminate(t)
			continue
		}

		createdWatchId := cresp.WatchId
		if cresp.Header == nil || cresp.Header.Revision != 1 {
			t.Errorf("#%d: header revision got +%v, wanted revison 1", i, cresp)
			clus.Terminate(t)
			continue
		}

		// asynchronously create keys
		go func() {
			for _, k := range tt.putKeys {
				kvc := toGRPC(clus.RandClient()).KV
				req := &pb.PutRequest{Key: []byte(k), Value: []byte("bar")}
				if _, err := kvc.Put(context.TODO(), req); err != nil {
					t.Fatalf("#%d: couldn't put key (%v)", i, err)
				}
			}
		}()

		// check stream results
		for j, wresp := range tt.wresps {
			resp, err := wStream.Recv()
			if err != nil {
				t.Errorf("#%d.%d: wStream.Recv error: %v", i, j, err)
			}

			if resp.Header == nil {
				t.Fatalf("#%d.%d: unexpected nil resp.Header", i, j)
			}
			if resp.Header.Revision != wresp.Header.Revision {
				t.Errorf("#%d.%d: resp.Header.Revision got = %d, want = %d", i, j, resp.Header.Revision, wresp.Header.Revision)
			}

			if wresp.Created != resp.Created {
				t.Errorf("#%d.%d: resp.Created got = %v, want = %v", i, j, resp.Created, wresp.Created)
			}
			if resp.WatchId != createdWatchId {
				t.Errorf("#%d.%d: resp.WatchId got = %d, want = %d", i, j, resp.WatchId, createdWatchId)
			}

			if !reflect.DeepEqual(resp.Events, wresp.Events) {
				t.Errorf("#%d.%d: resp.Events got = %+v, want = %+v", i, j, resp.Events, wresp.Events)
			}
		}

		rok, nr := waitResponse(wStream, 1*time.Second)
		if !rok {
			t.Errorf("unexpected pb.WatchResponse is received %+v", nr)
		}

		// can't defer because tcp ports will be in use
		clus.Terminate(t)
	}

commit ID: 22c38b193875a17eeeaf1fd1efd40698ed5ad424

nxgtw/dp-etcd: auth/store_test.go; 18 LoC

Found a possible issue in nxgtw/dp-etcd at auth/store_test.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 18 line(s) of Go which triggered the analyzer.
	for i := 0; i < 10; i++ {
		var wg sync.WaitGroup
		wg.Add(len(users))
		for u := range users {
			go func(user string) {
				defer wg.Done()
				token := fmt.Sprintf("%s(%d)", user, i)
				ctx := context.WithValue(context.WithValue(context.TODO(), AuthenticateParamIndex{}, uint64(1)), AuthenticateParamSimpleTokenPrefix{}, token)
				if _, err := as.Authenticate(ctx, user, "123"); err != nil {
					t.Fatal(err)
				}
				if _, err := as.AuthInfoFromCtx(ctx); err != nil {
					t.Fatal(err)
				}
			}(u)
		}
		time.Sleep(time.Millisecond)
		wg.Wait()
	}

commit ID: 4a9fee46e159791069546a12abe8a0d099b423b7

nxgtw/dp-etcd: clientv3/integration/txn_test.go; 22 LoC

Found a possible issue in nxgtw/dp-etcd at clientv3/integration/txn_test.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 22 line(s) of Go which triggered the analyzer.
	for i := range thenOps {
		clus.Members[0].Stop(t)
		<-clus.Members[0].StopNotify()

		donec := make(chan struct{})
		go func() {
			_, err := kv.Txn(context.TODO()).Then(thenOps[i]...).Commit()
			if err != nil {
				t.Fatalf("expected response, got error %v", err)
			}
			donec <- struct{}{}
		}()
		// wait for txn to fail on disconnect
		time.Sleep(100 * time.Millisecond)

		// restart node; client should resume
		clus.Members[0].Restart(t)
		select {
		case <-donec:
		case <-time.After(2 * clus.Members[1].ServerConfig.ReqTimeout()):
			t.Fatalf("waited too long")
		}
	}

commit ID: 4a9fee46e159791069546a12abe8a0d099b423b7

replicatedhq/ship: pkg/lifecycle/daemon/routes_navcycle_completestep.go; 33 LoC

Found a possible issue in replicatedhq/ship at pkg/lifecycle/daemon/routes_navcycle_completestep.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 33 line(s) of Go which triggered the analyzer.
	for _, step := range d.Release.Spec.Lifecycle.V1 {
		stepShared := step.Shared()
		stepID := stepShared.ID
		if stepID != requestedStep {
			continue
		}

		if ok := d.maybeAbortDueToMissingRequirement(
			stepShared.Requires,
			c,
			requestedStep,
		); !ok {
			return
		}

		errChan := make(chan error)
		d.StepProgress.Store(stepID, daemontypes.JSONProgress("v2router", map[string]interface{}{
			"status":  "working",
			"message": "working",
		}))
		go func() {
			errChan <- d.StepExecutor(d, step)
		}()
		// hack, give it 10 ms in case its an instant step. Hydrate and send will read progress from the syncMap
		time.Sleep(10 * time.Millisecond)

		d.completeMut.Lock()
		d.hydrateAndSend(step, c)
		go func() {
			defer d.completeMut.Unlock()
			d.handleAsync(errChan, debug, step, stepID)
		}()
		return
	}

commit ID: afe1f093c5dc1fea201fed2e31ab1befe2de4f32

nicolaslh/pubquiz-ws: comet/monitor.go; 7 LoC

Found a possible issue in nicolaslh/pubquiz-ws at comet/monitor.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 7 line(s) of Go which triggered the analyzer.
	for _, addr := range binds {
		go func(bind string) {
			if err := http.ListenAndServe(bind, monitorServeMux); err != nil {
				log.Error("http.ListenAndServe(\"%s\", pprofServeMux) error(%v)", addr, err)
				panic(err)
			}
		}(addr)
	}

commit ID: 4c8a83983e58dd7d6781508c9537b3c6a9d11384

nxgtw/dp-etcd: embed/etcd.go; 92 LoC

Found a possible issue in nxgtw/dp-etcd at embed/etcd.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 92 line(s) of Go which triggered the analyzer.
	for _, u := range cfg.LCUrls {
		sctx := newServeCtx(cfg.logger)
		if u.Scheme == "http" || u.Scheme == "unix" {
			if !cfg.ClientTLSInfo.Empty() {
				if cfg.logger != nil {
					cfg.logger.Warn("scheme is HTTP while key and cert files are present; ignoring key and cert files", zap.String("client-url", u.String()))
				} else {
					plog.Warningf("The scheme of client url %s is HTTP while peer key/cert files are presented. Ignored key/cert files.", u.String())
				}
			}
			if cfg.ClientTLSInfo.ClientCertAuth {
				if cfg.logger != nil {
					cfg.logger.Warn("scheme is HTTP while --client-cert-auth is enabled; ignoring client cert auth for this URL", zap.String("client-url", u.String()))
				} else {
					plog.Warningf("The scheme of client url %s is HTTP while client cert auth (--client-cert-auth) is enabled. Ignored client cert auth for this url.", u.String())
				}
			}
		}
		if (u.Scheme == "https" || u.Scheme == "unixs") && cfg.ClientTLSInfo.Empty() {
			return nil, fmt.Errorf("TLS key/cert (--cert-file, --key-file) must be provided for client url %s with HTTPs scheme", u.String())
		}

		network := "tcp"
		addr := u.Host
		if u.Scheme == "unix" || u.Scheme == "unixs" {
			network = "unix"
			addr = u.Host + u.Path
		}
		sctx.network = network

		sctx.secure = u.Scheme == "https" || u.Scheme == "unixs"
		sctx.insecure = !sctx.secure
		if oldctx := sctxs[addr]; oldctx != nil {
			oldctx.secure = oldctx.secure || sctx.secure
			oldctx.insecure = oldctx.insecure || sctx.insecure
			continue
		}

		if sctx.l, err = net.Listen(network, addr); err != nil {
			return nil, err
		}
		// net.Listener will rewrite ipv4 0.0.0.0 to ipv6 [::], breaking
		// hosts that disable ipv6. So, use the address given by the user.
		sctx.addr = addr

		if fdLimit, fderr := runtimeutil.FDLimit(); fderr == nil {
			if fdLimit <= reservedInternalFDNum {
				if cfg.logger != nil {
					cfg.logger.Fatal(
						"file descriptor limit of etcd process is too low; please set higher",
						zap.Uint64("limit", fdLimit),
						zap.Int("recommended-limit", reservedInternalFDNum),
					)
				} else {
					plog.Fatalf("file descriptor limit[%d] of etcd process is too low, and should be set higher than %d to ensure internal usage", fdLimit, reservedInternalFDNum)
				}
			}
			sctx.l = transport.LimitListener(sctx.l, int(fdLimit-reservedInternalFDNum))
		}

		if network == "tcp" {
			if sctx.l, err = transport.NewKeepAliveListener(sctx.l, network, nil); err != nil {
				return nil, err
			}
		}

		defer func() {
			if err == nil {
				return
			}
			sctx.l.Close()
			if cfg.logger != nil {
				cfg.logger.Warn(
					"closing peer listener",
					zap.String("address", u.Host),
					zap.Error(err),
				)
			} else {
				plog.Info("stopping listening for client requests on ", u.Host)
			}
		}()
		for k := range cfg.UserHandlers {
			sctx.userHandlers[k] = cfg.UserHandlers[k]
		}
		sctx.serviceRegister = cfg.ServiceRegister
		if cfg.EnablePprof || cfg.Debug {
			sctx.registerPprof()
		}
		if cfg.Debug {
			sctx.registerTrace()
		}
		sctxs[addr] = sctx
	}

commit ID: 4a9fee46e159791069546a12abe8a0d099b423b7

luizbafilho/fusis: vendor/github.com/coreos/etcd/mvcc/kv_test.go; 19 LoC

Found a possible issue in luizbafilho/fusis at vendor/github.com/coreos/etcd/mvcc/kv_test.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 19 line(s) of Go which triggered the analyzer.
	for i, tt := range tests {
		txn := s.Write()
		done := make(chan struct{}, 1)
		go func() {
			tt()
			done <- struct{}{}
		}()
		select {
		case <-done:
			t.Fatalf("#%d: operation failed to be blocked", i)
		case <-time.After(10 * time.Millisecond):
		}

		txn.End()
		select {
		case <-done:
		case <-time.After(10 * time.Second):
			testutil.FatalStack(t, fmt.Sprintf("#%d: operation failed to be unblocked", i))
		}
	}

commit ID: 22c38b193875a17eeeaf1fd1efd40698ed5ad424

nicgrayson/terraform-provider-marathon: vendor/github.com/gambol99/go-marathon/application_test.go; 28 LoC

Found a possible issue in nicgrayson/terraform-provider-marathon at vendor/github.com/gambol99/go-marathon/application_test.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 28 line(s) of Go which triggered the analyzer.
	for _, test := range tests {
		defaultConfig := NewDefaultConfig()
		defaultConfig.PollingWaitTime = waitTime
		configs := &configContainer{
			client: &defaultConfig,
			server: &serverConfig{
				scope: test.testScope,
			},
		}

		endpoint := newFakeMarathonEndpoint(t, configs)
		defer endpoint.Close()

		errCh := make(chan error)
		go func() {
			errCh <- endpoint.Client.WaitOnApplication(test.appName, test.timeout)
		}()

		select {
		case <-time.After(400 * time.Millisecond):
			assert.Fail(t, fmt.Sprintf("%s: WaitOnApplication did not complete in time", test.desc))
		case err := <-errCh:
			if test.shouldSucceed {
				assert.NoError(t, err, test.desc)
			} else {
				assert.IsType(t, err, ErrTimeoutError, test.desc)
			}
		}
	}

commit ID: 723723b68947c8978c5cf632d271c5626340ab2a

luizbafilho/fusis: vendor/github.com/coreos/etcd/embed/etcd.go; 68 LoC

Found a possible issue in luizbafilho/fusis at vendor/github.com/coreos/etcd/embed/etcd.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 68 line(s) of Go which triggered the analyzer.
	for _, u := range cfg.LCUrls {
		sctx := newServeCtx()

		if u.Scheme == "http" || u.Scheme == "unix" {
			if !cfg.ClientTLSInfo.Empty() {
				plog.Warningf("The scheme of client url %s is HTTP while peer key/cert files are presented. Ignored key/cert files.", u.String())
			}
			if cfg.ClientTLSInfo.ClientCertAuth {
				plog.Warningf("The scheme of client url %s is HTTP while client cert auth (--client-cert-auth) is enabled. Ignored client cert auth for this url.", u.String())
			}
		}
		if (u.Scheme == "https" || u.Scheme == "unixs") && cfg.ClientTLSInfo.Empty() {
			return nil, fmt.Errorf("TLS key/cert (--cert-file, --key-file) must be provided for client url %s with HTTPs scheme", u.String())
		}

		proto := "tcp"
		addr := u.Host
		if u.Scheme == "unix" || u.Scheme == "unixs" {
			proto = "unix"
			addr = u.Host + u.Path
		}

		sctx.secure = u.Scheme == "https" || u.Scheme == "unixs"
		sctx.insecure = !sctx.secure
		if oldctx := sctxs[addr]; oldctx != nil {
			oldctx.secure = oldctx.secure || sctx.secure
			oldctx.insecure = oldctx.insecure || sctx.insecure
			continue
		}

		if sctx.l, err = net.Listen(proto, addr); err != nil {
			return nil, err
		}
		// net.Listener will rewrite ipv4 0.0.0.0 to ipv6 [::], breaking
		// hosts that disable ipv6. So, use the address given by the user.
		sctx.addr = addr

		if fdLimit, fderr := runtimeutil.FDLimit(); fderr == nil {
			if fdLimit <= reservedInternalFDNum {
				plog.Fatalf("file descriptor limit[%d] of etcd process is too low, and should be set higher than %d to ensure internal usage", fdLimit, reservedInternalFDNum)
			}
			sctx.l = transport.LimitListener(sctx.l, int(fdLimit-reservedInternalFDNum))
		}

		if proto == "tcp" {
			if sctx.l, err = transport.NewKeepAliveListener(sctx.l, "tcp", nil); err != nil {
				return nil, err
			}
		}

		plog.Info("listening for client requests on ", u.Host)
		defer func() {
			if err != nil {
				sctx.l.Close()
				plog.Info("stopping listening for client requests on ", u.Host)
			}
		}()
		for k := range cfg.UserHandlers {
			sctx.userHandlers[k] = cfg.UserHandlers[k]
		}
		sctx.serviceRegister = cfg.ServiceRegister
		if cfg.EnablePprof || cfg.Debug {
			sctx.registerPprof()
		}
		if cfg.Debug {
			sctx.registerTrace()
		}
		sctxs[addr] = sctx
	}

commit ID: 22c38b193875a17eeeaf1fd1efd40698ed5ad424

cppforlife/turbulence-release: src/github.com/cloudfoundry/bosh-cli/vendor/golang.org/x/crypto/ssh/kex_test.go; 26 LoC

Found a possible issue in cppforlife/turbulence-release at src/github.com/cloudfoundry/bosh-cli/vendor/golang.org/x/crypto/ssh/kex_test.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 26 line(s) of Go which triggered the analyzer.
	for name, kex := range kexAlgoMap {
		a, b := memPipe()

		s := make(chan kexResultErr, 1)
		c := make(chan kexResultErr, 1)
		var magics handshakeMagics
		go func() {
			r, e := kex.Client(a, rand.Reader, &magics)
			c <- kexResultErr{r, e}
		}()
		go func() {
			r, e := kex.Server(b, rand.Reader, &magics, testSigners["ecdsa"])
			s <- kexResultErr{r, e}
		}()

		clientRes := <-c
		serverRes := <-s
		if clientRes.err != nil {
			t.Errorf("client: %v", clientRes.err)
		}
		if serverRes.err != nil {
			t.Errorf("server: %v", serverRes.err)
		}
		if !reflect.DeepEqual(clientRes.result, serverRes.result) {
			t.Errorf("kex %q: mismatch %#v, %#v", name, clientRes.result, serverRes.result)
		}
	}

commit ID: f6209362ce5f3a686913fee32e462a89cfef8b14

CSUNetSec/bgpmon: cmd/bgpmon/cmd/write.go; 9 LoC

Found a possible issue in CSUNetSec/bgpmon at cmd/bgpmon/cmd/write.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 9 line(s) of Go which triggered the analyzer.
	for _, fileName := range args[1:] {
		workerPool.Add()
		fmt.Printf("Writing %s\n", fileName)

		go func(f string, wp *swg.SizedWaitGroup) {
			ct, err := writeMRTFile(bc, f, sessID, filts)
			results <- writeMRTResult{fileName: f, msgCt: ct, err: err}
			wp.Done()
		}(fileName, &workerPool)
	}

commit ID: 891f3ce14aceb8ebd0e385ae83a176c81e61fa2a

cloud-gov/concourse-broker: vendor/github.com/concourse/atc/creds/vault/vendor/github.com/sethgrid/pester/main.go; 75 LoC

Found a possible issue in cloud-gov/concourse-broker at vendor/github.com/concourse/atc/creds/vault/vendor/github.com/sethgrid/pester/main.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 75 line(s) of Go which triggered the analyzer.
	for req := 0; req < concurrency; req++ {
		c.wg.Add(1)
		totalSentRequests.Add(1)
		go func(n int, p params) {
			defer c.wg.Done()
			defer totalSentRequests.Done()

			var err error
			for i := 1; i <= AttemptLimit; i++ {
				c.wg.Add(1)
				defer c.wg.Done()
				select {
				case <-finishCh:
					return
				default:
				}

				// rehydrate the body (it is drained each read)
				if len(originalRequestBody) > 0 {
					p.req.Body = ioutil.NopCloser(bytes.NewBuffer(originalRequestBody))
				}
				if len(originalBody) > 0 {
					p.body = bytes.NewBuffer(originalBody)
				}

				var resp *http.Response
				// route the calls
				switch p.method {
				case "Do":
					resp, err = httpClient.Do(p.req)
				case "Get":
					resp, err = httpClient.Get(p.url)
				case "Head":
					resp, err = httpClient.Head(p.url)
				case "Post":
					resp, err = httpClient.Post(p.url, p.bodyType, p.body)
				case "PostForm":
					resp, err = httpClient.PostForm(p.url, p.data)
				default:
					err = ErrUnexpectedMethod
				}

				// Early return if we have a valid result
				// Only retry (ie, continue the loop) on 5xx status codes
				if err == nil && resp.StatusCode < 500 {
					multiplexCh <- result{resp: resp, err: err, req: n, retry: i}
					return
				}

				c.log(ErrEntry{
					Time:    time.Now(),
					Method:  p.method,
					Verb:    p.verb,
					URL:     p.url,
					Request: n,
					Retry:   i + 1, // would remove, but would break backward compatibility
					Attempt: i,
					Err:     err,
				})

				// if it is the last iteration, grab the result (which is an error at this point)
				if i == AttemptLimit {
					multiplexCh <- result{resp: resp, err: err}
					return
				}

				// if we are retrying, we should close this response body to free the fd
				if resp != nil {
					resp.Body.Close()
				}

				// prevent a 0 from causing the tick to block, pass additional microsecond
				<-time.After(c.Backoff(i) + 1*time.Microsecond)
			}
		}(req, p)
	}

commit ID: 4ce55bc56e76b8da087c86e91374847841e1718d

luizbafilho/fusis: vendor/github.com/coreos/etcd/clientv3/integration/leasing_test.go; 32 LoC

Found a possible issue in luizbafilho/fusis at vendor/github.com/coreos/etcd/clientv3/integration/leasing_test.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 32 line(s) of Go which triggered the analyzer.
	for i := range tests {
		lkv, closeLKV, err := leasing.NewKV(clus.Client(0), "foo/", concurrency.WithTTL(1))
		testutil.AssertNil(t, err)
		defer closeLKV()

		if _, err = lkv.Get(context.TODO(), "abc"); err != nil {
			t.Fatal(err)
		}

		// down endpoint lkv uses for keepalives
		clus.Members[0].Stop(t)
		if err := waitForLeasingExpire(clus.Client(1), "foo/abc"); err != nil {
			t.Fatal(err)
		}
		waitForExpireAck(t, lkv)

		ctx, cancel := context.WithCancel(context.TODO())
		errc := make(chan error, 1)
		go func() { errc <- tests[i](ctx, lkv) }()
		// some delay to get past for ctx.Err() != nil {} loops
		time.Sleep(100 * time.Millisecond)
		cancel()

		select {
		case err := <-errc:
			if err != ctx.Err() {
				t.Errorf("#%d: expected %v, got %v", i, ctx.Err(), err)
			}
		case <-time.After(5 * time.Second):
			t.Errorf("#%d: timed out waiting for cancel", i)
		}
		clus.Members[0].Restart(t)
	}

commit ID: 22c38b193875a17eeeaf1fd1efd40698ed5ad424

luizbafilho/fusis: vendor/github.com/coreos/etcd/auth/store_test.go; 18 LoC

Found a possible issue in luizbafilho/fusis at vendor/github.com/coreos/etcd/auth/store_test.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 18 line(s) of Go which triggered the analyzer.
	for i := 0; i < 10; i++ {
		var wg sync.WaitGroup
		wg.Add(len(users))
		for u := range users {
			go func(user string) {
				defer wg.Done()
				token := fmt.Sprintf("%s(%d)", user, i)
				ctx := context.WithValue(context.WithValue(context.TODO(), "index", uint64(1)), "simpleToken", token)
				if _, err := as.Authenticate(ctx, user, "123"); err != nil {
					t.Fatal(err)
				}
				if _, err := as.AuthInfoFromCtx(ctx); err != nil {
					t.Fatal(err)
				}
			}(u)
		}
		time.Sleep(time.Millisecond)
		wg.Wait()
	}

commit ID: 22c38b193875a17eeeaf1fd1efd40698ed5ad424

ory/hydra: oauth2/oauth2_refresh_token_test.go; 148 LoC

Found a possible issue in ory/hydra at oauth2/oauth2_refresh_token_test.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 148 line(s) of Go which triggered the analyzer.
		for run := 0; run < testRuns; run++ {
			barrier := make(chan struct{})
			errorsCh := make(chan error, workers)

			go func() {
				for w := 0; w < workers; w++ {
					wg.Add(1)
					go func(run, worker int) {
						defer wg.Done()
						ctx, _ := context.WithDeadline(context.Background(), time.Now().Add(5*time.Second))
						time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond)
						// all workers will block here until the for loop above has launched all the worker go-routines
						// this is to ensure we fire all the workers off at the same
						<-barrier
						_, err := provider.NewAccessResponse(ctx, request)
						errorsCh <- err
					}(run, w)
				}

				// wait until all workers have completed their work
				wg.Wait()
				close(errorsCh)
			}()

			// let the race begin!
			// all worker go-routines will now attempt to hit the "NewAccessResponse" method
			close(barrier)

			// process worker results

			// successCount is the number of workers that were able to call "NewAccessResponse" without receiving an error.
			// if the successCount at the end of a test run is bigger than one, it means that multiple access/refresh tokens
			// were issued using the same refresh token! - https://knowyourmeme.com/memes/scared-hamster
			var successCount int
			for err := range errorsCh {
				if err != nil {
					if e := (&fosite.RFC6749Error{}); errors.As(err, &e) {
						switch e.ErrorField {

						// change logic below when the refresh handler starts returning 'fosite.ErrInvalidRequest' for other reasons.
						// as of now, this error is only returned due to concurrent transactions competing to refresh using the same token.

						case fosite.ErrInvalidRequest.ErrorField:
							// the error description copy is defined by RFC 6749 and should not be different regardless of
							// the underlying transactional aware storage backend used by hydra
							assert.Equal(t, fosite.ErrInvalidRequest.DescriptionField, e.DescriptionField)
							// the database error debug copy will be different depending on the underlying database used
							switch dbName {
							case dbal.DriverMySQL:
							case dbal.DriverPostgreSQL, dbal.DriverCockroachDB:
								var matched bool
								for _, errSubstr := range []string{
									// both postgreSQL & cockroachDB return error code 40001 for consistency errors as a result of
									// using the REPEATABLE_READ isolation level
									"SQLSTATE 40001",
									// possible if one worker starts the transaction AFTER another worker has successfully
									// refreshed the token and committed the transaction
									"not_found",
									// postgres: duplicate key value violates unique constraint "hydra_oauth2_access_request_id_idx": Unable to insert or update resource because a resource with that value exists already: The request could not be completed due to concurrent access
									"duplicate key",
									// cockroach: restart transaction: TransactionRetryWithProtoRefreshError: TransactionRetryError: retry txn (RETRY_WRITE_TOO_OLD - WriteTooOld flag converted to WriteTooOldError): "sql txn" meta={id=7f069400 key=/Table/62/2/"02a55d6e-509b-4d7a-8458-5828b2f831a1"/0 pri=0.00598277 epo=0 ts=1600955431.566576173,2 min=1600955431.566576173,0 seq=6} lock=true stat=PENDING rts=1600955431.566576173,2 wto=false max=1600955431.566576173,0: Unable to serialize access due to a concurrent update in another session: The request could not be completed due to concurrent access
									"RETRY_WRITE_TOO_OLD",
									// postgres: pq: deadlock detected
									"deadlock detected",
									// postgres: pq: could not serialize access due to concurrent update: Unable to serialize access due to a concurrent update in another session: The request could not be completed due to concurrent access
									"concurrent update",
								} {
									if strings.Contains(e.DebugField, errSubstr) {
										matched = true
										break
									}
								}

								assert.True(t, matched, "received an unexpected kind of `fosite.ErrInvalidRequest`\n"+
									"DB version: %s\n"+
									"Error description: %s\n"+
									"Error debug: %s\n"+
									"Error hint: %s\n"+
									"Raw error: %T %+v\n"+
									"Raw cause: %T %+v",
									storageVersion,
									e.DescriptionField,
									e.DebugField,
									e.HintField,
									err, err,
									e, e)
							}
						case fosite.ErrServerError.ErrorField:
							// this happens when there is an error with the storage
							if dbName == dbal.DriverCockroachDB && strings.Contains(e.DebugField, "RETRY_WRITE_TOO_OLD") {
								break
							}
							fallthrough
						default:
							// unfortunately, MySQL does not offer the same behaviour under the "REPEATABLE_READ" isolation
							// level so we have to relax this assertion just for MySQL for the time being as server_errors
							// resembling the following can be returned:
							//
							//    Error 1213: Deadlock found when trying to get lock; try restarting transaction
							if dbName != dbal.DriverMySQL {
								t.Errorf("an unexpected RFC6749 error with the name %q was returned.\n"+
									"Hint: has the refresh token error handling changed in fosite? If so, you need to add further "+
									"assertions here to cover the additional errors that are being returned by the handler.\n"+
									"DB version: %s\n"+
									"Error description: %s\n"+
									"Error debug: %s\n"+
									"Error hint: %s\n"+
									"Raw error: %+v",
									e.ErrorField,
									storageVersion,
									e.DescriptionField,
									e.DebugField,
									e.HintField,
									err)
							}
						}
					} else {
						t.Errorf("expected underlying error to be of type '*fosite.RFC6749Error', but it was "+
							"actually of type %T: %+v - DB version: %s", err, err, storageVersion)
					}
				} else {
					successCount++
				}
			}

			// IMPORTANT - skip consistency check for MySQL :(
			//
			// different DBMS's provide different consistency guarantees when using the "REPEATABLE_READ" isolation level
			// Currently, MySQL's implementation of "REPEATABLE_READ" makes it possible for multiple concurrent requests
			// to successfully utilize the same refresh token. Therefore, we skip the assertion below.
			//
			// TODO: this needs to be addressed by making it possible to use different isolation levels for various authorization
			//       flows depending on the underlying hydra storage backend. For example, if using MySQL, hydra should force
			//       the transaction isolation level to be "Serializable" when a request to the token handler is received.

			switch dbName {
			case dbal.DriverMySQL:
			case dbal.DriverPostgreSQL, dbal.DriverCockroachDB:
				require.Equal(t, 1, successCount, "CRITICAL: in test iteration %d, %d out of %d workers "+
					"were able to use the refresh token. Exactly ONE was expected to be have been successful.",
					run,
					successCount,
					workers)
			}

			// reset state for the next test iteration
			assert.NoError(t, dbRegistry.OAuth2Storage().RevokeRefreshToken(ctx, request.ID))
			assert.NoError(t, dbRegistry.OAuth2Storage().CreateRefreshTokenSession(ctx, tokenSignature, request))
		}

commit ID: 95e41ca5f0f3597be68296435a1e3c322dd6e6bb

CUG-Flipped/Flipped: Flipped-Server/pkg/mod/golang.org/x/[email protected]/go/analysis/passes/testinggoroutine/testdata/src/a/a.go; 6 LoC

Found a possible issue in CUG-Flipped/Flipped at Flipped-Server/pkg/mod/golang.org/x/[email protected]/go/analysis/passes/testinggoroutine/testdata/src/a/a.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 6 line(s) of Go which triggered the analyzer.
	for i := 0; i < b.N; i++ {
		wg.Add(1)
		go func(id int) {
			defer wg.Done()
			b.Errorf("TestFailed: %d", i)
		}(i)
	}

commit ID: 7d9499c6518035898bedc50db6392bfad9fa8857

nxgtw/dp-etcd: integration/v3_watch_test.go; 85 LoC

Found a possible issue in nxgtw/dp-etcd at integration/v3_watch_test.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 85 line(s) of Go which triggered the analyzer.
	for i, tt := range tests {
		clus := NewClusterV3(t, &ClusterConfig{Size: 3})

		wAPI := toGRPC(clus.RandClient()).Watch
		ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
		defer cancel()
		wStream, err := wAPI.Watch(ctx)
		if err != nil {
			t.Fatalf("#%d: wAPI.Watch error: %v", i, err)
		}

		err = wStream.Send(tt.watchRequest)
		if err != nil {
			t.Fatalf("#%d: wStream.Send error: %v", i, err)
		}

		// ensure watcher request created a new watcher
		cresp, err := wStream.Recv()
		if err != nil {
			t.Errorf("#%d: wStream.Recv error: %v", i, err)
			clus.Terminate(t)
			continue
		}
		if !cresp.Created {
			t.Errorf("#%d: did not create watchid, got %+v", i, cresp)
			clus.Terminate(t)
			continue
		}
		if cresp.Canceled {
			t.Errorf("#%d: canceled watcher on create %+v", i, cresp)
			clus.Terminate(t)
			continue
		}

		createdWatchId := cresp.WatchId
		if cresp.Header == nil || cresp.Header.Revision != 1 {
			t.Errorf("#%d: header revision got +%v, wanted revison 1", i, cresp)
			clus.Terminate(t)
			continue
		}

		// asynchronously create keys
		go func() {
			for _, k := range tt.putKeys {
				kvc := toGRPC(clus.RandClient()).KV
				req := &pb.PutRequest{Key: []byte(k), Value: []byte("bar")}
				if _, err := kvc.Put(context.TODO(), req); err != nil {
					t.Fatalf("#%d: couldn't put key (%v)", i, err)
				}
			}
		}()

		// check stream results
		for j, wresp := range tt.wresps {
			resp, err := wStream.Recv()
			if err != nil {
				t.Errorf("#%d.%d: wStream.Recv error: %v", i, j, err)
			}

			if resp.Header == nil {
				t.Fatalf("#%d.%d: unexpected nil resp.Header", i, j)
			}
			if resp.Header.Revision != wresp.Header.Revision {
				t.Errorf("#%d.%d: resp.Header.Revision got = %d, want = %d", i, j, resp.Header.Revision, wresp.Header.Revision)
			}

			if wresp.Created != resp.Created {
				t.Errorf("#%d.%d: resp.Created got = %v, want = %v", i, j, resp.Created, wresp.Created)
			}
			if resp.WatchId != createdWatchId {
				t.Errorf("#%d.%d: resp.WatchId got = %d, want = %d", i, j, resp.WatchId, createdWatchId)
			}

			if !reflect.DeepEqual(resp.Events, wresp.Events) {
				t.Errorf("#%d.%d: resp.Events got = %+v, want = %+v", i, j, resp.Events, wresp.Events)
			}
		}

		rok, nr := waitResponse(wStream, 1*time.Second)
		if !rok {
			t.Errorf("unexpected pb.WatchResponse is received %+v", nr)
		}

		// can't defer because tcp ports will be in use
		clus.Terminate(t)
	}

commit ID: 4a9fee46e159791069546a12abe8a0d099b423b7

luizbafilho/fusis: vendor/github.com/coreos/etcd/clientv3/integration/txn_test.go; 22 LoC

Found a possible issue in luizbafilho/fusis at vendor/github.com/coreos/etcd/clientv3/integration/txn_test.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 22 line(s) of Go which triggered the analyzer.
	for i := range thenOps {
		clus.Members[0].Stop(t)
		<-clus.Members[0].StopNotify()

		donec := make(chan struct{})
		go func() {
			_, err := kv.Txn(context.TODO()).Then(thenOps[i]...).Commit()
			if err != nil {
				t.Fatalf("expected response, got error %v", err)
			}
			donec <- struct{}{}
		}()
		// wait for txn to fail on disconnect
		time.Sleep(100 * time.Millisecond)

		// restart node; client should resume
		clus.Members[0].Restart(t)
		select {
		case <-donec:
		case <-time.After(2 * clus.Members[1].ServerConfig.ReqTimeout()):
			t.Fatalf("waited too long")
		}
	}

commit ID: 22c38b193875a17eeeaf1fd1efd40698ed5ad424

asalkeld/azure-monitoring-operator: vendor/golang.org/x/tools/go/analysis/passes/loopclosure/testdata/src/a/a.go; 5 LoC

Found a possible issue in asalkeld/azure-monitoring-operator at vendor/golang.org/x/tools/go/analysis/passes/loopclosure/testdata/src/a/a.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 5 line(s) of Go which triggered the analyzer.
	for i, v := range s {
		go func() {
			println(i) // want "loop variable i captured by func literal"
			println(v) // want "loop variable v captured by func literal"
		}()
	}

commit ID: de674b6c38572e8e4a5e64cbd34c2c6ed2ebf25f

nicolaslh/pubquiz-ws: libs/perf/perf.go; 7 LoC

Found a possible issue in nicolaslh/pubquiz-ws at libs/perf/perf.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 7 line(s) of Go which triggered the analyzer.
	for _, addr := range pprofBind {
		go func() {
			if err := http.ListenAndServe(addr, pprofServeMux); err != nil {
				log.Error("http.ListenAndServe(\"%s\", pprofServeMux) error(%v)", addr, err)
				panic(err)
			}
		}()
	}

commit ID: 4c8a83983e58dd7d6781508c9537b3c6a9d11384

j-c-levin/gdevelop-multiplayer-sample: Server/main/main.go; 7 LoC

Found a possible issue in j-c-levin/gdevelop-multiplayer-sample at Server/main/main.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 7 line(s) of Go which triggered the analyzer.
	for i, msg := range playerMap {
		go func() {
			// Mimic lag, sleep the code for 'lag' milliseconds
			time.Sleep(time.Duration(lag) * time.Millisecond)
			m.Broadcast(msg)
		}()
		delete(playerMap,i)
	}

commit ID: 6189d9a5d1c84725e22e2e29cede0f45e07a2bb9

cppforlife/turbulence-release: src/github.com/cppforlife/turbulence/incident/incident_execution.go; 8 LoC

Found a possible issue in cppforlife/turbulence-release at src/github.com/cppforlife/turbulence/incident/incident_execution.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 8 line(s) of Go which triggered the analyzer.
		for _, event := range events {
			go func() {
				req, err := i.tasksRepo.Wait(event.ID)
				if err == nil && len(req.Error) > 0 {
					err = errors.New(req.Error) // todo better error reporting?
				}
				i.events.RegisterResult(reporter.EventResult{event, err})
			}()
		}

commit ID: f6209362ce5f3a686913fee32e462a89cfef8b14

luizbafilho/fusis: vendor/github.com/docker/libnetwork/etchosts/etchosts_test.go; 22 LoC

Found a possible issue in luizbafilho/fusis at vendor/github.com/docker/libnetwork/etchosts/etchosts_test.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 22 line(s) of Go which triggered the analyzer.
	for i := 0; i < 10; i++ {
		wg.Add(1)
		go func() {
			defer wg.Done()

			rec := []Record{
				{
					IP:    fmt.Sprintf("%d.%d.%d.%d", i, i, i, i),
					Hosts: fmt.Sprintf("testhostname%d", i),
				},
			}

			for j := 0; j < 25; j++ {
				if err := Add(file.Name(), rec); err != nil {
					t.Fatal(err)
				}

				if err := Delete(file.Name(), rec); err != nil {
					t.Fatal(err)
				}
			}
		}()
	}

commit ID: 22c38b193875a17eeeaf1fd1efd40698ed5ad424

RTradeLtd/go-ipfs-plugin-i2p-gateway: vendor/gx/ipfs/QmWL6MKfes1HuSiRUNzGmwy9YyQDwcZF9V1NaA2keYKhtE/go-libp2p-pubsub/floodsub_test.go; 68 LoC

Found a possible issue in RTradeLtd/go-ipfs-plugin-i2p-gateway at vendor/gx/ipfs/QmWL6MKfes1HuSiRUNzGmwy9YyQDwcZF9V1NaA2keYKhtE/go-libp2p-pubsub/floodsub_test.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 68 line(s) of Go which triggered the analyzer.
	for _, tc := range tcs {

		hosts := getNetHosts(t, ctx, 2)
		psubs := getPubsubs(ctx, hosts)

		connect(t, hosts[0], hosts[1])
		topic := "foobar"

		block := make(chan struct{})

		err := psubs[1].RegisterTopicValidator(topic,
			func(ctx context.Context, from peer.ID, msg *Message) bool {
				<-block
				return true
			},
			WithValidatorConcurrency(tc.maxConcurrency))

		if err != nil {
			t.Fatal(err)
		}

		sub, err := psubs[1].Subscribe(topic)
		if err != nil {
			t.Fatal(err)
		}

		time.Sleep(time.Millisecond * 50)

		if len(tc.msgs) != tc.maxConcurrency+1 {
			t.Fatalf("expected number of messages sent to be maxConcurrency+1. Got %d, expected %d", len(tc.msgs), tc.maxConcurrency+1)
		}

		p := psubs[0]

		var wg sync.WaitGroup
		wg.Add(1)
		go func() {
			for _, tmsg := range tc.msgs {
				select {
				case msg := <-sub.ch:
					if !tmsg.validates {
						t.Log(msg)
						t.Error("expected message validation to drop the message because all validator goroutines are taken")
					}
				case <-time.After(333 * time.Millisecond):
					if tmsg.validates {
						t.Error("expected message validation to accept the message")
					}
				}
			}
			wg.Done()
		}()

		for i, tmsg := range tc.msgs {
			err := p.Publish(topic, tmsg.msg)
			if err != nil {
				t.Fatal(err)
			}

			// wait a bit to let pubsub's internal state machine start validating the message
			time.Sleep(10 * time.Millisecond)

			// unblock validator goroutines after we sent one too many
			if i == len(tc.msgs)-1 {
				close(block)
			}
		}
		wg.Wait()
	}

commit ID: f8e40a1c034fb8bdaf0c4af6a395a787bade270b

venon2fork/bundleCourseVidYouProjet: ch02/defer.go; 4 LoC

Found a possible issue in venon2fork/bundleCourseVidYouProjet at ch02/defer.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 4 line(s) of Go which triggered the analyzer.
	for i := 3; i > 0; i-- {
		defer func() {
			fmt.Print(i, " ")
		}()
	}

commit ID: 80b6ca122fe4a52943823c8931f7a190c578faa4

titolins/tva: vendor/golang.org/x/net/internal/netreflect/socket_test.go; 26 LoC

Found a possible issue in titolins/tva at vendor/golang.org/x/net/internal/netreflect/socket_test.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 26 line(s) of Go which triggered the analyzer.
	for _, network := range []string{"tcp", "unix", "unixpacket"} {
		if !nettest.TestableNetwork(network) {
			continue
		}
		ln, err := nettest.NewLocalListener(network)
		if err != nil {
			t.Error(err)
			continue
		}
		defer func() {
			path := ln.Addr().String()
			ln.Close()
			if network == "unix" || network == "unixpacket" {
				os.Remove(path)
			}
		}()
		c, err := net.Dial(ln.Addr().Network(), ln.Addr().String())
		if err != nil {
			t.Error(err)
			continue
		}
		defer c.Close()
		if _, err := netreflect.SocketOf(c); err != nil {
			t.Error(err)
			continue
		}
	}

commit ID: 5db66ae4f3daecb8e6f909025a8d8e22946fbf0a

tiger7456/go_crawler_zhenai: engine/concurrent.go; 2 LoC

Found a possible issue in tiger7456/go_crawler_zhenai at engine/concurrent.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 2 line(s) of Go which triggered the analyzer.
		for _, item := range result.Items {
			go func() { e.ItemChan <- item }()
		}

commit ID: e1982a8d38db2df4ad41e19421e5a6cdba4674bf

CUG-Flipped/Flipped: Flipped-Server/pkg/mod/github.com/mongodb/[email protected]/mongo/testatlas/main.go; 25 LoC

Found a possible issue in CUG-Flipped/Flipped at Flipped-Server/pkg/mod/github.com/mongodb/[email protected]/mongo/testatlas/main.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 25 line(s) of Go which triggered the analyzer.
	for idx, uri := range uris {
		client, err := mongo.Connect(ctx, options.Client().ApplyURI(uri))
		if err != nil {
			panic(createErrorMessage(idx, "Connect error: %v", err))
		}

		defer func() {
			if err = client.Disconnect(ctx); err != nil {
				panic(createErrorMessage(idx, "Disconnect error: %v", err))
			}
		}()

		db := client.Database("test")
		err = db.RunCommand(
			ctx,
			bson.D{{"isMaster", 1}},
		).Err()
		if err != nil {
			panic(createErrorMessage(idx, "isMaster error: %v", err))
		}

		coll := db.Collection("test")
		if err = coll.FindOne(ctx, bson.D{{"x", 1}}).Err(); err != nil && err != mongo.ErrNoDocuments {
			panic(createErrorMessage(idx, "FindOne error: %v", err))
		}
	}

commit ID: 7d9499c6518035898bedc50db6392bfad9fa8857

nxgtw/dp-etcd: mvcc/kv_test.go; 19 LoC

Found a possible issue in nxgtw/dp-etcd at mvcc/kv_test.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 19 line(s) of Go which triggered the analyzer.
	for i, tt := range tests {
		txn := s.Write()
		done := make(chan struct{}, 1)
		go func() {
			tt()
			done <- struct{}{}
		}()
		select {
		case <-done:
			t.Fatalf("#%d: operation failed to be blocked", i)
		case <-time.After(10 * time.Millisecond):
		}

		txn.End()
		select {
		case <-done:
		case <-time.After(10 * time.Second):
			testutil.FatalStack(t, fmt.Sprintf("#%d: operation failed to be unblocked", i))
		}
	}

commit ID: 4a9fee46e159791069546a12abe8a0d099b423b7

nicolaslh/pubquiz-ws: logic/job/monitor.go; 7 LoC

Found a possible issue in nicolaslh/pubquiz-ws at logic/job/monitor.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 7 line(s) of Go which triggered the analyzer.
	for _, addr := range binds {
		go func(bind string) {
			if err := http.ListenAndServe(bind, monitorServeMux); err != nil {
				log.Error("http.ListenAndServe(\"%s\", pprofServeMux) error(%v)", addr, err)
				panic(err)
			}
		}(addr)
	}

commit ID: 4c8a83983e58dd7d6781508c9537b3c6a9d11384

nicolaslh/pubquiz-ws: logic/monitor.go; 7 LoC

Found a possible issue in nicolaslh/pubquiz-ws at logic/monitor.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 7 line(s) of Go which triggered the analyzer.
	for _, addr := range binds {
		go func(bind string) {
			if err := http.ListenAndServe(bind, monitorServeMux); err != nil {
				log.Error("http.ListenAndServe(\"%s\", pprofServeMux) error(%v)", addr, err)
				panic(err)
			}
		}(addr)
	}

commit ID: 4c8a83983e58dd7d6781508c9537b3c6a9d11384

nicolaslh/pubquiz-ws: router/monitor.go; 7 LoC

Found a possible issue in nicolaslh/pubquiz-ws at router/monitor.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 7 line(s) of Go which triggered the analyzer.
	for _, addr := range binds {
		go func(bind string) {
			if err := http.ListenAndServe(bind, monitorServeMux); err != nil {
				log.Error("http.ListenAndServe(\"%s\", pprofServeMux) error(%v)", addr, err)
				panic(err)
			}
		}(addr)
	}

commit ID: 4c8a83983e58dd7d6781508c9537b3c6a9d11384

dmitry-msk777/Connector_1C_Enterprise: vendor/github.com/go-redis/redis/v7/cluster.go; 35 LoC

Found a possible issue in dmitry-msk777/Connector_1C_Enterprise at vendor/github.com/go-redis/redis/v7/cluster.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 35 line(s) of Go which triggered the analyzer.
	for attempt := 0; attempt <= c.opt.MaxRedirects; attempt++ {
		if attempt > 0 {
			if err := internal.Sleep(ctx, c.retryBackoff(attempt)); err != nil {
				setCmdsErr(cmds, err)
				return err
			}
		}

		failedCmds := newCmdsMap()
		var wg sync.WaitGroup

		for node, cmds := range cmdsMap.m {
			wg.Add(1)
			go func(node *clusterNode, cmds []Cmder) {
				defer wg.Done()

				err := c._processPipelineNode(ctx, node, cmds, failedCmds)
				if err == nil {
					return
				}
				if attempt < c.opt.MaxRedirects {
					if err := c.mapCmdsByNode(failedCmds, cmds); err != nil {
						setCmdsErr(cmds, err)
					}
				} else {
					setCmdsErr(cmds, err)
				}
			}(node, cmds)
		}

		wg.Wait()
		if len(failedCmds.m) == 0 {
			break
		}
		cmdsMap = failedCmds
	}

commit ID: 3d93a231bd47139218e52a4fdb179cd44cd9ea28

ooni/psiphon: oopsi/github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/crypto/ssh/kex_test.go; 28 LoC

Found a possible issue in ooni/psiphon at oopsi/github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/crypto/ssh/kex_test.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 28 line(s) of Go which triggered the analyzer.
	for name, kex := range kexAlgoMap {
		a, b := memPipe()

		s := make(chan kexResultErr, 1)
		c := make(chan kexResultErr, 1)
		var magics handshakeMagics
		go func() {
			r, e := kex.Client(a, rand.Reader, &magics)
			a.Close()
			c <- kexResultErr{r, e}
		}()
		go func() {
			r, e := kex.Server(b, rand.Reader, &magics, testSigners["ecdsa"])
			b.Close()
			s <- kexResultErr{r, e}
		}()

		clientRes := <-c
		serverRes := <-s
		if clientRes.err != nil {
			t.Errorf("client: %v", clientRes.err)
		}
		if serverRes.err != nil {
			t.Errorf("server: %v", serverRes.err)
		}
		if !reflect.DeepEqual(clientRes.result, serverRes.result) {
			t.Errorf("kex %q: mismatch %#v, %#v", name, clientRes.result, serverRes.result)
		}
	}

commit ID: dbb52fd6059f5dad0a8cfd36481d3c8e0409e1a7

NCCloud/fluid: internal/ingress/controller/controller.go; 51 LoC

Found a possible issue in NCCloud/fluid at internal/ingress/controller/controller.go

The below snippet of Go code triggered static analysis which searches for goroutines and/or defer statements
which capture loop variables.

Click here to see the code in its original context.

Click here to show the 51 line(s) of Go which triggered the analyzer.
	for _, sm := range subMaps {
		wg.Add(1)
		go func() {
			for _, upstream := range sm {
				lockCheck.RLock()
				isHTTPSfrom := []*ingress.Server{}
				for _, server := range servers {
					for _, location := range server.Locations {
						if upstream.Name == location.Backend {
							if len(upstream.Endpoints) == 0 {
								glog.V(3).Infof("upstream %v does not have any active endpoints.", upstream.Name)
								location.Backend = ""

								// check if the location contains endpoints and a custom default backend
								if location.DefaultBackend != nil {
									sp := location.DefaultBackend.Spec.Ports[0]
									endps := n.getEndpoints(location.DefaultBackend, &sp, apiv1.ProtocolTCP, &healthcheck.Config{})
									if len(endps) > 0 {
										glog.V(3).Infof("using custom default backend in server %v location %v (service %v/%v)",
											server.Hostname, location.Path, location.DefaultBackend.Namespace, location.DefaultBackend.Name)
										nb := upstream.DeepCopy()
										name := fmt.Sprintf("custom-default-backend-%v", upstream.Name)
										nb.Name = name
										nb.Endpoints = endps
										aUpstreams = append(aUpstreams, nb)
										location.Backend = name
									}
								}
							}

							// Configure Backends[].SSLPassthrough
							if server.SSLPassthrough {
								if location.Path == rootLocation {
									if location.Backend == defUpstreamName {
										glog.Warningf("ignoring ssl passthrough of %v as it doesn't have a default backend (root context)", server.Hostname)
										continue
									}

									isHTTPSfrom = append(isHTTPSfrom, server)
								}
							}
						}
					}
				}
				if len(isHTTPSfrom) > 0 {
					upstream.SSLPassthrough = true
				}
				lockCheck.RUnlock()
			}
			wg.Done()
		}()
	}

commit ID: 1167665ac94e07c04ad868381192090a2b51679b

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.