Skip to content

Commit b31bd6d

Browse files
committed
[tsan] Reduce MapRodata frame size
arch64 triggers -Wframe-larger-than=530.
1 parent 81a3828 commit b31bd6d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void WriteMemoryProfile(char *buf, uptr buf_size, u64 uptime_ns) {
152152
#if !SANITIZER_GO
153153
// Mark shadow for .rodata sections with the special Shadow::kRodata marker.
154154
// Accesses to .rodata can't race, so this saves time, memory and trace space.
155-
static void MapRodata() {
155+
static NOINLINE void MapRodata(char* buffer, uptr size) {
156156
// First create temp file.
157157
const char *tmpdir = GetEnv("TMPDIR");
158158
if (tmpdir == 0)
@@ -163,13 +163,12 @@ static void MapRodata() {
163163
#endif
164164
if (tmpdir == 0)
165165
return;
166-
char name[256];
167-
internal_snprintf(name, sizeof(name), "%s/tsan.rodata.%d",
166+
internal_snprintf(buffer, size, "%s/tsan.rodata.%d",
168167
tmpdir, (int)internal_getpid());
169-
uptr openrv = internal_open(name, O_RDWR | O_CREAT | O_EXCL, 0600);
168+
uptr openrv = internal_open(buffer, O_RDWR | O_CREAT | O_EXCL, 0600);
170169
if (internal_iserror(openrv))
171170
return;
172-
internal_unlink(name); // Unlink it now, so that we can reuse the buffer.
171+
internal_unlink(buffer); // Unlink it now, so that we can reuse the buffer.
173172
fd_t fd = openrv;
174173
// Fill the file with Shadow::kRodata.
175174
const uptr kMarkerSize = 512 * 1024 / sizeof(RawShadow);
@@ -188,8 +187,8 @@ static void MapRodata() {
188187
}
189188
// Map the file into shadow of .rodata sections.
190189
MemoryMappingLayout proc_maps(/*cache_enabled*/true);
191-
// Reusing the buffer 'name'.
192-
MemoryMappedSegment segment(name, ARRAY_SIZE(name));
190+
// Reusing the buffer 'buffer'.
191+
MemoryMappedSegment segment(buffer, size);
193192
while (proc_maps.Next(&segment)) {
194193
if (segment.filename[0] != 0 && segment.filename[0] != '[' &&
195194
segment.IsReadable() && segment.IsExecutable() &&
@@ -209,7 +208,8 @@ static void MapRodata() {
209208
}
210209

211210
void InitializeShadowMemoryPlatform() {
212-
MapRodata();
211+
char buffer[256]; // Keep in a different frame.
212+
MapRodata(buffer, ARRAY_SIZE(buffer));
213213
}
214214

215215
#endif // #if !SANITIZER_GO

0 commit comments

Comments
 (0)