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

testing/quick: stack overflow for recursive types (2) #11148

Closed
osocurioso opened this issue Jun 10, 2015 · 1 comment
Closed

testing/quick: stack overflow for recursive types (2) #11148

osocurioso opened this issue Jun 10, 2015 · 1 comment
Milestone

Comments

@osocurioso
Copy link
Contributor

CL 10821 added generation of nil pointers to terminate recursive structures.

However, the following still does not terminate:

package main

import (
    "reflect"
    "testing/quick"
)

type R struct {
    N []*R
}

func main() {
    quick.Value(reflect.TypeOf(&R{}), nil)
}

The problem with slices (or maps) is the competition between expansion by a factor 'complexSize' and termination with probability '1/complexSize'. Some sort of automatic shrinking of the expansion factor would tip the weight in favour of termination.

To cover all problematic combinations of recursive types one should probably test a monster like the following:

type R struct {
    Ptr      *R
    SliceP   []*R
    Slice    []R
    Map      map[int]R
    MapP     map[int]*R
    MapR     map[*R]*R
    SliceMap []map[int]R
}
@josharian josharian added this to the Go1.6 milestone Jun 10, 2015
@gopherbot
Copy link

CL https://golang.org/cl/13830 mentions this issue.

@agl agl closed this as completed in 74245b0 Aug 29, 2015
@golang golang locked and limited conversation to collaborators Sep 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants