[llvm] r305056 - bugpoint: disabling symbolication of bugpoint-executed programs

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 11 18:23:02 PDT 2017


On Sun, Jun 11, 2017 at 6:15 PM Philip Reames <listmail at philipreames.com>
wrote:

> On 06/09/2017 12:29 AM, David Blaikie via llvm-commits wrote:
> > Author: dblaikie
> > Date: Fri Jun  9 02:29:03 2017
> > New Revision: 305056
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=305056&view=rev
> > Log:
> > bugpoint: disabling symbolication of bugpoint-executed programs
> >
> > Initial implementation - needs similar work/testing for other tools
> > bugpoint invokes (llc, lli I think, maybe more).
> >
> > Alternatively (as suggested by chandlerc@) an environment variable could
> > be used. This would allow the option to pass transparently through user
> > scripts, pass to compilers if they happened to be LLVM-ish, etc.
> >
> > I worry a bit about using cl::opt in the crash handling code - LLVM
> > might crash early, perhaps before the cl::opt is properly initialized?
> > Or at least before arguments have been parsed?
> >
> >   - should be OK since it defaults to "pretty", so if the crash is very
> >   early in opt parsing, etc, then crash reports will still be symbolized.
> >
> > I shyed away from doing this with an environment variable when I
> > realized that would require copying the existing environment and
> > appending the env variable of interest. But it seems there's no existing
> > LLVM API for accessing the environment (even the Support tests for
> > process launching have their own ifdefs for getting the environment). It
> > could be added, but seemed like a higher bar/untested codepath to
> > actually add environment variables.
> >
> > Most importantly, this reduces the runtime of test/BugPoint/metadata.ll
> > in a split-dwarf Debug build from 1m34s to 6.5s by avoiding a lot of
> > symbolication. (this wasn't a problem for non-split-dwarf builds only
> > because the executable was too large to map into memory (due to bugpoint
> > setting a 400MB memory (including address space - not sure why? Going to
> > remove that) limit on the child process) so symbolication would fail
> > fast & wouldn't spend all that time parsing DWARF, etc)
> The 400MB limit is probably to catch out of memory conditions in the
> sub-process.  (i.e. some bugs show up as huge bogus allocation attempts
> and we want to be able to reduce those too.)  It can probably be fine
> tuned, but having some limit is definitely useful.
>

Oh, sure - wasn't planning to remove the limit entirely, but to remove the
/address space/ limit, while keeping the resident memory limit. As you say,
it's probably quite reasonable for bugpoint to stop the child processes
from runaway memory allocation - but I'm not sure of any particular risk of
a child process just memory mapping a lot of files, as such.

- Dave


> >
> > Reviewers: chandlerc, dannyb
> >
> > Differential Revision: https://reviews.llvm.org/D33804
> >
> > Added:
> >      llvm/trunk/test/BugPoint/unsymbolized.ll
> > Modified:
> >      llvm/trunk/lib/Support/Signals.cpp
> >      llvm/trunk/tools/bugpoint/OptimizerDriver.cpp
> >
> > Modified: llvm/trunk/lib/Support/Signals.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Signals.cpp?rev=305056&r1=305055&r2=305056&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/Support/Signals.cpp (original)
> > +++ llvm/trunk/lib/Support/Signals.cpp Fri Jun  9 02:29:03 2017
> > @@ -26,15 +26,21 @@
> >   #include "llvm/Support/Program.h"
> >   #include "llvm/Support/StringSaver.h"
> >   #include "llvm/Support/raw_ostream.h"
> > +#include "llvm/Support/Options.h"
> >   #include <vector>
> >
> > -namespace llvm {
> > -
> >
>  //===----------------------------------------------------------------------===//
> >   //=== WARNING: Implementation here must contain only TRULY operating
> system
> >   //===          independent code.
> >
>  //===----------------------------------------------------------------------===//
> >
> > +using namespace llvm;
> > +
> > +static cl::opt<bool>
> > +    DisableSymbolication("disable-symbolication",
> > +                         cl::desc("Disable symbolizing crash
> backtraces."),
> > +                         cl::init(false), cl::Hidden);
> > +
> >   static ManagedStatic<std::vector<std::pair<void (*)(void *), void *>>>
> >       CallBacksToRun;
> >   void sys::RunSignalHandlers() {
> > @@ -44,9 +50,6 @@ void sys::RunSignalHandlers() {
> >       I.first(I.second);
> >     CallBacksToRun->clear();
> >   }
> > -}
> > -
> > -using namespace llvm;
> >
> >   static bool findModulesAndOffsets(void **StackTrace, int Depth,
> >                                     const char **Modules, intptr_t
> *Offsets,
> > @@ -70,6 +73,9 @@ static bool printSymbolizedStackTrace(St
> >   static bool printSymbolizedStackTrace(StringRef Argv0,
> >                                         void **StackTrace, int Depth,
> >                                         llvm::raw_ostream &OS) {
> > +  if (DisableSymbolication)
> > +    return false;
> > +
> >     // Don't recursively invoke the llvm-symbolizer binary.
> >     if (Argv0.find("llvm-symbolizer") != std::string::npos)
> >       return false;
> >
> > Added: llvm/trunk/test/BugPoint/unsymbolized.ll
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/BugPoint/unsymbolized.ll?rev=305056&view=auto
> >
> ==============================================================================
> > --- llvm/trunk/test/BugPoint/unsymbolized.ll (added)
> > +++ llvm/trunk/test/BugPoint/unsymbolized.ll Fri Jun  9 02:29:03 2017
> > @@ -0,0 +1,21 @@
> > +; REQUIRES: loadable_module
> > +; RUN: echo "import sys" > %t.py
> > +; RUN: echo "print('args = ' + str(sys.argv))" >> %t.py
> > +; RUN: echo "exit(1)" >> %t.py
> > +; RUN: not bugpoint -load %llvmshlibdir/BugpointPasses%shlibext %s
> -output-prefix %t -bugpoint-crashcalls -opt-command="%python" -opt-args
> %t.py | FileCheck %s
> > +; RUN: not --crash opt -load %llvmshlibdir/BugpointPasses%shlibext %s
> -bugpoint-crashcalls -disable-symbolication 2>&1 | FileCheck
> --check-prefix=CRASH %s
> > +
> > +; Test that bugpoint disables symbolication on the opt tool to reduce
> runtime overhead when opt crashes
> > +; CHECK: args = {{.*}}'-disable-symbolication'
> > +
> > +; Test that opt, when it crashes & is passed -disable-symbolication,
> doesn't symbolicate.
> > +; In theory this test should maybe be in test/tools/opt or
> > +; test/Transforms, but since there doesn't seem to be another
> convenient way to
> > +; crash opt, apart from the BugpointPasses dynamic plugin, this is the
> spot for
> > +; now.
> > +; CRASH-NOT: Signals.inc
> > +
> > +define void @f() {
> > +  call void @f()
> > +  ret void
> > +}
> >
> > Modified: llvm/trunk/tools/bugpoint/OptimizerDriver.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/OptimizerDriver.cpp?rev=305056&r1=305055&r2=305056&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/tools/bugpoint/OptimizerDriver.cpp (original)
> > +++ llvm/trunk/tools/bugpoint/OptimizerDriver.cpp Fri Jun  9 02:29:03
> 2017
> > @@ -202,10 +202,11 @@ bool BugDriver::runPasses(Module *Progra
> >     } else
> >       Args.push_back(tool.c_str());
> >
> > -  Args.push_back("-o");
> > -  Args.push_back(OutputFilename.c_str());
> >     for (unsigned i = 0, e = OptArgs.size(); i != e; ++i)
> >       Args.push_back(OptArgs[i].c_str());
> > +  Args.push_back("-disable-symbolication");
> > +  Args.push_back("-o");
> > +  Args.push_back(OutputFilename.c_str());
> >     std::vector<std::string> pass_args;
> >     for (unsigned i = 0, e = PluginLoader::getNumPlugins(); i != e; ++i)
> {
> >       pass_args.push_back(std::string("-load"));
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170612/1ab5b8af/attachment.html>


More information about the llvm-commits mailing list