Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic on FileSystemList.Get #166

Closed
bananabrick opened this issue Aug 10, 2022 · 3 comments · Fixed by #188
Closed

panic on FileSystemList.Get #166

bananabrick opened this issue Aug 10, 2022 · 3 comments · Fixed by #188
Labels

Comments

@bananabrick
Copy link

goroutine 83 [running]:
github.com/elastic/gosigar.(*FileSystemList).Get.func1({0xc0019b8ab0, 0xc000ae9000})
	github.com/elastic/gosigar/external/com_github_elastic_gosigar/sigar_linux_common.go:113 +0x1b0
github.com/elastic/gosigar.readFile({0x4e8860e, 0x200000003}, 0xc000ac7440)
	github.com/elastic/gosigar/external/com_github_elastic_gosigar/sigar_linux_common.go:386 +0x208
github.com/elastic/gosigar.(*FileSystemList).Get(0xc000ac7508)
	github.com/elastic/gosigar/external/com_github_elastic_gosigar/sigar_linux_common.go:106 +0x8f
github.com/cockroachdb/cockroach/pkg/storage.getFileSystemProperties({0x6355138, 0xc000828e40}, {0xc00095f2f0, 0x21})
	github.com/cockroachdb/cockroach/pkg/storage/store_properties.go:60 +0x1d4
github.com/cockroachdb/cockroach/pkg/storage.computeStoreProperties({0x6355138, 0xc000828e40}, {0xc00095f2f0, 0x3d}, 0x47, 0x59)

If an entry in the mount table file doesn't have the options defined, then FileSystemList.Get can panic as shown.

@andrewkroh andrewkroh added the bug label Aug 11, 2022
@dkossako
Copy link

dkossako commented Aug 15, 2022

This issue is related to present docker volumes in OS. When docker is turned off (service docker stop) then cockroach starts fine.

@ap-wtioit
Copy link

This issue causes our graylog-sidecars to restart on build systems:

