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

cmd/stdiscosrv: test suite sometimes seg faults on OpenBSD #5247

Closed
vext01 opened this Issue Oct 7, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@vext01
Copy link

vext01 commented Oct 7, 2018

This seems to be another non-deterministic failure:

$ go run build.go test
...
ok      github.com/syncthing/syncthing/lib/versioner    0.034s
ok      github.com/syncthing/syncthing/lib/watchaggregator      7.579s
ok      github.com/syncthing/syncthing/lib/weakhash     0.005s
?       github.com/syncthing/syncthing/cmd/stbench      [no test files]
?       github.com/syncthing/syncthing/cmd/stcli        [no test files]
?       github.com/syncthing/syncthing/cmd/stcompdirs   [no test files]
?       github.com/syncthing/syncthing/cmd/stdisco      [no test files]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x6efdcc]

goroutine 32 [running]:
github.com/syncthing/syncthing/vendor/github.com/syndtr/goleveldb/leveldb.(*DB).newRawIterator(0xc000080ea0, 0x0, 0x0, 0x0, 0x0, 0xc00007b8f0, 0x0, 0xc0004eaf00, 0xc00001ea00)
        /home/porter/go/src/github.com/syncthing/syncthing/vendor/github.com/syndtr/goleveldb/leveldb/db_iter.go:54 +0x29c
github.com/syncthing/syncthing/vendor/github.com/syndtr/goleveldb/leveldb.(*DB).newIterator(0xc000080ea0, 0x0, 0x0, 0x0, 0x0, 0x4, 0xc000041f88, 0x0, 0x4759b6)
        /home/porter/go/src/github.com/syncthing/syncthing/vendor/github.com/syndtr/goleveldb/leveldb/db_iter.go:79 +0x99
github.com/syncthing/syncthing/vendor/github.com/syndtr/goleveldb/leveldb.(*DB).NewIterator(0xc000080ea0, 0xc000041f88, 0x0, 0x0, 0x0)
        /home/porter/go/src/github.com/syncthing/syncthing/vendor/github.com/syndtr/goleveldb/leveldb/db.go:886 +0x146
github.com/syncthing/syncthing/cmd/stdiscosrv.(*levelDBStore).statisticsServe(0xc00001ed80, 0xc000022960, 0xc0000229c0)
        /home/porter/go/src/github.com/syncthing/syncthing/cmd/stdiscosrv/database.go:201 +0x8ff
created by github.com/syncthing/syncthing/cmd/stdiscosrv.(*levelDBStore).Serve
        /home/porter/go/src/github.com/syncthing/syncthing/cmd/stdiscosrv/database.go:167 +0x135
...

I can't get it to fail in isolation sadly:

fremen% STRACE=stdisosrcv go test -v
=== RUN   TestFixupAddresses
--- PASS: TestFixupAddresses (0.00s)
=== RUN   TestDatabaseGetSet
--- PASS: TestDatabaseGetSet (0.08s)
=== RUN   TestFilter
--- PASS: TestFilter (0.00s)
PASS
ok      github.com/syncthing/syncthing/cmd/stdiscosrv   0.236s

git version: f528923d1ef224a07d58fea21b0dca14ca18ba78

This is the last of the OpenBSD issues that I am aware of. Sorry for filing so many!

@calmh

This comment has been minimized.

Copy link
Member

calmh commented Oct 7, 2018

I can see why this might happen in the tests

@calmh

This comment has been minimized.

Copy link
Member

calmh commented Oct 7, 2018

See if this helps:

diff --git a/cmd/stdiscosrv/database.go b/cmd/stdiscosrv/database.go
index 33234ea4..8a267980 100644
--- a/cmd/stdiscosrv/database.go
+++ b/cmd/stdiscosrv/database.go
@@ -162,10 +162,10 @@ func (s *levelDBStore) Serve() {
        // Start the statistics serve routine. It will exit with us when
        // statisticsTrigger is closed.
        statisticsTrigger := make(chan struct{})
-       defer close(statisticsTrigger)
        statisticsDone := make(chan struct{})
        go s.statisticsServe(statisticsTrigger, statisticsDone)

+loop:
        for {
                select {
                case fn := <-s.inbox:
@@ -184,12 +184,17 @@ func (s *levelDBStore) Serve() {

                case <-s.stop:
                        // We're done.
-                       return
+                       close(statisticsTrigger)
+                       break loop
                }
        }
+
+       <-statisticsDone
 }

 func (s *levelDBStore) statisticsServe(trigger <-chan struct{}, done chan<- struct{}) {
+       defer close(done)
+
        for range trigger {
                t0 := time.Now()
                nowNanos := t0.UnixNano()
@vext01

This comment has been minimized.

Copy link
Author

vext01 commented Oct 16, 2018

Hi,

I was unable to reproduce the crash after reporting it.

I tried your patch anyway, and it doesn't seem to have any adverse effects.

Thanks

@calmh calmh added the build label Oct 18, 2018

@calmh calmh closed this in c1f1fd7 Oct 18, 2018

@calmh calmh added this to the v0.14.53 milestone Oct 31, 2018

@calmh calmh changed the title `cmd/stdiscosrv` test suite sometimes seg faults on OpenBSD cmd/stdiscosrv` test suite sometimes seg faults on OpenBSD Nov 13, 2018

@calmh calmh changed the title cmd/stdiscosrv` test suite sometimes seg faults on OpenBSD cmd/stdiscosrv: test suite sometimes seg faults on OpenBSD Nov 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.