Fix threaded heap profile bug in pprof.

Fix ReadThreadedHeapProfile to pass the correct parameters to
AdjustSamples.
Fix prof_tdata_get()-related regressions.

Fix prof_tdata_get() to avoid dereferencing an invalid tdata pointer
(when it's PROF_TDATA_STATE_{REINCARNATED,PURGATORY}).

Fix prof_tdata_get() callers to check for invalid results besides NULL
(PROF_TDATA_STATE_{REINCARNATED,PURGATORY}).

These regressions were caused by
602c8e0971160e4b85b08b16cf8a2375aa24bc04 (Implement per thread heap
profiling.), which did not make it into any releases prior to these
fixes.
Fix a profile sampling race.

Fix a profile sampling race that was due to preparing to sample, yet
doing nothing to assure that the context remains valid until the stats
are updated.

These regressions were caused by
602c8e0971160e4b85b08b16cf8a2375aa24bc04 (Implement per thread heap
profiling.), which did not make it into any releases prior to these
fixes.