Jan 23 09:13:30 hostname.fqdn systemd[1]: graylog-sidecar.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Jan 23 09:13:30 hostname.fqdn systemd[1]: graylog-sidecar.service: Failed with result 'exit-code'.
Jan 23 09:15:30 hostname.fqdn systemd[1]: graylog-sidecar.service: Scheduled restart job, restart counter is at 136.
Jan 23 09:15:30 hostname.fqdn systemd[1]: Stopped Wrapper service for Graylog controlled collector.
Jan 23 09:15:30 hostname.fqdn systemd[1]: Started Wrapper service for Graylog controlled collector.
Jan 23 09:15:30 hostname.fqdn graylog-sidecar[1656265]: time="2025-01-23T09:15:30+01:00" level=info msg="Using node-id: 5fdfae72-eedc-491e-8636-85184ac45b3b"
Jan 23 09:15:30 hostname.fqdn graylog-sidecar[1656265]: time="2025-01-23T09:15:30+01:00" level=info msg="Starting signal distributor"
Jan 23 09:15:30 hostname.fqdn graylog-sidecar[1656265]: panic: runtime error: index out of range [3] with length 3
Jan 23 09:15:30 hostname.fqdn graylog-sidecar[1656265]: goroutine 6 [running]:
Jan 23 09:15:30 hostname.fqdn graylog-sidecar[1656265]: github.com/elastic/gosigar.(*FileSystemList).Get.func1({0xc00039ba40?, 0xc0000f8000?})
Jan 23 09:15:30 hostname.fqdn graylog-sidecar[1656265]:         /home/jenkins/workspace/napshots_collector-sidecar_1.5.0/vendor/github.com/elastic/gosigar/sigar_linux_common.go:113>
Jan 23 09:15:30 hostname.fqdn graylog-sidecar[1656265]: github.com/elastic/gosigar.readFile({0x81f16f?, 0x2f000000008271fb?}, 0xc0000ef448)
Jan 23 09:15:30 hostname.fqdn graylog-sidecar[1656265]:         /home/jenkins/workspace/napshots_collector-sidecar_1.5.0/vendor/github.com/elastic/gosigar/sigar_linux_common.go:386>
Jan 23 09:15:30 hostname.fqdn graylog-sidecar[1656265]: github.com/elastic/gosigar.(*FileSystemList).Get(0xc0000ef550)
Jan 23 09:15:30 hostname.fqdn graylog-sidecar[1656265]:         /home/jenkins/workspace/napshots_collector-sidecar_1.5.0/vendor/github.com/elastic/gosigar/sigar_linux_common.go:106>
Jan 23 09:15:30 hostname.fqdn graylog-sidecar[1656265]: github.com/Graylog2/collector-sidecar/common.GetFileSystemList75({0xc0000ef680?, 0xc0000ef680?})
Jan 23 09:15:30 hostname.fqdn graylog-sidecar[1656265]:         /home/jenkins/workspace/napshots_collector-sidecar_1.5.0/common/sigar.go:111 +0x3f
Jan 23 09:15:30 hostname.fqdn graylog-sidecar[1656265]: github.com/Graylog2/collector-sidecar/api.UpdateRegistration(0x8087a0?, {0x0, 0x0}, 0xc000018700, 0xc0001e2180?, 0xc00009e8a>
Jan 23 09:15:30 hostname.fqdn graylog-sidecar[1656265]:         /home/jenkins/workspace/napshots_collector-sidecar_1.5.0/api/graylog.go:170 +0x185
Jan 23 09:15:30 hostname.fqdn graylog-sidecar[1656265]: github.com/Graylog2/collector-sidecar/services.updateCollectorRegistration(0x0?, {0x0, 0x0}, 0x0?, 0x0?)
Jan 23 09:15:30 hostname.fqdn graylog-sidecar[1656265]:         /home/jenkins/workspace/napshots_collector-sidecar_1.5.0/services/periodicals.go:124 +0x165
Jan 23 09:15:30 hostname.fqdn graylog-sidecar[1656265]: github.com/Graylog2/collector-sidecar/services.StartPeriodicals.func1()
Jan 23 09:15:30 hostname.fqdn graylog-sidecar[1656265]:         /home/jenkins/workspace/napshots_collector-sidecar_1.5.0/services/periodicals.go:63 +0x385
Jan 23 09:15:30 hostname.fqdn graylog-sidecar[1656265]: created by github.com/Graylog2/collector-sidecar/services.StartPeriodicals in goroutine 1
Jan 23 09:15:30 hostname.fqdn graylog-sidecar[1656265]:         /home/jenkins/workspace/napshots_collector-sidecar_1.5.0/services/periodicals.go:38 +0x4f
Jan 23 09:15:30 hostname.fqdn systemd[1]: graylog-sidecar.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Jan 23 09:15:30 hostname.fqdn systemd[1]: graylog-sidecar.service: Failed with result 'exit-code'.
Jan 23 09:17:30 hostname.fqdn systemd[1]: graylog-sidecar.service: Scheduled restart job, restart counter is at 137.
Jan 23 09:17:30 hostname.fqdn systemd[1]: Stopped Wrapper service for Graylog controlled collector.
Jan 23 09:17:30 hostname.fqdn systemd[1]: Started Wrapper service for Graylog controlled collector.

@ap-wtioit
Copy link

ap-wtioit commented Jan 23, 2025

From what i can understand in the go code (my go is very minimal):

	err := readFile(getMountTableFileName(), func(line string) bool {
		fields := strings.Fields(line)
...

uses

func readFile(file string, handler func(string) bool) error {
	contents, err := ioutil.ReadFile(file)
	if err != nil {
		return err
	}

	reader := bufio.NewReader(bytes.NewBuffer(contents))

	for {
		line, _, err := reader.ReadLine()
		if err == io.EOF {
...

to read /etc/mtab

https://pkg.go.dev/bufio#Reader.ReadLine states

ReadLine tries to return a single line, not including the end-of-line bytes. If the line was too long for the buffer then isPrefix is set and the beginning of the line is returned. The rest of the line will be returned from future calls. isPrefix will be false when returning the last fragment of the line. The returned buffer is only valid until the next call to ReadLine. ReadLine either returns a non-nil line or it returns an error, never both.

The code calling ReadLine seems to discard isPrefix and on long lines is then surprised when the next line is a continuation of the last line (possibly containing less than 4 fields)

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

Successfully merging a pull request may close this issue.

4 participants