NEW 129173
getPlatformThreadRegisters() returns the wrong size on the pthread port
https://bugs.webkit.org/show_bug.cgi?id=129173
Summary getPlatformThreadRegisters() returns the wrong size on the pthread port
Mark Lam
Reported 2014-02-21 15:03:57 PST
In heap/MachineStackMarker.cpp, getPlatformThreadRegisters() is supposed to return the size of PlatformThreadRegisters. This is because MachineThreads::gatherFromOtherThread() expects to scan the thread registers by scanning from &regs to &regs + regSize where regSize is the value returned by getPlatformThreadRegisters(). Currently, the pthread port's getPlatformThreadRegisters() returns 0. That means the pthread port is not scanning the thread registers and may result in GC not retaining some live objects. One possible fix is to have getPlatformThreadRegisters() return sizeof(regs). This will only work if pthread_attr_t (which is how the pthread port implements PlatformThreadRegisters) is a struct that will hold the register values that the GC needs to scan. However, the spec says "The pthread_attr_t type should be treated as opaque: any access to the object other than via pthreads functions is nonportable and produces undefined results." If pthread_attr_t is implemented as a handle / pointer to some buffer that contains the register values, then there's a bigger problem i.e. MachineThreads::gatherFromOtherThread() 's scan will be ineffective based on the current pthread implementation of PlatformThreadRegisters. The proper fix will require copying the thread register values to a port defined PlatformThreadRegisters struct that MachineThreads::gatherFromOtherThread() can scan instead of assuming that pthread_attr_t is that struct. This bug will affect any ports that uses pthread i.e. gtk, elf, but only if they invoke JSC from more than one thread (after acquiring the VM JSLock, of course).
Attachments
Note You need to log in before you can comment on or make changes to this bug.