Skip to content

Instantly share code, notes, and snippets.

@gnprice
Created November 19, 2012 04:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gnprice/4108905 to your computer and use it in GitHub Desktop.
Save gnprice/4108905 to your computer and use it in GitHub Desktop.
Patch to make MRI/Ruby safe for -pg
From 98fc9cd0b28921dc02ee4c366c96e4caeb7d8475 Mon Sep 17 00:00:00 2001
From: Greg Price <price@mit.edu>
Date: Wed, 31 Oct 2012 15:53:59 -0700
Subject: [PATCH] Suppress SIGPROF
We don't handle it well -- the exact reason is unclear, but threading
seems to trigger it -- so just squelch it.
Building with -pg is necessary for getting call-graph information with
e.g. the Linux 'perf' profiler. But -pg also causes the libc startup
routine to set a SIGPROF timer. That doesn't serve any purpose with a
modern profiler like 'perf'; it was used by 'gprof'.
---
main.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/main.c b/main.c
index f4d526a..a824afb 100644
--- a/main.c
+++ b/main.c
@@ -18,6 +18,7 @@
#ifdef RUBY_DEBUG_ENV
#include <stdlib.h>
#endif
+#include <sys/time.h>
int
main(int argc, char **argv)
@@ -29,6 +30,11 @@ main(int argc, char **argv)
setlocale(LC_CTYPE, "");
#endif
+ {
+ struct itimerval itimer = {{0, 0}, {0, 0}};
+ setitimer(ITIMER_PROF, &itimer, NULL);
+ }
+
ruby_sysinit(&argc, &argv);
{
RUBY_INIT_STACK;
--
1.7.11.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment