Commit ddb28043 authored by Kirill Smelkov's avatar Kirill Smelkov

X rebuild: Don't return nil for empty ΔPPTreeSubSet - that leads to SIGSEGV

--- FAIL: TestΔBTail (0.74s)
    --- FAIL: TestΔBTail/rebuild/T/T1/T-T2/B0:e-B1:f-B2:g→T1/T-T/B0:g-T2/B1:h-B2:g (0.00s)
        --- FAIL: TestΔBTail/rebuild/T/T1/T-T2/B0:e-B1:f-B2:g→T1/T-T/B0:g-T2/B1:h-B2:g/_T{};R (0.00s)
            --- FAIL: TestΔBTail/rebuild/T/T1/T-T2/B0:e-B1:f-B2:g→T1/T-T/B0:g-T2/B1:h-B2:g/_T{};R/_→T1/T-T/B0:g-T/B1:e (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x632cc1]

goroutine 238 [running]:
testing.tRunner.func1.2(0x696aa0, 0x893f70)
        /home/kirr/src/tools/go/go/src/testing/testing.go:1143 +0x332
testing.tRunner.func1(0xc000001b00)
        /home/kirr/src/tools/go/go/src/testing/testing.go:1146 +0x4b6
panic(0x696aa0, 0x893f70)
        /home/kirr/src/tools/go/go/src/runtime/panic.go:965 +0x1b9
lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xbtree.PPTreeSubSet.ApplyΔ(0xc00040f9b0, 0x0)
        /home/kirr/src/neo/src/lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xbtree/pptreesubset.go:515 +0x41
lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xbtree.(*ΔTtail).rebuild(0xc00040f830, 0xc, 0xc00040f500, 0xc000142b40, 0x0, 0x0, 0x0)
        /home/kirr/src/neo/src/lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xbtree/δbtail.go:371 +0x145
lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xbtree.(*ΔBtail).rebuildAll(0xc00015dc00, 0x0, 0x0)
        /home/kirr/src/neo/src/lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xbtree/δbtail.go:319 +0x18c
lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xbtree.xverifyΔBTail_rebuild_TR(0xc000001b00, 0xc000142b40, 0xc00015dc00, 0xc00006a960, 0xc, 0xc0004863c0, 0xc00040f3b0, 0xc00040f5c0, 0xc00040f650, 0xc00040f740, ...)
        /home/kirr/src/neo/src/lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xbtree/δbtail_test.go:1127 +0x1b6
lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xbtree.xverifyΔBTail_rebuild.func1.1.1(0xc000001b00)
        /home/kirr/src/neo/src/lab.nexedi.com/nexedi/wendelin.core/wcfs/internal/xbtree/δbtail_test.go:1074 +0xafa
testing.tRunner(0xc000001b00, 0xc000555740)
        /home/kirr/src/tools/go/go/src/testing/testing.go:1193 +0xef
created by testing.(*T).Run
        /home/kirr/src/tools/go/go/src/testing/testing.go:1238 +0x2b3
exit status 2
parent 9d20f8e8
......@@ -482,6 +482,15 @@ type ΔPPTreeSubSet struct {
δnchildNonLeafs map[zodb.Oid]int
}
// NewΔPPTreeSubSet creates new empty ΔPPTreeSubSet.
func NewΔPPTreeSubSet() *ΔPPTreeSubSet {
return &ΔPPTreeSubSet{
Del: PPTreeSubSet{},
Add: PPTreeSubSet{},
δnchildNonLeafs: map[zodb.Oid]int{},
}
}
// Update updates δ to be combination of δ+δ2.
func (δ *ΔPPTreeSubSet) Update(δ2 *ΔPPTreeSubSet) {
δ.Del.UnionInplace(δ2.Del)
......
......@@ -330,7 +330,7 @@ func treediff(ctx context.Context, root zodb.Oid, δtops SetOid, δZTC SetOid, t
defer xerr.Contextf(&err, "treediff %s..%s %s", zconnOld.At(), zconnNew.At(), root)
δT = map[Key]ΔValue{}
δtrack = &ΔPPTreeSubSet{Del: PPTreeSubSet{}, Add: PPTreeSubSet{}, δnchildNonLeafs: map[zodb.Oid]int{}}
δtrack = NewΔPPTreeSubSet()
δtkeycov = &RangedKeySet{}
tracefDiff("\ntreediff %s δtops: %v δZTC: %v\n", root, δtops, δZTC)
......@@ -445,7 +445,7 @@ func diffT(ctx context.Context, A, B *Tree, δZTC SetOid, trackSet PPTreeSubSet)
defer xerr.Contextf(&err, "diffT %s %s", xidOf(A), xidOf(B))
δ = map[Key]ΔValue{}
δtrack = &ΔPPTreeSubSet{Del: PPTreeSubSet{}, Add: PPTreeSubSet{}, δnchildNonLeafs: map[zodb.Oid]int{}}
δtrack = NewΔPPTreeSubSet()
δtkeycov = &RangedKeySet{}
defer func() {
tracefDiff(" -> δ: %v\n", δ)
......
......@@ -451,7 +451,7 @@ func (δTtail *ΔTtail) rebuild1(atPrev zodb.Tid, δZ zodb.ΔRevEntry, trackNew
// skip opening DB connections if there is no change to this tree
if len(δtopsByRoot) == 0 {
return nil, nil, nil
return NewΔPPTreeSubSet(), &RangedKeySet{}, nil
}
if len(δtopsByRoot) != 1 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment