Search completed in 1.19 seconds.
13 results for "valgrind":
The Valgrind Test Job
The
Valgrind test job builds the browser and runs it under
Valgrind, which can detect various common memory-related errors. This job only runs on Linux64, which is the platform best suited to running
Valgrind. Running the
Valgrind test job locally
Valgrind works best on Linux. It also works on Mac, though sometimes not as well. Building You need a
Valgrind-enabled build of Firefox. Add the following lines to your mozconfig file. ac_add_options --enable-
valgrind ac_add_options --disable-jemalloc Running To run the
Valgrind test job locally, run the following command. mach
valgrind-test See also the general instructions for using
Valgrind with Mozilla code. ...
...ot as well. Building You need a
Valgrind-enabled build of Firefox. Add the following lines to your mozconfig file. ac_add_options --enable-
valgrind ac_add_options --disable-jemalloc Running To run the
Valgrind test job locally, run the following command. mach
valgrind-test See also the general instructions for using
Valgrind with Mozilla code. Understanding errors For each problem that
Valgrind finds, it emits a message describing the problem, along with a stack trace indicating where the problem occurs. It also prints a suppression, which is a sequence of text that can be put in a suppression file (and specified via
Valgrind's --suppressions option) if you want
Valgrind to ignore such errors in future runs. For example, we have a small number of deliberate but inconsequential memory ...
...rs should be fixed rather than suppressed. When running locally, you may see errors that do not occur on the test machines. Errors in system libraries can generally be ignored, because they are out of our control and the kind of thing we suppress on the test machines. Errors in Mozilla code should probably be reported in bugs! If you need help or experience problems If you need help with the
Valgrind test job, please contact Nicholas Nethercote or Gary Kwong. Julian Seward can also help with
Valgrind issues. Alternatively, bugs relating to the test job can be filed in the "Testing" product, under the "General" component. Please CC :njn and :gkw on any such bugs. ...
Hacking Tips
n <path>, set dot-bin <path>, set pngviewer-bin <path>) within gdb. Enabling GDB instrumentation may require launching a JS shell executable that shares a directory with a file name "js-gdb.py". If js/src/js does not provide the "iongraph" command, try js/src/shell/js. GDB may complain that ~/.gdbinit requires modification to authorize user scripts, and if so will print out directions. Break on
valgrind errors Sometimes, a bug can be reproduced under
valgrind but hardly under gdb. One way to investigate is to let
valgrind start gdb for you, the other way documented here is to let
valgrind act as a gdb server which can be manipulated from the gdb remote. $
valgrind --smc-check=all-non-file --vex-iropt-register-updates=allregs-at-mem-access --vgdb-error=0 ./js ... This command will tell you ho...
...ind start gdb for you, the other way documented here is to let
valgrind act as a gdb server which can be manipulated from the gdb remote. $
valgrind --smc-check=all-non-file --vex-iropt-register-updates=allregs-at-mem-access --vgdb-error=0 ./js ... This command will tell you how to start gdb as a remote. Be aware that functions which are usually dumping some output will do it in the shell where
valgrind is started and not in the shell where gdb is started. Thus functions such as js::DumpBacktrace, when called from gdb, will print their output in the shell containing
valgrind. Adding spew for Compilations & Bailouts & Invalidations (from gdb) If you are in rr, and forgot to record with the spew enabled with IONFLAGS or because this is an optimized build, then you can add similar spew with extra...
...ttps://github.com/haytjes/tracelogger/tree/master/tools_v2. You need to download "engine.js", "reduce.py", "reduce.js", "reduce-tree.js" and "reduce-corrections.js". Running this tool is a matter of running "python reduce.py JS_SHELL /tmp/tl-data.json tl-reduced". Where JS_SHELL is a real shell. Using callgrind (JS shell) As SpiderMonkey just-in-time compiler are rewriting the executed program,
valgrind should be informed from the command line by adding --smc-check=all-non-file. $
valgrind --tool=callgrind --callgrind-out-file=bench.clg \ --smc-check=all-non-file --vex-iropt-register-updates=allregs-at-mem-access ./js ./run.js The output file can then be use with kcachegrind which provides a graphical view of the call graph. Using IonMonkey spew (JS shell) IonMonkey spew is extremely v...
Leak-hunting strategies and tips
PCWrappedJS is a sign that there could be significant numbers of JS objects leaked.) For example, start with bringing up the mail window and closing the window without doing anything. Then go on to selecting a folder, then selecting a message, and then other activities one does while reading mail. Once you've done this, and it doesn't leak much, then try the action under trace-malloc or LSAN or
Valgrind to find the leaks of smaller graphs of objects. (When I refer to the size of a graph of objects, I'm referring to the number of objects, not the size in bytes. Leaking many copies of a string could be a very large leak, but the object graphs are small and easy to identify using GC-based leak detection.) What leak tools do we have? Tool Finds Platforms Requires Leak to...
...OUNT_{CTOR,DTOR} All tier 1 platforms Debug build (or build opt with --enable-logrefcnt) Leaksoup (part of TraceMalloc) All objects? (or allocations?) All tier 1 platforms Build with --enable-trace-malloc Leak tools for simple objects and summary statistics TraceMalloc All allocations All tier 1 platforms Build with --enable-trace-malloc
Valgrind All allocations Mac, Linux Build with --enable-
valgrind and some other options LSAN All allocations Mac, Linux Any build Apple tools ? Mac Any build Leak tools for debugging memory growth that is cleaned up on shutdown diffbloatdump (part of TraceMalloc) All allocations Linux only? Build with --enable-trace-malloc Com...
Performance
ing Refcount tracing and balancing are ways to track down leaks caused by incorrect uses of reference counting. They are slow and not particular easy to use, and thus most suitable for use by expert developers. GC and CC logs GC and CC logs can be generated and analyzed to in various ways. In particular, they can help you understand why a particular object is being kept alive.
Valgrind Valgrind is a tool that detects various memory-related problems at runtime, including leaks.
Valgrind is used as part of Mozilla's continuous integration testing, though the coverage is limited because
Valgrind is slow. LeakSanitizer LeakSanitizer (a.k.a. LSAN) is similar to
Valgrind, but it runs faster because it uses static source code instrumentation. LSAN is part of Mozilla's c...
...The "leaks" tool is not recommended for use with SpiderMonkey or Firefox, because it gets confused by tagged pointers and thinks objects have leaked when they have not (see bug 390944). ...
Secure Development Guidelines
n(int argc, char *argv[]) { if (argc > 1) printf(argv[1]); } Format String Bugs: Prevention Easy to fix: Always use a format string specifier: int main(int argc, char *argv[]) { if (argc > 1) printf("%s", argv[1]); } Double Free Example: void* ptr = malloc(1024); if (error) { free(ptr); } free(ptr); Double Free: Prevention Set a pointer to NULL when it's freed
Valgrind or malloc debugging can help detect those bugs Use After Free Accessing data after a free() or delete can lead to undefined behavior Some debug tools might be able catch some cases Un-initialized Data Example: int main() { char *uninitialized_ptr; printf("0x%08x\r\n", uninitialized_ptr); return 0; } $ ./test 0x8fe0103 Un-initialized Data: Prevention Initialize y...
...cases Un-initialized Data Example: int main() { char *uninitialized_ptr; printf("0x%08x\r\n", uninitialized_ptr); return 0; } $ ./test 0x8fe0103 Un-initialized Data: Prevention Initialize your variables! ...
Testing Mozilla code
Nightly Project involves building a Firefox Nightly browser with the popular AddressSanitizer tool and enhancing it with remote crash reporting capabilities for any errors detected.Clang static analysisThis document is split in two parts. The first part will focus on the modern and robust way of static-analysis and the second part will present the build-time static-analysis.Debugging Mozilla with
ValgrindThis page describes how to use
Valgrind (specifically, its Memcheck tool) to find memory errors.Firefox and Address SanitizerAddress Sanitizer (ASan) is a fast memory error detector that detects use-after-free and out-of-bound bugs in C/C++ programs. It uses a compile-time instrumentation to check all reads and writes during the execution. In addition, the runtime part replaces the malloc and free...
...coverage essentially is about measuring how often certain lines are hit, branches taken or conditions met in a program, given some test that you run on it. There are different types of coverage metrics (see also the Wikipedia entry), but when we speak of code coverage here, we usually mean line and branch coverage. This type of coverage is only concerned with hit counts for lines and branches.The
Valgrind Test JobThe
Valgrind test job builds the browser and runs it under
Valgrind, which can detect various common memory-related errors. This job only runs on Linux64, which is the platform best suited to running
Valgrind. ...
Continuous Integration
mpilation and some compiled-code tests (e.g., 'make check'). Be - B2G build jobs for engineering builds; user builds are denoted with B, the same as for desktop and Android builds. N and Ne - Nightly build jobs; these jobs are similar to B and Be jobs, but are triggered on a periodic basis instead of being triggered by a push to hg. Hf - Static rooting hazard analysis S - Static analysis V -
Valgrind build and test jobs; these jobs create
valgrind-compatible builds and run a small set of
valgrind tests on them. Builds that run in CI are clobber builds. Clobber builds mean the directory hierarchy, including the local source and object directory are deleted if it exists from a previous build. Functional Tests These jobs are scheduled after a build job has successfully produced a build. Th...
Debugging
lldb is the new debugger on Mac. Advanced debugging techniques Understanding crash reports How to read crash reports, which are full of information yet often not easy to interpret and act on. Debugging a minidump Windows crash reports include a minidump, which contains a lot of information about the application when it crashed. Debugging Mozilla with
valgrind Valgrind is a memory debugger for Mac and Linux. It is slow, but good for tracking down difficult memory safety bugs. Replay debugging Firefox with VMWare Workstation How to setup record and replay debugging on Firefox, to help debug intermittent mochitest failures. Detecting defects in Firefox with Coverity Coverity is a static analysis system that can detect defects in ...
NSS_3.12_release_notes.html
or_with_h1 allocates and leaks sha1cx Bug 341122: Coverity 633 SFTK_DestroySlotData uses slot->slotLock then checks it for NULL Bug 351140: Coverity 995, potential crash in ecgroup_fromNameAndHex Bug 362278: lib/util includes header files from other NSS directories Bug 228190: Remove unnecessary NSS_ENABLE_ECC defines from manifest.mn Bug 412906: remove sha.c and sha.h from lib/freebl Bug 353543:
valgrind uninitialized memory read in nssPKIObjectCollection_AddInstances Bug 377548: NSS QA test program certutil's default DSA prime is only 512 bits Bug 333405: item cleanup is unused DEADCODE in SECITEM_AllocItem loser Bug 288730: compiler warnings in certutil Bug 337251: warning: /* within comment Bug 362967: export SECMOD_DeleteModuleEx Bug 389248: NSS build failure when NSS_ENABLE_ECC is not define...
SpiderMonkey 1.8.5
can treat as potential GC roots. The approach eliminates the need for the JS_EnterLocalRootScope API, and in many cases the need to explicitly root GC things or use the "root as you go" approach popular with earlier SpiderMonkey releases. Since this is a conservative collector, it will often find "garbage" addresses which can trigger warnings from certain code analysis tools. If you are running
valgrind on your embedding, be sure to build SpiderMonkey with the --enable-
valgrind option to suppress superflous error messages triggered by the garbage collector. This also means that objects will be finalized in a non-deterministic order in SpiderMonkey 1.8.5. This is not a bug, and, any embedding which depends upon deterministic finalization is fatally flawed. Typed Rooting API The rooting API has b...
SpiderMonkey 1.8.7
can treat as potential GC roots. The approach eliminates the need for the JS_EnterLocalRootScope API, and in many cases the need to explicitly root GC things or use the "root as you go" approach popular with earlier SpiderMonkey releases. Since this is a conservative collector, it will often find "garbage" addresses which can trigger warnings from certain code analysis tools. If you are running
valgrind on your embedding, be sure to build SpiderMonkey with the --enable-
valgrind option to suppress superflous error messages triggered by the garbage collector. This also means that objects will be finalized in a non-deterministic order in SpiderMonkey 1.8.5. This is not a bug, and, any embedding which depends upon deterministic finalization is fatally flawed. Typed Rooting API The rooting API has b...
Running Automated JavaScript Tests
e-level functionality, you may wish to use jstests.py PATH_TO_JS_SHELL --exclude=test262 Other options allow you to show the test command lines being run, command output and return codes, run tests named in a given file, exclude tests named in a given file, hide the progress bar, change the timeout, run skipped tests, print output in Tinderbox format, run a test in the debugger, or run tests in
valgrind. Run with the -h option to see all the options. The jstests test suite also includes some tests from web-platform-tests. By default, these are only run when no tests paths are specified; this can be overridden by the --wpt=enabled flag. Running JSTest in a browser JSTests also runs on browser, with the following command: ./mach jstestbrowser To run specific test, you can use --filter=PATTER...
Exploitable crashes
ough normal testing and usage, when developers recognize a crash stack in gdb or submitted to a bug as exploitable. Additionally, Mozilla developers make heavy use of two tools in particular to find exploitable situations before they show up as exploitable crash reports. The first tool is AddressSanitizer (ASAN). There is an MDN article documenting its use with Mozilla projects. The other tool is
Valgrind. There is an MDN article documenting its use with Mozilla projects. Next steps Once you've determined that a crash is potentially exploitable, take the following steps. If you need help with any of the steps (e.g. perhaps you lack necessary bugzilla privileges) please email security@mozilla.org. Make sure a bug is on file. Mark the bug as security-sensitive by putting it into the "Security-Sen...