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

Stack overflow with v0.4.4 #16

Closed
stoneman opened this issue Feb 7, 2023 · 5 comments · Fixed by #19
Closed

Stack overflow with v0.4.4 #16

stoneman opened this issue Feb 7, 2023 · 5 comments · Fixed by #19
Labels
bug Something isn't working

Comments

@stoneman
Copy link

stoneman commented Feb 7, 2023

musttag 0.4.4 is experiencing a stack overflow when run on one of our projects. I can't share that project unfortunately but the output of musttag ./... is provided in the attached file.

The problem doesn't occur if I revert this change: 9229084#diff-cfb5a4e47e6f8c71c0c2f50fffec7a51b18984f95177a9c1af9c436475810a99R209-R213

I added some logging at it seems to be looping over some structs from go-github.

I'm out of time to look at this for now but thought I'd let you know what I've found so far in case the problem/solution is obvious to you.

@tmzane
Copy link
Member

tmzane commented Feb 8, 2023

Thank you for the report, I'll take a look!

@AlekSi
Copy link

AlekSi commented Feb 9, 2023

We are having the same issue in a public project that uses musttag via golangci-lint: https://github.com/FerretDB/FerretDB/actions/runs/4119737045/jobs/7113756954

@SVilgelm
Copy link
Contributor

A simple package to reproduce:

package tmp

import (
	"encoding/json"
)

type Human struct {
	Mom      *Human   `json:"mom"`
	Dad      *Human   `json:"dad"`
	Children []*Human `json:"children"`
}

func encode(v *Human) ([]byte, error) {
	return json.Marshal(v)
}

so the stack overflow happens when a struct has a field with type of those struct, I already have a fix, will publish the PR in couple of minutes

SVilgelm added a commit to SVilgelm/musttag that referenced this issue Feb 10, 2023
fix go-simpler#16 with stack overflow issue when a struct has the fields of self type
SVilgelm added a commit to SVilgelm/musttag that referenced this issue Feb 10, 2023
fix go-simpler#16 with stack overflow issue when a struct has the fields of self type
SVilgelm added a commit to SVilgelm/musttag that referenced this issue Feb 10, 2023
fix go-simpler#16 with stack overflow issue when a struct has the fields of self type
@tmzane tmzane added the bug Something isn't working label Feb 11, 2023
tmzane pushed a commit that referenced this issue Feb 11, 2023
fix #16 with stack overflow issue when a struct has the fields of self type
@tmzane
Copy link
Member

tmzane commented Feb 14, 2023

Hey @stoneman, I was going to release a new version when #17 is closed, so it would include all the recent fixes. But if you find the current state of main useful, I can definitely push a tag for it 👍

@tmzane
Copy link
Member

tmzane commented Feb 14, 2023

Please take a look at https://github.com/junk1tm/musttag/releases/tag/v0.4.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants