Comments (5)
this changes in code of file register.go makes my program able to start and work normal
func regItab(symPtr map[string]uintptr, name string, addr uintptr) {
symPtr[name] = addr
bss := strings.Split(strings.TrimLeft(name, ITAB_PREFIX), ",")
slice := sliceHeader{addr, len(bss), len(bss)}
ptrs := *(*[]unsafe.Pointer)(unsafe.Pointer(&slice))
for i, ptr := range ptrs {
tname := bss[len(bss)-i-1]
if tname[0] == '*' {
obj := reflect.TypeOf(0)
(*emptyInterface)(unsafe.Pointer(&obj)).word = ptr
prefix := TYPE_PREFIX + tname[1:]
//obj = obj.(reflect.Type).Elem()
//symPtr[prefix] = uintptr((*emptyInterface)(unsafe.Pointer(&obj)).word)
if symPtr[prefix] != 0 {
obj = obj.(reflect.Type).Elem()
symPtr[prefix] = uintptr((*emptyInterface)(unsafe.Pointer(&obj)).word)
}
}
symPtr[TYPE_PREFIX+tname] = uintptr(ptr)
}
}
from goloader.
@lekting
could you give me test.o go file, and base package, i can't reappear this case with now information.
in addition, with your golang version, os version
from goloader.
@pkujhd
Yeah sure, go version:
go version go1.14.4 windows/amd64
Update: i have found place with error. My struct TCPServer have a pointer to the another struct World where there is a function that uses library go-mc:
https://github.com/Tnze/go-mc/blob/master/nbt/nbt.go#L36
function new() gives an error, also this happens when i'm using hashing (adler32)
https://github.com/golang/go/blob/master/src/hash/adler32/adler32.go#L44
test.go
func mainb(server *base.TestTCPServer) {
fmt.Println("here")
fmt.Println(server.Protocol)
}
func main() {
//Empty because needed in main package
}
main.go
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
//packets.InitPackets()
server := &base.TestTCPServer{Port: "25565", Protocol: "tcp"}
symPtr := make(map[string]uintptr)
err := goloader.RegSymbol(symPtr)
if err != nil {
fmt.Println(err)
return
}
goloader.RegTypes(symPtr, time.Duration(0), time.Unix(0, 0))
goloader.RegTypes(symPtr, runtime.LockOSThread)
//goloader.RegTypes(symPtr, server)
reloc, err := goloader.ReadObjs([]string{"../plugins/test.o"}, []string{""})
if err != nil {
fmt.Println(err)
return
}
symPtr["os.Stdout"] = uintptr(unsafe.Pointer(&os.Stdout))
codeModule, err := goloader.Load(reloc, symPtr)
if err != nil {
fmt.Println("Load error:", err)
return
}
runFuncPtr := codeModule.Syms["main.mainb"]
if runFuncPtr == 0 {
fmt.Println("Load error! not find function:", "main.mainb")
return
}
funcPtrContainer := (uintptr)(unsafe.Pointer(&runFuncPtr))
runFunc := *(*func(server *base.TestTCPServer))(unsafe.Pointer(&funcPtrContainer))
runFunc(server)
os.Stdout.Sync()
codeModule.Unload()
}
TCPServer
package base
import (
"brewellcore/server/world"
"fmt"
"net"
)
// TCPServer struct
type TestTCPServer struct {
Protocol string
Port string
Net net.Listener
World *world.Map
}
//var players []*UserConnection
func (server *TestTCPServer) Run() {
server.Net, _ = net.Listen(server.Protocol, ":"+server.Port)
world.Generate(server.World)
fmt.Println("[Server|Generator] World loaded")
for {
_, _ = server.Net.Accept()
//go server.handleRequest(conn)
}
}
World
func Generate(world *Map) {
files, err := ioutil.ReadDir("testworld/region/")
if err != nil {
log.Fatal(err)
}
for _, file := range files {
r, err := region.Open("testworld/region/" + file.Name())
if err != nil {
fmt.Println(err)
return
}
defer r.Close()
for x := 0; x < 32; x++ {
for z := 0; z < 32; z++ {
data, err := r.ReadSector(region.In(x, z))
if err != nil {
continue
}
r, err := zlib.NewReader(bytes.NewReader(data[1:]))
if err != nil {
continue
}
nbt.NewDecoder(r) <<HERE ERROR
}
}
}
}
from goloader.
@lekting , means now you modify your code, previous error already disappeared?
i still do not reappear error with newer code in go 1.14.4 on windows/amd64.
from goloader.
@pkujhd , yeah, i'll modify my code to make its working, this error happens sometimes and i don't know why, I will study more problems and let you know if I find out something. Thanks for library
from goloader.
Related Issues (20)
- fatal error: unreachable method called. linker bug? HOT 19
- Mac M1 Load error: syscall.Mmap: permission denied HOT 6
- linker 是不是设计成main.xx导出方法 HOT 3
- 在运行的golang代码如果使用指针会报错 HOT 5
- macos Lstat使用报index out of range HOT 12
- Load error: symName:database/sql.(*DB).Close offset:139266851392960 is overflow! HOT 2
- 有一个想法 HOT 1
- Do I have to build the host program with `-w`? HOT 3
- support golang 1.20
- Can't get example to run using Go 1.20 HOT 3
- how to use it in other program HOT 1
- Load error: unresolve external:runtime.writeBarrier HOT 7
- 你好, 请问这个项目是怎么保持跟随 Go 最新版本的呢 HOT 13
- 实现 MarshalJSON 接口方法, 不会被执行 HOT 16
- Will panic soon when visit pprof web page HOT 7
- the handle of inline is incorrect HOT 11
- the usage of `copy2Slice` here seems to be incorrect, PutInt64 should be used instead HOT 30
- the `addfuncdata` rewrite `0` to `^uint32(0)`, but ignoring the case where 0 represents a normal offset value. HOT 5
- during module unloading, removing the itab can lead to runtime error HOT 1
- `getitab` alloc memory for `itab` by `persistentalloc`, and that couldnt be free HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from goloader.