Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

config.PoolSpans(true) will panic #416

Closed
philchia opened this issue Aug 14, 2019 · 7 comments
Closed

config.PoolSpans(true) will panic #416

philchia opened this issue Aug 14, 2019 · 7 comments

Comments

@philchia
Copy link

philchia commented Aug 14, 2019

i create a new tracer with 128bit and pool span options, found that the PoolSpans(true) options may panic my app

cfg.NewTracer(
		config.Gen128Bit(true),
		config.PoolSpans(true),
	)

i walk through the code base, found that

func (t *Tracer) newSpan() *Span {
	if !t.options.poolSpans {
		return &Span{}
	}
	sp := t.spanPool.Get().(*Span)
	sp.context = emptyContext
	sp.tracer = nil
	sp.tags = nil
	sp.logs = nil
	return sp
}

and

func (t *Tracer) reportSpan(sp *Span) {
	t.metrics.SpansFinished.Inc(1)
	if sp.context.IsSampled() {
		t.reporter.Report(sp)
	}
	if t.options.poolSpans {
		t.spanPool.Put(sp)
	}
}

but t.reporter.Report(sp) may be an async operation by put that span into a buffered channel, and then you guys put the span back into the pool, the span is still alive in the channel, this will cause some race condition or nil pointer reference therefore panic the program

@yurishkuro
Copy link
Member

Is this with the standard Jaeger reporter or a custom one?
Is 128bit relevant?

@philchia
Copy link
Author

128bit not relevant, its the standard jaeger remote reporter

@philchia
Copy link
Author

func (r *remoteReporter) Report(span *Span) {
	select {
	case r.queue <- reporterQueueItem{itemType: reporterQueueItemSpan, span: span}:
		atomic.AddInt64(&r.queueLength, 1)
	default:
		r.metrics.ReporterDropped.Inc(1)
	}
}

r.queue is a buffered channel

@guanw
Copy link

guanw commented Aug 15, 2019

@philchia You might be interested to see this

@philchia
Copy link
Author

@guanw the mr not exists in the latest release

@guanw
Copy link

guanw commented Aug 17, 2019

@yurishkuro I guess we need to push a new release for jaeger-client-go?

@philchia philchia closed this as completed Sep 2, 2019
@yurishkuro
Copy link
Member

Fixed in 2.17

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants