From b608bb8322085893877078d76e3e50f7d9918c5a Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Tue, 9 Jun 2009 21:41:40 -0400 Subject: build compatibility fix for gcc 3.4 * translate.cxx (emit_symbol_data): Use ~0 instead of -1 for big unsigned constant --- translate.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'translate.cxx') diff --git a/translate.cxx b/translate.cxx index 76530cc4..4e312f3e 100644 --- a/translate.cxx +++ b/translate.cxx @@ -4903,7 +4903,7 @@ emit_symbol_data (systemtap_session& s) ofstream kallsyms_out ((s.tmpdir + "/" + symfile).c_str()); - unwindsym_dump_context ctx = { s, kallsyms_out, 0, -1, s.unwindsym_modules }; + unwindsym_dump_context ctx = { s, kallsyms_out, 0, ~0, s.unwindsym_modules }; // Micro optimization, mainly to speed up tiny regression tests // using just begin probe. -- cgit From cc76db234897ff09eda098e786643506517b2175 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 10 Jun 2009 15:50:04 -0700 Subject: PR10260: Clean up all resources after init errors When anything in systemtap_module_init fails, and we return non-zero, then the module load is aborted. The normal module unload path (systemtap_module_exit) is not even attempted, so we need to make sure that all partially-allocated resources are returned. Our timer callbacks for the gettimeofday subsystem are a classic example of this error. If we don't unregister the timers before aborting init, they will later be called and cause a kernel fault. We also were neglecting to free the percpu context. A memory leak is less harmful, but that's fixed now too. --- translate.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'translate.cxx') diff --git a/translate.cxx b/translate.cxx index 4e312f3e..518e5584 100644 --- a/translate.cxx +++ b/translate.cxx @@ -1249,6 +1249,14 @@ c_unparser::emit_module_init () o->newline() << "synchronize_sched();"; o->newline() << "#endif"; + // In case gettimeofday was started, it needs to be stopped + o->newline() << "#ifdef STAP_NEED_GETTIMEOFDAY"; + o->newline() << " _stp_kill_time();"; // An error is no cause to hurry... + o->newline() << "#endif"; + + // Free up the context memory after an error too + o->newline() << "free_percpu (contexts);"; + o->newline() << "return rc;"; o->newline(-1) << "}\n"; } -- cgit