-
Notifications
You must be signed in to change notification settings - Fork 96
Runtime tests fall over when run with address sanitizer #87
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
Comments
Here are fixed versions of the functions using func withClassValuePointer<Value, Result>(
of value: inout Value,
_ body: (UnsafeMutableRawPointer) throws -> Result) throws -> Result {
return try withUnsafePointer(to: &value) {
return try $0.withMemoryRebound(to: UnsafeMutableRawPointer.self, capacity: 1) {
try body($0.pointee)
}
}
}
func withExistentialValuePointer<Value, Result>(
of value: inout Value,
_ body: (UnsafeMutableRawPointer) throws -> Result) throws -> Result {
return try withUnsafePointer(to: &value) { ptr in
try ptr.withMemoryRebound(to: ExistentialContainer.self, capacity: 1) {
let container = $0.pointee
let info = try metadata(of: container.type)
if info.kind == .class || info.size > ExistentialContainerBuffer.size() {
return try ptr.withMemoryRebound(to: UnsafeMutableRawPointer.self, capacity: 1) {
let base = $0.pointee
if info.kind == .struct {
return try body(base.advanced(by: existentialHeaderSize))
} else {
return try body(base)
}
}
} else {
return try body($0.mutable.raw)
}
}
}
} |
Ah good catch. Yea I originally started doing that in a couple places when reading the metadata, and those addresses would always be static so it wasn't too much of an issue. Obviously got to use to it and it should not be done here 😅. But Id be happy to merge a PR that fixes it! |
If you run
You get the following error
Looks like this is because you are assuming you can use the
pointee
value outside of awithMemoryRebound
. Although if I fix this the address sanitizer just fails elsewhere.On Linux both thread and address sanitizers fail
The text was updated successfully, but these errors were encountered: