census-instrumentation/opencensus-go

Goroutine started on init() function

adrianlzt opened this issue ยท 4 comments

Describe the bug
In this init() function a gorouting is fired.

This looks like an strange behaviour for a lib, because any program importing this lib will have your goroutine running.
Found looking for a problem in Telegraf: influxdata/telegraf#5612

Found this goroutine running during my tests today. This strikes me as extremely bad practice to start unwanted goroutines no matter how "cheap" they are. If the package requires a Goroutine to run, starting it should be part of the public API that users have to start themselves.

ncw commented

Likewise importing these google APIs will also start the mystery go routine

  • google.golang.org/api/drive/v2
  • google.golang.org/api/drive/v3
  • google.golang.org/api/storage/v1
mholt commented

I can't explain how, but I believe this goroutine has a serious bug causing the CPU to spin, and somehow blocking program start. Reported in: #1200

agreed this should not be happening. i had to investigate wtf the library was and whether it posed a security risk to my application.