]> sourceware.org Git - systemtap.git/commitdiff
Graceful continuation when not enough memory available for liveness analysis
authorWilliam Cohen <wcohen@redhat.com>
Tue, 18 Jan 2022 03:02:44 +0000 (22:02 -0500)
committerFrank Ch. Eigler <fche@redhat.com>
Tue, 18 Jan 2022 16:43:12 +0000 (11:43 -0500)
The dyninst parsing of binaries can take a significant amount of
memory.  On machines without enough memory to parse a large binary we
want the analysis to fail gracefully with a warning that the liveness
analysis was unable to run and continue on rather than immediately
exiting with a std::bad_alloc exception.

analysis.cxx

index 813e48699281d67fa8d1afd161f522775d61a2bb..359e59d6de6c462d4bafe64eec41ff0c011fae52 100644 (file)
@@ -230,6 +230,9 @@ int liveness(systemtap_session& s,
             Dwarf_Addr addr,
             location_context ctx)
 {
+  try{
+       // Doing this inside a try/catch because dyninst may require
+       // too much memory to parse the binary.
        // should cache the executable names like the other things
        analysis func_to_analyze(executable);
        MachRegister r;
@@ -297,6 +300,11 @@ int liveness(systemtap_session& s,
        bool used;
        la->query(iloc, LivenessAnalyzer::Before, r, used);
        return (used ? 1 : -1);
+  } catch (std::bad_alloc & ex){
+    s.print_warning(_F("unable to allocate memory for liveness analysis of %s",
+                                  executable.c_str()), e->tok);
+    return 0;
+  }
 }
 
 #endif // HAVE_DYNINST
This page took 0.026142 seconds and 5 git commands to generate.