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

test(gnovm): add test for bounding issue #2526

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

Conversation

moul
Copy link
Member

@moul moul commented Jul 6, 2024

Cherry-picked fixes by @jaekwon from #2535


cc @jaekwon, new edge case happening after #1257.
cc @deelawn, seems that you touched this part of the code in march too #1846.
blocks #2516

$> go test tests/*.go -run 'TestFiles$/zrealm_crossrealm15' -update-golden-tests 
Machine.RunFunc("init.1") panic: new escaped mark has no object ID
Machine:
    CheckTypes: false
    Op: [OpHalt OpPopResults OpExec OpBody OpPopResults]
    Values: (len: 2)
          #1 (SetFooer func(f gno.land/r/demo/tests/crossrealm.Fooer)())
          #0 (init.1 func()())
    Exprs:
    Stmts:
          #1 bodyStmt[0/0/2]=crossrealm<VPBlock(2,0)>.CallFoo()
          #0 return
    Blocks:
          @(111) Block(ID:0000000000000000000000000000000000000000:0,Addr:0x14003d32960,Source:func SetFooer(f Fooer<VPBlock(2,...,Parent:0x14003c34780)
            f: (&(struct{} gno.land/r/crossrealm_test.fooer) *gno.land/r/crossrealm_test.fooer)
 (s vals) @(111) Block(ID:0000000000000000000000000000000000000000:0,Addr:0x140001f4830,Source:func SetFooer(f Fooer<VPBlock(2,...,Parent:0x140001fe630)
            f: (undefined)
 (s typs) @(111) [gno.land/r/demo/tests/crossrealm.Fooer]
          @(273) Block(ID:1712ac7adcfdc8e58a67e5615e20fb312394c4df:3,Addr:0x14003c34780,Source:file{ package crossrealm; import...,Parent:0x1400019a780)
            p_crossrealm: (package(p_crossrealm gno.land/p/demo/tests/p_crossrealm) package{})
            ufmt: (package(ufmt gno.land/p/demo/ufmt) package{})
 (s vals) @(273) Block(ID:0000000000000000000000000000000000000000:0,Addr:0x140001fe630,Source:file{ package crossrealm; import...,Parent:0x140001fe930)
            p_crossrealm: (package(p_crossrealm gno.land/p/demo/tests/p_crossrealm) package{})
            ufmt: (package(ufmt gno.land/p/demo/ufmt) package{})
 (s typs) @(273) [package{} package{}]
          @(495) gno.land/r/demo/tests/crossrealm
    Blocks (other):
          #2 Block(ID:0000000000000000000000000000000000000000:0,Addr:0x14003d32780,Source:func init.1() { f<VPBlock(3,3)> ...,Parent:0x14003ccfa40)
 (static) #2 Block(ID:0000000000000000000000000000000000000000:0,Addr:0x140001d3430,Source:func init.1() { f<VPBlock(3,3)> ...,Parent:0x14000190c30)
          #1 Block(ID:f5a516808f8976c33939133293d598ce3bca4e8d:3,Addr:0x14003ccfa40,Source:file{ package crossrealm_test; i...,Parent:0x1400019a3c0)
            crossrealm: (package(crossrealm gno.land/r/demo/tests/crossrealm) package{})
 (static) #1 Block(ID:0000000000000000000000000000000000000000:0,Addr:0x14000190c30,Source:file{ package crossrealm_test; i...,Parent:0x14000190f30)
            crossrealm: (package(crossrealm gno.land/r/demo/tests/crossrealm) package{})
    Frames:
          #1 [FRAME FUNC:SetFooer RECV:(undefined) (1 args) 5/1/0/2/3 LASTPKG:gno.land/r/crossrealm_test LASTRLM:Realm{Path:"gno.land/r/crossrealm_test",Time:3}#F5A516808F8976C33939133293D598CE3BCA4E8D]
          #0 [FRAME FUNC:init.1 RECV:(undefined) (0 args) 2/0/0/0/2 LASTPKG:gno.land/r/crossrealm_test LASTRLM:Realm{Path:"gno.land/r/crossrealm_test",Time:3}#F5A516808F8976C33939133293D598CE3BCA4E8D]
    Realm:
      gno.land/r/demo/tests/crossrealm
    Exceptions:

OUTPUT:

ERROR:
new escaped mark has no object ID
goroutine 7 [running]:
runtime/debug.Stack()
	/Users/moul/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.4.darwin-arm64/src/runtime/debug/stack.go:24 +0x64
runtime/debug.PrintStack()
	/Users/moul/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.4.darwin-arm64/src/runtime/debug/stack.go:16 +0x1c
command-line-arguments.RunFileTest.func1.1()
	/Users/moul/go/src/github.com/gnolang/gno/gnovm/tests/file.go:153 +0x1e0
panic({0x102f08840?, 0x102ff0990?})
	/Users/moul/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.4.darwin-arm64/src/runtime/panic.go:770 +0x124
github.com/gnolang/gno/gnovm/pkg/gnolang.(*Machine).RunFunc.func1()
	/Users/moul/go/src/github.com/gnolang/gno/gnovm/pkg/gnolang/machine.go:741 +0xf4
panic({0x102f08840?, 0x102ff0990?})
	/Users/moul/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.4.darwin-arm64/src/runtime/panic.go:770 +0x124
github.com/gnolang/gno/gnovm/pkg/gnolang.(*Realm).processNewEscapedMarks(0x140002cd420, {0x103009250, 0x140000f8f00})
	/Users/moul/go/src/github.com/gnolang/gno/gnovm/pkg/gnolang/realm.go:589 +0x290
github.com/gnolang/gno/gnovm/pkg/gnolang.(*Realm).FinalizeRealmTransaction(0x140002cd420, 0x50?, {0x103009250, 0x140000f8f00})
	/Users/moul/go/src/github.com/gnolang/gno/gnovm/pkg/gnolang/realm.go:335 +0x78
github.com/gnolang/gno/gnovm/pkg/gnolang.(*Machine).doOpReturnFromBlock(0x140002ecb48)
	/Users/moul/go/src/github.com/gnolang/gno/gnovm/pkg/gnolang/op_call.go:239 +0x28c
github.com/gnolang/gno/gnovm/pkg/gnolang.(*Machine).Run(0x140002ecb48)
	/Users/moul/go/src/github.com/gnolang/gno/gnovm/pkg/gnolang/machine.go:1225 +0x144
github.com/gnolang/gno/gnovm/pkg/gnolang.(*Machine).RunStatement(0x140002ecb48, {0x103000be0, 0x140006eb6c0})
	/Users/moul/go/src/github.com/gnolang/gno/gnovm/pkg/gnolang/machine.go:864 +0x330
github.com/gnolang/gno/gnovm/pkg/gnolang.(*Machine).RunFunc(0x140002ecb48, {0x14004a11038, 0x6})
	/Users/moul/go/src/github.com/gnolang/gno/gnovm/pkg/gnolang/machine.go:744 +0x188
github.com/gnolang/gno/gnovm/pkg/gnolang.(*Machine).runInitFromUpdates(0x140002ecb48, 0x1400019e1e0, {0x14003fc6280?, 0x1?, 0x1400062d770?})
	/Users/moul/go/src/github.com/gnolang/gno/gnovm/pkg/gnolang/machine.go:678 +0x1e4
github.com/gnolang/gno/gnovm/pkg/gnolang.(*Machine).runMemPackage(0x140002ecb48, 0x14000363bc0, 0x1, 0x0)
	/Users/moul/go/src/github.com/gnolang/gno/gnovm/pkg/gnolang/machine.go:299 +0x268
github.com/gnolang/gno/gnovm/pkg/gnolang.(*Machine).RunMemPackage(...)
	/Users/moul/go/src/github.com/gnolang/gno/gnovm/pkg/gnolang/machine.go:255
command-line-arguments.RunFileTest.func1(0x7?, 0x102ff2a58?, {0x0?, 0x0?}, 0x1400062d3e0, {0x140000393b9, 0x1a}, {0x140000393c4, 0xf}, {0x103009250, ...}, ...)
	/Users/moul/go/src/github.com/gnolang/gno/gnovm/tests/file.go:198 +0x298
command-line-arguments.RunFileTest({0x140002f6858, 0x5}, {0x1400030de60, 0x1d}, {0x14000110b00, 0x3, 0x4?})
	/Users/moul/go/src/github.com/gnolang/gno/gnovm/tests/file.go:245 +0x218
command-line-arguments.runFileTest(0x140002fa000, {0x1400030de60, 0x1d}, {0x140001266c8, 0x1, 0x10282c098?})
	/Users/moul/go/src/github.com/gnolang/gno/gnovm/tests/file_test.go:140 +0x1c8
command-line-arguments.runFileTests.func1(0x140002fa000?)
	/Users/moul/go/src/github.com/gnolang/gno/gnovm/tests/file_test.go:64 +0x38
testing.tRunner(0x140002fa000, 0x1400062d398)
	/Users/moul/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.4.darwin-arm64/src/testing/testing.go:1689 +0xec
created by testing.(*T).Run in goroutine 22
	/Users/moul/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.4.darwin-arm64/src/testing/testing.go:1742 +0x318
--- FAIL: TestFiles (0.53s)
    --- FAIL: TestFiles/zrealm_crossrealm15.gno (0.51s)
panic: fail on files/zrealm_crossrealm15.gno: got unexpected error: new escaped mark has no object ID [recovered]
	panic: fail on files/zrealm_crossrealm15.gno: got unexpected error: new escaped mark has no object ID

goroutine 7 [running]:
testing.tRunner.func1.2({0x102f08840, 0x1400052dd40})
	/Users/moul/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.4.darwin-arm64/src/testing/testing.go:1631 +0x1c4
testing.tRunner.func1()
	/Users/moul/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.4.darwin-arm64/src/testing/testing.go:1634 +0x33c
panic({0x102f08840?, 0x1400052dd40?})
	/Users/moul/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.4.darwin-arm64/src/runtime/panic.go:770 +0x124
command-line-arguments.RunFileTest({0x140002f6858, 0x5}, {0x1400030de60, 0x1d}, {0x14000110b00, 0x3, 0x4?})
	/Users/moul/go/src/github.com/gnolang/gno/gnovm/tests/file.go:318 +0xa3c
command-line-arguments.runFileTest(0x140002fa000, {0x1400030de60, 0x1d}, {0x140001266c8, 0x1, 0x10282c098?})
	/Users/moul/go/src/github.com/gnolang/gno/gnovm/tests/file_test.go:140 +0x1c8
command-line-arguments.runFileTests.func1(0x140002fa000?)
	/Users/moul/go/src/github.com/gnolang/gno/gnovm/tests/file_test.go:64 +0x38
testing.tRunner(0x140002fa000, 0x1400062d398)
	/Users/moul/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.4.darwin-arm64/src/testing/testing.go:1689 +0xec
created by testing.(*T).Run in goroutine 22
	/Users/moul/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.4.darwin-arm64/src/testing/testing.go:1742 +0x318
FAIL	command-line-arguments	0.784s
FAIL

@moul moul self-assigned this Jul 6, 2024
@github-actions github-actions bot added 🧾 package/realm Tag used for new Realms or Packages. 📦 🤖 gnovm Issues or PRs gnovm related labels Jul 6, 2024
@moul moul added the 🐞 bug Something isn't working label Jul 6, 2024
moul added 4 commits July 6, 2024 09:37
Signed-off-by: moul <94029+moul@users.noreply.github.com>
Signed-off-by: moul <94029+moul@users.noreply.github.com>
@deelawn
Copy link
Contributor

deelawn commented Jul 6, 2024

I don't think this is a bug and I believe the behavior was introduced by #2255; this PR also had the side of fixing #974. Here is why I don't think this is a bug:

func init() {
	f = &fooer{}
	crossrealm.SetFooer(f)
	crossrealm.CallFoo()
}

The init function imports crossrealm and passes in a pointer to the SetFooer method. At this point, during initialization, f has not yet been persisted to the realm it is defined in.

var fooer Fooer

func SetFooer(f Fooer) { fooer = f }

The above code in the crossrealm package attempts to persist this value to its own realm before it has been persisted in the realm it which it originated. Were this not to fail, crossrealm would be the owner of the object -- not a desirable outcome.

That being said, perhaps we should amend the error message for this failure case to make it clearer as to why it is failing. Maybe even put something in our docs to explain this and link to it from the error message.

Copy link

codecov bot commented Jul 7, 2024

Codecov Report

Attention: Patch coverage is 68.60465% with 27 lines in your changes missing coverage. Please review.

Project coverage is 54.91%. Comparing base (b1d778c) to head (91134ca).
Report is 6 commits behind head on master.

Files Patch % Lines
gnovm/pkg/gnolang/realm.go 35.29% 9 Missing and 2 partials ⚠️
gno.land/pkg/gnoland/vals.go 43.75% 6 Missing and 3 partials ⚠️
gnovm/pkg/gnolang/machine.go 68.42% 3 Missing and 3 partials ⚠️
gnovm/stdlibs/std/emit_event.go 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2526      +/-   ##
==========================================
+ Coverage   54.88%   54.91%   +0.03%     
==========================================
  Files         592      594       +2     
  Lines       79232    79310      +78     
==========================================
+ Hits        43487    43556      +69     
+ Misses      32460    32451       -9     
- Partials     3285     3303      +18     
Flag Coverage Δ
contribs/gnodev 23.15% <100.00%> (ø)
contribs/gnofaucet 14.46% <ø> (ø)
contribs/gnokeykc 0.00% <ø> (ø)
contribs/gnomd 0.00% <ø> (ø)
gnovm 60.21% <66.03%> (+<0.01%) ⬆️

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.

@moul moul mentioned this pull request Jul 7, 2024
moul added 3 commits July 7, 2024 13:49
Signed-off-by: moul <94029+moul@users.noreply.github.com>
Signed-off-by: moul <94029+moul@users.noreply.github.com>
Signed-off-by: moul <94029+moul@users.noreply.github.com>
@moul moul marked this pull request as ready for review July 7, 2024 21:08
@moul moul requested review from thehowl and jaekwon as code owners July 7, 2024 21:08
@moul moul requested review from piux2, deelawn, mvertes and a team as code owners July 7, 2024 21:08
moul and others added 8 commits July 7, 2024 16:16
Signed-off-by: moul <94029+moul@users.noreply.github.com>
Signed-off-by: moul <94029+moul@users.noreply.github.com>
This reverts commit 4ca57af.
Signed-off-by: moul <94029+moul@users.noreply.github.com>
Signed-off-by: moul <94029+moul@users.noreply.github.com>
@moul moul added the don't merge Please don't merge this functionality temporarily label Jul 8, 2024
@ajnavarro
Copy link
Contributor

@moul Is this still relevant?

@moul
Copy link
Member Author

moul commented Aug 21, 2024

It is, but is also on hold; Related with #2535

Signed-off-by: moul <94029+moul@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working don't merge Please don't merge this functionality temporarily 📦 🤖 gnovm Issues or PRs gnovm related 🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: No status
Status: 🙏🏻 To Delegate
Status: Agenda
Status: In Review
Development

Successfully merging this pull request may close these issues.

4 participants