close
Skip to content

Commit 81dd7b5

Browse files
gleocadiezacharycmontoya
authored andcommitted
[Profiler] Investigating timer_create failure on arm64/alpine (#8744)
1 parent 161b809 commit 81dd7b5

1 file changed

Lines changed: 51 additions & 1 deletion

File tree

‎profiler/src/ProfilerEngine/Datadog.Profiler.Native.Linux/TimerCreateCpuProfiler.cpp‎

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@
1616
#endif
1717

1818
#include <sys/syscall.h> /* Definition of SYS_* constants */
19+
#include <sys/resource.h>
1920
#include <sys/types.h>
21+
#include <sys/utsname.h>
2022
#include <ucontext.h>
2123
#include <unistd.h>
2224

25+
#include <fstream>
26+
#include <string>
27+
2328
std::atomic<TimerCreateCpuProfiler*> TimerCreateCpuProfiler::Instance = nullptr;
2429

2530
TimerCreateCpuProfiler::TimerCreateCpuProfiler(
@@ -75,6 +80,32 @@ const char* TimerCreateCpuProfiler::GetName()
7580

7681
bool TimerCreateCpuProfiler::StartImpl()
7782
{
83+
// Dump environment info to help diagnose timer_create failures
84+
{
85+
struct utsname uts;
86+
if (uname(&uts) == 0)
87+
{
88+
Log::Info("Kernel: ", uts.sysname, " ", uts.release, " ", uts.machine);
89+
}
90+
91+
struct rlimit rl;
92+
if (getrlimit(RLIMIT_SIGPENDING, &rl) == 0)
93+
{
94+
Log::Info("RLIMIT_SIGPENDING: soft=", rl.rlim_cur, " hard=", rl.rlim_max);
95+
}
96+
97+
std::ifstream status("/proc/self/status");
98+
std::string line;
99+
while (std::getline(status, line))
100+
{
101+
if (line.rfind("SigQ:", 0) == 0)
102+
{
103+
Log::Info("Signal queue at startup: ", line);
104+
break;
105+
}
106+
}
107+
}
108+
78109
if (_pSignalManager == nullptr)
79110
{
80111
Log::Info("Profiler Signal manager was not correctly initialized (see previous messages).",
@@ -319,7 +350,26 @@ void TimerCreateCpuProfiler::RegisterThreadImpl(ManagedThreadInfo* threadInfo)
319350
clockid_t clock = ((~tid) << 3) | 6; // CPUCLOCK_SCHED | CPUCLOCK_PERTHREAD_MASK thread_cpu_clock(tid);
320351
if (syscall(__NR_timer_create, clock, &sev, &timerId) < 0)
321352
{
322-
Log::Error("Call to timer_create failed for thread ", tid, ". Error: ", strerror(errno));
353+
auto err = errno;
354+
Log::Error("Call to timer_create failed for thread ", tid,
355+
". errno=", err, " (", strerror(err), ")");
356+
357+
struct rlimit rl;
358+
if (getrlimit(RLIMIT_SIGPENDING, &rl) == 0)
359+
{
360+
Log::Error("RLIMIT_SIGPENDING: soft=", rl.rlim_cur, " hard=", rl.rlim_max);
361+
}
362+
363+
std::ifstream status("/proc/self/status");
364+
std::string line;
365+
while (std::getline(status, line))
366+
{
367+
if (line.rfind("SigQ:", 0) == 0)
368+
{
369+
Log::Error("Signal queue: ", line);
370+
break;
371+
}
372+
}
323373
return;
324374
}
325375

0 commit comments

Comments
 (0)