df-mc / structure

Structure parsing and writing library for Dragonfly
4 stars 0 forks source link

Cannot get block from structure #3

Open Flonja opened 1 year ago

Flonja commented 1 year ago

After updating from v1.0.4 (df-structure) and v0.8.10 (df-mc/dragonfly) my structure couldn't build anymore. I used some code to debug my problem first and found out that it errors out at b:

// s.island is a `structure.Structure`
b, l := s.island.At(x, y, z, nil)
fmt.Printf("(%v %v %v)", x, y, z)
fmt.Printf("%T %T\n", b, l)

Stacktrace:

(5 8 6)runtime: nameOff 0xff304c1 base 0x464880 not in ranges:
        types 0x92c000 etypes 0xb88c38
fatal error: runtime: name offset base pointer out of range

goroutine 84 [running]:
runtime.throw({0xa7e579?, 0xc000196270?})
        /home/flonja/sdk/go1.20.1/src/runtime/panic.go:1047 +0x5d fp=0xc0014d77c0 sp=0xc0014d7790 pc=0x435d9d
runtime.resolveNameOff(0xc0014d7888?, 0xff304c1)
        /home/flonja/sdk/go1.20.1/src/runtime/type.go:221 +0x1d6 fp=0xc0014d7818 sp=0xc0014d77c0 pc=0x45d436
reflect.resolveNameOff(0xa6caaf?, 0x2ea8a0?)
        /home/flonja/sdk/go1.20.1/src/runtime/runtime1.go:512 +0x19 fp=0xc0014d7838 sp=0xc0014d7818 pc=0x463ad9
reflect.(*rtype).nameOff(...)
        /home/flonja/sdk/go1.20.1/src/reflect/type.go:729
reflect.(*rtype).String(0x464880)
        /home/flonja/sdk/go1.20.1/src/reflect/type.go:799 +0x25 fp=0xc0014d7858 sp=0xc0014d7838 pc=0x4a1525
fmt.(*pp).printArg(0xc00015e000, {0x464880?, 0x0?}, 0x200?)
        /home/flonja/sdk/go1.20.1/src/fmt/print.go:699 +0xe2 fp=0xc0014d78f8 sp=0xc0014d7858 pc=0x4c9a82
fmt.(*pp).doPrintf(0xc00015e000, {0xa640be, 0x6}, {0xc0014d7b88?, 0x2, 0x2})
        /home/flonja/sdk/go1.20.1/src/fmt/print.go:1176 +0x9a9 fp=0xc0014d79f0 sp=0xc0014d78f8 pc=0x4cd1a9
fmt.Fprintf({0xb5baa0, 0xc0001aa008}, {0xa640be, 0x6}, {0xc0014d7b88, 0x2, 0x2})
        /home/flonja/sdk/go1.20.1/src/fmt/print.go:224 +0x75 fp=0xc0014d7a50 sp=0xc0014d79f0 pc=0x4c6c75
fmt.Printf(...)
        /home/flonja/sdk/go1.20.1/src/fmt/print.go:233
generator/generators.Skywars.GenerateChunk({0xc0000484e0, 0x15, {0x1261860, 0x4, 0x4}, {0xc001460200}, {0xc001460300}, {0xc001460400}, {0xc001460500}}, {0x0, ...}, ...)
        /home/flonja/Desktop/Projects/Golang/Personal/generator/generators/skywars.go:120 +0x42e fp=0xc0014d7c10 sp=0xc0014d7a50 pc=0x8e174e
generator/generators.(*Skywars).GenerateChunk(0xc0011f3e90?, {0x0, 0x4}, 0x400000000?)
        <autogenerated>:1 +0xc5 fp=0xc0014d7cc0 sp=0xc0014d7c10 pc=0x8e1e85
github.com/df-mc/dragonfly/server/world.(*World).loadChunk(0xc001464a80, {0x0, 0x4})
        /home/flonja/go/pkg/mod/github.com/df-mc/dragonfly@v0.9.6/server/world/world.go:1248 +0x249 fp=0xc0014d7d78 sp=0xc0014d7cc0 pc=0x604c09
