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

fix(gnovm): fix crash stack overflow when print value of self referencing structure #2851

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

MikaelVallenet
Copy link
Contributor

@MikaelVallenet MikaelVallenet commented Sep 26, 2024

Fix stack overflow when printing value of recursive self referencing struct

resolve #2850

Methodology used

I added a stack to store the struct type already processed, then each time we process a struct i check if this struct type is already processed, if yes i remplace it by an empty struct so it avoid crash on recursive.

func gno2GoType(t Type, seen map[Type]reflect.Type) reflect.Type
		if val, ok := seen[t]; ok {
			return val
		}

		placeholder := reflect.TypeOf(struct{}{})
		seen[t] = placeholder
Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

Copy link

codecov bot commented Sep 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.95%. Comparing base (577c462) to head (49ff9dc).
Report is 10 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2851      +/-   ##
==========================================
+ Coverage   60.92%   60.95%   +0.02%     
==========================================
  Files         564      564              
  Lines       75267    75389     +122     
==========================================
+ Hits        45854    45950      +96     
- Misses      26041    26048       +7     
- Partials     3372     3391      +19     
Flag Coverage Δ
contribs/gnodev 61.46% <ø> (ø)
contribs/gnofaucet 14.46% <ø> (ø)
gno.land 67.17% <ø> (ø)
gnovm 65.78% <100.00%> (+<0.01%) ⬆️
misc/genstd 80.54% <ø> (ø)
misc/logos 19.88% <ø> (-0.36%) ⬇️
tm2 62.07% <ø> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot added the 📦 🤖 gnovm Issues or PRs gnovm related label Sep 27, 2024
@MikaelVallenet MikaelVallenet changed the title WIP - fix(gnovm): fix crash stack overflow when print value of self referencing structure fix(gnovm): fix crash stack overflow when print value of self referencing structure Sep 27, 2024
@MikaelVallenet MikaelVallenet marked this pull request as ready for review September 30, 2024 09:10
@MikaelVallenet
Copy link
Contributor Author

Ready for review ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🤖 gnovm Issues or PRs gnovm related
Projects
Status: No status
Status: Triage
Development

Successfully merging this pull request may close these issues.

bug: crash stack overflow / size exceeded when printing value of self referencing structure
1 participant