Closed Bug 1525457 Opened 6 years ago Closed 6 years ago

LeakSanitizer reports memory leak from key generated in GenerateAsymmetricKeyTask::DoCrypto()

Categories

(Core :: Security: PSM, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1517574
Tracking Status
firefox67 --- affected

People

(Reporter: dholbert, Unassigned)

Details

I happened to notice that we've got a persistent leak reported for the Linux x64 asan "W-e10s(wpt1)" test run.

The leak logging looks like this:

INFO - TEST-OK | /WebCryptoAPI/generateKey/failures_RSA-OAEP.https.any.worker.html | took 1185ms
INFO - TEST-START | /WebCryptoAPI/generateKey/failures_RSA-PSS.https.any.html
INFO - Closing window 38654705665
INFO - PID 4168 | ###!!! [Parent][RunMessage] Error: Channel closing: too late to send/recv, messages will be lost
INFO - PID 4168 | ###!!! [Parent][RunMessage] Error: Channel closing: too late to send/recv, messages will be lost
INFO - PID 4168 | =================================================================
INFO - PID 4168 | LeakSanitizer: detected memory leaks
INFO - PID 4168 | Direct leak of 26 byte(s) in 26 object(s) allocated from:
INFO - PID 4168 |     #0 0x55753dba0953 in malloc /builds/worker/workspace/moz-toolchain/src/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:146:3
INFO - PID 4168 |     #1 0x7f7090eb3b90 in PORT_Alloc_Util /builds/worker/workspace/build/src/security/nss/lib/util/secport.c:87:14
INFO - PID 4168 |     #2 0x7f7090eb074d in SECITEM_AllocItem_Util /builds/worker/workspace/build/src/security/nss/lib/util/secitem.c:43:28
INFO - PID 4168 |     #3 0x7f7061d36ad9  (<unknown module>)
INFO - PID 4168 |     #4 0x7f7061d26608  (<unknown module>)
INFO - PID 4168 |     #5 0x7f7090429256 in PK11_GenerateKeyPairWithOpFlags /builds/worker/workspace/build/src/security/nss/lib/pk11wrap/pk11akey.c:1530:11
INFO - PID 4168 |     #6 0x7f7090429bf2 in PK11_GenerateKeyPairWithFlags /builds/worker/workspace/build/src/security/nss/lib/pk11wrap/pk11akey.c:1617:12
INFO - PID 4168 |     #7 0x7f7090429bf2 in PK11_GenerateKeyPair /builds/worker/workspace/build/src/security/nss/lib/pk11wrap/pk11akey.c:1641
INFO - PID 4168 |     #8 0x7f7079addb99 in mozilla::dom::GenerateAsymmetricKeyTask::DoCrypto() /builds/worker/workspace/build/src/dom/crypto/WebCryptoTask.cpp:2414:40
INFO - PID 4168 |     #9 0x7f7079ad9277 in CalculateResult /builds/worker/workspace/build/src/dom/crypto/WebCryptoTask.cpp:387:10
INFO - PID 4168 |     #10 0x7f7079ad9277 in mozilla::dom::WebCryptoTask::Run() /builds/worker/workspace/build/src/dom/crypto/WebCryptoTask.cpp:348
INFO - PID 4168 |     #11 0x7f70739563cf in nsThreadPool::Run() /builds/worker/workspace/build/src/xpcom/threads/nsThreadPool.cpp:241:14
INFO - PID 4168 |     #12 0x7f7073956b4c in non-virtual thunk to nsThreadPool::Run() /builds/worker/workspace/build/src/xpcom/threads/nsThreadPool.cpp
INFO - PID 4168 |     #13 0x7f707394c526 in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/workspace/build/src/xpcom/threads/nsThread.cpp:1162:14
INFO - PID 4168 |     #14 0x7f7073952748 in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/workspace/build/src/xpcom/threads/nsThreadUtils.cpp:474:10
INFO - PID 4168 |     #15 0x7f707490018a in mozilla::ipc::MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate*) /builds/worker/workspace/build/src/ipc/glue/MessagePump.cpp:303:20
INFO - PID 4168 |     #16 0x7f70748469bf in RunInternal /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:315:10
INFO - PID 4168 |     #17 0x7f70748469bf in RunHandler /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:308
INFO - PID 4168 |     #18 0x7f70748469bf in MessageLoop::Run() /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:290
INFO - PID 4168 |     #19 0x7f70739466da in nsThread::ThreadFunc(void*) /builds/worker/workspace/build/src/xpcom/threads/nsThread.cpp:449:11
INFO - PID 4168 |     #20 0x7f70910d4666 in _pt_root /builds/worker/workspace/build/src/nsprpub/pr/src/pthreads/ptthread.c:201:5
INFO - PID 4168 |     #21 0x7f7094dfd6b9 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76b9)
INFO - PID 4168 | -----------------------------------------------------
INFO - PID 4168 | Suppressions used:
INFO - PID 4168 |   count      bytes template
INFO - PID 4168 |     242       7712 nsComponentManagerImpl
INFO - PID 4168 |       1        208 mozJSComponentLoader::LoadModule
INFO - PID 4168 |     611      17713 libfontconfig.so
INFO - PID 4168 |       1         29 libglib-2.0.so
INFO - PID 4168 | -----------------------------------------------------
INFO - PID 4168 | -----------------------------------------------------
INFO - PID 4168 | Suppressions used:
INFO - PID 4168 |   count      bytes template
INFO - PID 4168 |     242       7712 nsComponentManagerImpl
INFO - PID 4168 |       1        208 mozJSComponentLoader::LoadModule
INFO - PID 4168 |     611      17713 libfontconfig.so
INFO - PID 4168 |       1         29 libglib-2.0.so
INFO - PID 4168 | -----------------------------------------------------
INFO - 

...and this:

INFO - .
INFO - TEST-OK | /WebCryptoAPI/generateKey/failures_RSA-PSS.https.any.worker.html | took 1216ms
INFO - TEST-START | /WebCryptoAPI/generateKey/failures_RSASSA-PKCS1-v1_5.https.any.html
INFO - Closing window 42949672961
INFO - PID 4168 | =================================================================
INFO - PID 4168 | LeakSanitizer: detected memory leaks
INFO - PID 4168 | Direct leak of 6 byte(s) in 6 object(s) allocated from:
INFO - PID 4168 |     #0 0x55683613c953 in malloc /builds/worker/workspace/moz-toolchain/src/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:146:3
INFO - PID 4168 |     #1 0x7fca68bb3b90 in PORT_Alloc_Util /builds/worker/workspace/build/src/security/nss/lib/util/secport.c:87:14
INFO - PID 4168 |     #2 0x7fca68bb074d in SECITEM_AllocItem_Util /builds/worker/workspace/build/src/security/nss/lib/util/secitem.c:43:28
INFO - PID 4168 |     #3 0x7fca39b44ad9  (<unknown module>)
INFO - PID 4168 |     #4 0x7fca39b34608  (<unknown module>)
INFO - PID 4168 |     #5 0x7fca68129256 in PK11_GenerateKeyPairWithOpFlags /builds/worker/workspace/build/src/security/nss/lib/pk11wrap/pk11akey.c:1530:11
INFO - PID 4168 |     #6 0x7fca68129bf2 in PK11_GenerateKeyPairWithFlags /builds/worker/workspace/build/src/security/nss/lib/pk11wrap/pk11akey.c:1617:12
INFO - PID 4168 |     #7 0x7fca68129bf2 in PK11_GenerateKeyPair /builds/worker/workspace/build/src/security/nss/lib/pk11wrap/pk11akey.c:1641
INFO - PID 4168 |     #8 0x7fca517ddb99 in mozilla::dom::GenerateAsymmetricKeyTask::DoCrypto() /builds/worker/workspace/build/src/dom/crypto/WebCryptoTask.cpp:2414:40
INFO - PID 4168 |     #9 0x7fca517d9277 in CalculateResult /builds/worker/workspace/build/src/dom/crypto/WebCryptoTask.cpp:387:10
INFO - PID 4168 |     #10 0x7fca517d9277 in mozilla::dom::WebCryptoTask::Run() /builds/worker/workspace/build/src/dom/crypto/WebCryptoTask.cpp:348
INFO - PID 4168 |     #11 0x7fca4b6563cf in nsThreadPool::Run() /builds/worker/workspace/build/src/xpcom/threads/nsThreadPool.cpp:241:14
INFO - PID 4168 |     #12 0x7fca4b656b4c in non-virtual thunk to nsThreadPool::Run() /builds/worker/workspace/build/src/xpcom/threads/nsThreadPool.cpp
INFO - PID 4168 |     #13 0x7fca4b64c526 in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/workspace/build/src/xpcom/threads/nsThread.cpp:1162:14
INFO - PID 4168 |     #14 0x7fca4b652748 in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/workspace/build/src/xpcom/threads/nsThreadUtils.cpp:474:10
INFO - PID 4168 |     #15 0x7fca4c60018a in mozilla::ipc::MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate*) /builds/worker/workspace/build/src/ipc/glue/MessagePump.cpp:303:20
INFO - PID 4168 |     #16 0x7fca4c5469bf in RunInternal /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:315:10
INFO - PID 4168 |     #17 0x7fca4c5469bf in RunHandler /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:308
INFO - PID 4168 |     #18 0x7fca4c5469bf in MessageLoop::Run() /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:290
INFO - PID 4168 |     #19 0x7fca4b6466da in nsThread::ThreadFunc(void*) /builds/worker/workspace/build/src/xpcom/threads/nsThread.cpp:449:11
INFO - PID 4168 |     #20 0x7fca68dd4666 in _pt_root /builds/worker/workspace/build/src/nsprpub/pr/src/pthreads/ptthread.c:201:5
INFO - PID 4168 |     #21 0x7fca6cb096b9 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x76b9)
INFO - PID 4168 | -----------------------------------------------------
INFO - PID 4168 | Suppressions used:
INFO - PID 4168 |   count      bytes template
INFO - PID 4168 |     242       7712 nsComponentManagerImpl
INFO - PID 4168 |       1        208 mozJSComponentLoader::LoadModule
INFO - PID 4168 |     611      17713 libfontconfig.so
INFO - PID 4168 |       1         29 libglib-2.0.so
INFO - PID 4168 | -----------------------------------------------------

and this:

INFO - TEST-OK | /WebCryptoAPI/generateKey/successes_RSASSA-PKCS1-v1_5.https.any.worker.html?21-30 | took 1206ms
INFO - Browser exited with return code 0
INFO - PROCESS LEAKS None
INFO - INFO | LeakSanitizer | SUMMARY: AddressSanitizer: 26 byte(s) leaked in 26 allocation(s).
INFO - LeakSanitizer | To show the addresses of leaked objects add report_objects=1 to LSAN_OPTIONS
INFO - This can be done in testing/mozbase/mozrunner/mozrunner/utils.py
INFO - Allowed depth was 4
INFO - TEST-FAIL | LeakSanitizer | leak at PORT_Alloc_Util, SECITEM_AllocItem_Util, PK11_GenerateKeyPairWithOpFlags, PK11_GenerateKeyPairWithFlags

Sample logs (you may want to use "open raw log" near top left for better find-in-page functionality):
https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=226293356&repo=autoland
https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=226294598&repo=autoland

Note that this leak isn't reported as a test-failure on TreeHerder -- i.e. if you click the icon for a Wpt1 testrun, this leak won't show up in the short-summary, unless there was another failure. (This seems to be a treeherder shortcoming at the moment.)

Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE

There's an extensive system set up for whitelisting in these WPT files. The basic issue is that we want to be able to import failing tests from upstream automatically without turning the tree orange. This ability to white list by directory was also taken advantage of to turn on leak checking without fixing any existing leaks.

The white lists for WPT can be seen here: https://searchfox.org/mozilla-central/search?q=lsan-allowed&path=

Bug 1517309 is the meta bug where I've been working on fixing these leaks and removing the white lists.

You need to log in before you can comment on or make changes to this bug.