Problem
When instrumenting code with custom types in make() or new() calls, type names were incorrectly treated as variable reads.
Example:
methods := make([]*SexpFunction, 0)
Generated broken code:
RaceRead(uintptr(unsafe.Pointer(SexpFunction))) // ERROR: SexpFunction is a TYPE!
methods := make([]*SexpFunction, 0)
This caused compilation error:
SexpFunction (type) is not an expression
Root Cause
extractReads() was walking into type expressions (ArrayType, MapType, etc.) and finding identifiers that looked like variables but were actually type names.
Fix
-
Added case to skip type expression AST nodes:
*ast.ArrayType
*ast.MapType
*ast.ChanType
*ast.StructType
*ast.InterfaceType
*ast.FuncType
*ast.Ellipsis
-
Special handling for make/new - skip first argument (always a type)
Found While
Testing on zygomys project which uses many custom types with make().
Problem
When instrumenting code with custom types in
make()ornew()calls, type names were incorrectly treated as variable reads.Example:
Generated broken code:
This caused compilation error:
Root Cause
extractReads()was walking into type expressions (ArrayType,MapType, etc.) and finding identifiers that looked like variables but were actually type names.Fix
Added case to skip type expression AST nodes:
*ast.ArrayType*ast.MapType*ast.ChanType*ast.StructType*ast.InterfaceType*ast.FuncType*ast.EllipsisSpecial handling for
make/new- skip first argument (always a type)Found While
Testing on zygomys project which uses many custom types with
make().