Closed Opened 12 years ago Closed 12 years ago

# JM: Leak [@ js::methodjit::Compiler::Compile]

x86
Linux
Not set
critical

## Tracking

### ()

RESOLVED WORKSFORME

## Details

### (4 keywords)

```z = [{
test: function () {
f() = ""
}
}]
for (let i = 0; i < z.length; i++) {
a = z[i]
if (a.test()) h
}

leaks js debug shell on JM tip with -m and -j at malloc. This does not seem to occur without -m.

===

\$ cat w386-reduced.js | valgrind --leak-check=full ./js-dbg-64-jm-linux -m -j -i
==6201== Memcheck, a memory error detector
==6201== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==6201== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
==6201== Command: ./js-dbg-64-jm-linux -m -j -i
==6201==
js> z = [{
test: function () {
f() = ""
}
}]
[{test:(function () {f() = "";})}]
js> for (let i = 0; i < z.length; i++) {
a = z[i]
if (a.test()) h
}
[pic] moving 2 infos to script
[pic]     entry  0: hpb=0x4164393 crl=0x4164615
[pic]     entry  1: hpb=0x41644c7 crl=0x4164670
[pic] GETPROP 0x4164670 typein:6
[pic]     array length
[pic]     generate array length stub
[pic]     new stub start=0x4164740
[pic] CALLPROP 0x4164615 typein:8
[pic]     PIC 0x6002ae8 hit=0 patched=0 gen'd = 0
typein:3: ReferenceError: f is not defined
js>
==6201==
==6201== HEAP SUMMARY:
==6201==     in use at exit: 205 bytes in 11 blocks
==6201==   total heap usage: 1,131 allocs, 1,120 frees, 2,594,378 bytes allocated
==6201==
==6201== 16 bytes in 1 blocks are definitely lost in loss record 1 of 3
==6201==    at 0x4C274A8: malloc (vg_replace_malloc.c:236)
==6201==    by 0x40FD7E: js_malloc (jsutil.h:188)
==6201==    by 0x427E1D: JSRuntime::malloc(unsigned long) (jscntxt.h:1542)
==6201==    by 0x4280D0: JSContext::malloc(unsigned long) (jscntxt.h:1983)
==6201==    by 0x5AFFE2: js::methodjit::Compiler::Compile() (Compiler.cpp:177)
==6201==    by 0x5C65E5: js::methodjit::Compile(JSContext*, JSScript*) (MethodJIT.cpp:622)
==6201==    by 0x5D453F: InlineCall(js::VMFrame&, unsigned int, void**, unsigned int) (Stubs.cpp:3078)
==6201==    by 0x5D4764: js::jsl_Call(js::VMFrame&, unsigned int) (Stubs.cpp:3116)
==6201==    by 0x41643E6: ???
==6201==    by 0x5C6527: js::methodjit::JaegerShot(JSContext*) (MethodJIT.cpp:605)
==6201==    by 0x484D8F: js_RunScript (jsinterp.cpp:440)
==6201==    by 0x486152: js_Execute (jsinterp.cpp:890)
==6201==
==6201== 60 bytes in 1 blocks are definitely lost in loss record 2 of 3
==6201==    at 0x4C274A8: malloc (vg_replace_malloc.c:236)
==6201==    by 0x5B0162: js::methodjit::Compiler::Compile() (Compiler.cpp:200)
==6201==    by 0x5C65E5: js::methodjit::Compile(JSContext*, JSScript*) (MethodJIT.cpp:622)
==6201==    by 0x5D453F: InlineCall(js::VMFrame&, unsigned int, void**, unsigned int) (Stubs.cpp:3078)
==6201==    by 0x5D4764: js::jsl_Call(js::VMFrame&, unsigned int) (Stubs.cpp:3116)
==6201==    by 0x41643E6: ???
==6201==    by 0x5C6527: js::methodjit::JaegerShot(JSContext*) (MethodJIT.cpp:605)
==6201==    by 0x484D8F: js_RunScript (jsinterp.cpp:440)
==6201==    by 0x486152: js_Execute (jsinterp.cpp:890)
==6201==    by 0x42558F: JS_ExecuteScript (jsapi.cpp:4823)
==6201==    by 0x404008: Process(JSContext*, JSObject*, char*, int) (js.cpp:544)
==6201==    by 0x404A79: ProcessArgs(JSContext*, JSObject*, char**, int) (js.cpp:871)
==6201==
==6201== LEAK SUMMARY:
==6201==    definitely lost: 76 bytes in 2 blocks
==6201==    indirectly lost: 0 bytes in 0 blocks
==6201==      possibly lost: 0 bytes in 0 blocks
==6201==    still reachable: 129 bytes in 9 blocks
==6201==         suppressed: 0 bytes in 0 blocks
==6201== Reachable blocks (those to which a pointer was found) are not shown.
==6201== To see them, rerun with: --leak-check=full --show-reachable=yes
==6201==
==6201== For counts of detected and suppressed errors, rerun with: -v
==6201== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 4 from 4)```
Keywords: mlk
Summary: JM: Leak [@ malloc] → JM: Leak [@ js::methodjit::Compiler::Compile]
```WFM on JM changeset 5ff0c0a8d4d8 on 32-bit and 64-bit shells. (Tested only on Mac)

\$ cat 560078.js | ~/Bin/vTrunk --leak-check=full ./js-dbg-64-jm-darwin -m -j -i
==1148== Memcheck, a memory error detector
==1148== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==1148== Using Valgrind-3.6.0.SVN and LibVEX; rerun with -h for copyright info
==1148== Command: ./js-dbg-64-jm-darwin -m -j -i
==1148==
js> z = [{
test: function () {
f() = ""
}
}]
[{test:(function () {f() = "";})}]
js> for (let i = 0; i < z.length; i++) {
a = z[i]
if (a.test()) h
}
typein:3: ReferenceError: f is not defined
js>
js>
js>
==1148==
==1148== HEAP SUMMARY:
==1148==     in use at exit: 707,383 bytes in 1,691 blocks
==1148==   total heap usage: 3,408 allocs, 1,717 frees, 1,803,084 bytes allocated
==1148==
==1148== LEAK SUMMARY:
==1148==    definitely lost: 0 bytes in 0 blocks
==1148==    indirectly lost: 0 bytes in 0 blocks
==1148==      possibly lost: 0 bytes in 0 blocks
==1148==    still reachable: 707,383 bytes in 1,691 blocks
==1148==         suppressed: 0 bytes in 0 blocks
==1148== Reachable blocks (those to which a pointer was found) are not shown.
==1148== To see them, rerun with: --leak-check=full --show-reachable=yes
==1148==
==1148== For counts of detected and suppressed errors, rerun with: -v
==1148== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)```
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.
{"ft_lang_label":"__label__en","ft_lang_prob":0.64530295,"math_prob":0.6780282,"size":5508,"snap":"2021-43-2021-49","text_gpt3_token_len":1973,"char_repetition_ratio":0.1693314,"word_repetition_ratio":0.35732648,"special_character_ratio":0.442992,"punctuation_ratio":0.23097113,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9913239,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-11-29T18:21:44Z\",\"WARC-Record-ID\":\"<urn:uuid:282c6990-ae00-4e62-8859-f3b67adec24b>\",\"Content-Length\":\"78995\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b7a9a30e-f244-450a-818d-772d3425e605>\",\"WARC-Concurrent-To\":\"<urn:uuid:73e8606a-199a-4c8a-8803-e7e4ac064365>\",\"WARC-IP-Address\":\"52.38.23.124\",\"WARC-Target-URI\":\"https://bugzilla.mozilla.org/show_bug.cgi?id=560078\",\"WARC-Payload-Digest\":\"sha1:ROIS6ZH36IZNYHC5TUUUFD56GXQO5LB4\",\"WARC-Block-Digest\":\"sha1:LO4SYPXGQKVY633WCMSPAPUXXDINL6TP\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-49/CC-MAIN-2021-49_segments_1637964358786.67_warc_CC-MAIN-20211129164711-20211129194711-00055.warc.gz\"}"}