github.com/df-mc/dragonfly/server/world.(*World).chunk(0xc001464a80, {0x0, 0x4})
        /home/flonja/go/pkg/mod/github.com/df-mc/dragonfly@v0.9.6/server/world/world.go:1179 +0x129 fp=0xc0014d7e38 sp=0xc0014d7d78 pc=0x6046c9
github.com/df-mc/dragonfly/server/world.(*Loader).Load(0xc0011e3110, 0x4)
        /home/flonja/go/pkg/mod/github.com/df-mc/dragonfly@v0.9.6/server/world/loader.go:92 +0xe7 fp=0xc0014d7ea8 sp=0xc0014d7e38 pc=0x5f7387
github.com/df-mc/dragonfly/server/session.(*Session).sendChunks(0xc001462600)
        /home/flonja/go/pkg/mod/github.com/df-mc/dragonfly@v0.9.6/server/session/session.go:377 +0x1a9 fp=0xc0014d7f08 sp=0xc0014d7ea8 pc=0x8b3249
github.com/df-mc/dragonfly/server/session.(*Session).background(0xc001462600)
        /home/flonja/go/pkg/mod/github.com/df-mc/dragonfly@v0.9.6/server/session/session.go:336 +0x13b fp=0xc0014d7fc8 sp=0xc0014d7f08 pc=0x8b2efb
github.com/df-mc/dragonfly/server/session.(*Session).handlePackets.func2()
        /home/flonja/go/pkg/mod/github.com/df-mc/dragonfly@v0.9.6/server/session/session.go:295 +0x26 fp=0xc0014d7fe0 sp=0xc0014d7fc8 pc=0x8b2d86
runtime.goexit()
        /home/flonja/sdk/go1.20.1/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc0014d7fe8 sp=0xc0014d7fe0 pc=0x467841
created by github.com/df-mc/dragonfly/server/session.(*Session).handlePackets
        /home/flonja/go/pkg/mod/github.com/df-mc/dragonfly@v0.9.6/server/session/session.go:295 +0x8a

Other run with fmt.Printf("%T %T\n", b, l) split into to fmt.Printf calls:

(6 4 9)block.Stone
<nil>
(6 5 9)block.Stone
<nil>
(6 6 9)block.Stone
<nil>
(6 7 9)runtime: nameOff 0xff304c1 base 0x464880 not in ranges:
        types 0x92c000 etypes 0xb88c58

When running this code in v1.0.4 it got the block successfully:

b, l := island.At(6, 7, 9, nil)
fmt.Printf("%T %T\n", b, l)

// block.Stone <nil>
Flonja commented 1 year ago

I would like the keep the structure file private. If a contributor needs it, then please dm me on discord (tag: flonja)

yousifnimah commented 1 year ago

This error typically occurs when there is a mismatch between the versions of different packages or dependencies.

Double-check that all your dependencies, including df-structure and df-mc/dragonfly, are compatible with each other. Also, If you are using a package manager for your project, such as Go Modules (go.mod file), verify that all your dependencies and their versions are correctly listed. Use the package manager to update or retrieve the correct versions of the packages you need.

Sandertv commented 1 year ago

Hmmmm I seem unable to reproduce using Go version 1.20.5 and dragonfly v0.9.4. Maybe it's dependent on the OS? What os+arch are you using?

yousifnimah commented 1 year ago

I use Go version go1.18.4 darwin/amd64.

Sandertv commented 1 year ago

Are you also experiencing this issue?

yousifnimah commented 1 year ago

Actually, I don't have a structure file so I couldn't run it. I got:

panic: open file: open example.mcstructure: no such file or directory
undefined: world.BlockPos
Flonja commented 1 year ago

Hmmmm I seem unable to reproduce using Go version 1.20.5 and dragonfly v0.9.4. Maybe it's dependent on the OS? What os+arch are you using?

OS: Pop!_OS 22.04 LTS x86_64 Kernel: 6.2.6-76060206-generic Golang: version go1.20.1 linux/amd64

Flonja commented 1 year ago

bump

Flonja commented 1 year ago

bump