You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
People are trying to build stuff that uses modernc.org/memory package. There is one assumption made by this package- it requires a size of 8 for sync.Mutex.
The current implementation of sync.Mutex is based on the task.Mutex which is composed of a bool and a Stack (pointer). This gives the Mutex a size of 16 bytes on 64-bit aligned systems while in upstream Go it is 8 bytes.
To be honest, this is a bug in modernc.org/memory, not in TinyGo. They have written non-portable code. If they want to extend portability to TinyGo they could use a build tag. But it's also possible we're going to break this at some point - for example, -scheduler=threads and -scheduler=tasks may have a different sync.Mutex size.
I don't think there's anything to fix on our side.
As it happens, #4559 will make sync.Mutex 8 bytes on a 64-bit system on Linux. It's still no guarantee, but for those looking for a bit more compatibility that PR happens to provide it as a side effect.
@soypat
In the commit for libc_issues#43, the allocated memory has been expanded in an attempt to make it compatible with the current tinygo's sync.Mutex. If it works, then this issue seems to have been resolved.
However, after fixing this issue, a new problem has emerged:
i64 add (i64 ptrtoint (ptr @"modernc.org/libc._table" to i64), i64 256)
People are trying to build stuff that uses modernc.org/memory package. There is one assumption made by this package- it requires a size of 8 for sync.Mutex.
The current implementation of sync.Mutex is based on the task.Mutex which is composed of a bool and a Stack (pointer). This gives the Mutex a size of 16 bytes on 64-bit aligned systems while in upstream Go it is 8 bytes.
TinyGo data structures
Go data structures
The text was updated successfully, but these errors were encountered: