LogPrint(category...) fixes #3377

pull gavinandresen wants to merge 2 commits into bitcoin:master from gavinandresen:LogPrintFixes changing 1 files +29 −26
  1. gavinandresen commented at 3:31 AM on December 10, 2013: contributor

    Two commits, two fixes.

    First is an obscure infinite loop on Windows (and possible crash-at-shutdown). Most of the difference in that commit are just an indentation change from switching from LOCK(cs_...) to using mutexDebugLock.

    Second is a fix for an obscure crash-at-shutdown on all platforms.

    Tested by running without -debug, with -debug and with -debug=net -debug=mempool.

  2. Fix infinite loop with LogPrint on Windows
    Running -printtodebugger -debug (or -debug=lock),
    compiled with -DDEBUG_LOCKORDER would infinite loop
    on Windows because every critical section lock/unlock
    triggers a LogPrint.
    
    Solution is to use the raw boost mutex instead of a CCriticalSection.
    962b1cf441
  3. Use thread-local storage for LogPrint(category...)
    This prevents crashes at shutdown where a global destructor
    calls LogPrint(category...) after mapMultiArgs has been
    deleted.
    0b238b2786
  4. BitcoinPullTester commented at 3:44 AM on December 10, 2013: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/0b238b278686f8e0c6609b7c9360d36c3198105c for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.

  5. in src/util.cpp:None in 0b238b2786
     304 | @@ -299,27 +305,24 @@ int LogPrint(const char* category, const char* pszFormat, ...)
     305 |  #ifdef WIN32
     306 |      if (fPrintToDebugger)
    


    laanwj commented at 11:43 AM on December 10, 2013:

    BTW I strongly doubt that anyone is using "print to debugger". It's a strange, obscure, WIN32-only thing. Maybe it'd be better to get rid of it.


    sipa commented at 9:31 PM on December 12, 2013:

    Agree on getting rid of it.

  6. in src/util.cpp:None in 0b238b2786
     256 | +        if (ptrCategory.get() == NULL)
     257 |          {
     258 | -            // Category was not found (not supplied via -debug=<category>)
     259 | -            if (find(categories.begin(), categories.end(), string(category)) == categories.end())
     260 | -                return 0;
     261 | +            const vector<string>& categories = mapMultiArgs["-debug"];
    


    laanwj commented at 12:01 PM on December 10, 2013:

    ACK -- we must make sure though that no one will ever call LogPrint before mapMultiArgs has its final state, to avoid different threads ending up with different values. Neither ReadConfigFile nor ParseParameters calls LogPrint (and neither does any of the supporting code, it appears) so right now it is safe. In any case this is better than a crash.

  7. laanwj referenced this in commit 8a7606f35b on Dec 14, 2013
  8. laanwj merged this on Dec 14, 2013
  9. laanwj closed this on Dec 14, 2013

  10. gavinandresen deleted the branch on Mar 13, 2014
  11. Bushstar referenced this in commit ff6f391aea on Apr 8, 2020
  12. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 18:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me