pkujhd / goloader

load and run golang code at runtime.
Apache License 2.0
507 stars 59 forks source link

during module unloading, removing the itab can lead to runtime error #80

Closed fumeboy closed 1 year ago

fumeboy commented 1 year ago

https://github.com/golang/go/blob/ce8146ed3361f584ba79427ac6c6d6fe9c297bea/src/runtime/iface.go#L145

when the itabtable is expanding because if t.count >= 3*(t.size/4) { // 75% load factor, it checks the count of both the old and new tables. If they are inconsistent, it will throw an error.

If we happen to be unloading a module at this time, it is possible to make the count inconsistent.

fumeboy commented 1 year ago

oh, i miss the lock(itabLock) before removing itabs, this is not an issue