Page MenuHomePhabricator

[Tsan] Fix the global_race tests to pass on FreeBSD
ClosedPublic

Authored by kutuzov.viktor.84 on Oct 8 2014, 5:18 AM.

Details

Summary

On FreeBSD the libc's %p conversion specifier outputs the pointer value in 0x%x format, that is, without any leading zeros. In contrast, on Linux that specifier works as 0x%012x what matches the RTL's implementation of formatted output:

static int AppendPointer(char **buff, const char *buff_end, u64 ptr_value) {
  int result = 0;
  result += AppendString(buff, buff_end, -1, "0x");
  result += AppendUnsigned(buff, buff_end, ptr_value, 16,
                           (SANITIZER_WORDSIZE == 64) ? 12 : 8, true);
  return result;
}

As soon as Tsan relies on that code for generating diagnostic messages, it looks the test cases should generate pointer values in this specific format as well and should not assume it matches to what %p would produce.

Diff Detail

Repository
rL LLVM

Event Timeline

kutuzov.viktor.84 retitled this revision from to [Tsan] Fix the global_race tests to pass on FreeBSD.
kutuzov.viktor.84 updated this object.
kutuzov.viktor.84 edited the test plan for this revision. (Show Details)
kutuzov.viktor.84 added reviewers: kcc, samsonov, glider.
kutuzov.viktor.84 added subscribers: Unknown Object (MLST), emaste.
glider accepted this revision.Oct 8 2014, 5:35 AM
glider edited edge metadata.

Can you please add comment to each test about why %p doesn't work?
LGTM otherwise.

This revision is now accepted and ready to land.Oct 8 2014, 5:35 AM
Diffusion closed this revision.Oct 9 2014, 2:45 AM
Diffusion updated this revision to Diff 14639.

Closed by commit rL219398 (authored by vkutuzov).