const log = console.log; function confuse(arr, index) { return arr[index]; } let doubles = [1.1, 2.2, 3.3]; for (let i = 0; i < 10000; i++) { confuse(doubles, 0); } let secretObj = { secret: "TOP_SECRET_DATA" }; let objects = [secretObj]; let leak = confuse(objects, 0); if (leak && leak.secret) { log(`\nLeaked secret: ${leak.secret}`); %DebugPrint(leak); } else { log("\nFailed."); } // Result: // [marking 0x107a000649ad for optimization to MAGLEV, ConcurrencyMode::kConcurrent, reason: hot and stable] // [compiling method 0x107a000649ad (target MAGLEV), mode: ConcurrencyMode::kConcurrent] // [marking 0x107a00064949 for optimization to MAGLEV, ConcurrencyMode::kConcurrent, reason: hot and stable] // [completed compiling 0x107a000649ad (target MAGLEV) - took 0.000, 4.000, 0.042 ms] // [compiling method 0x107a00064949 (target MAGLEV) OSR, mode: ConcurrencyMode::kConcurrent] // [completed compiling 0x107a00064949 (target MAGLEV) OSR - took 0.000, 2.666, 0.042 ms] // [compiling method 0x107a00064949 (target TURBOFAN_JS) OSR, mode: ConcurrencyMode::kConcurrent] // [bailout (kind: deopt-eager, reason: Insufficient type feedback for object literal): begin. deoptimizing 0x107a00064949 , 0x7eb800140705 , opt id 1, node id 0, bytecode offset 61, deopt exit 5, FP to SP delta 96, caller SP 0x00016f26a798, pc 0x000150002b50] // [bailout (kind: deopt-eager, reason: wrong map): begin. deoptimizing 0x107a000649ad , 0x7eb80014017d , opt id 0, node id 0, bytecode offset 2, deopt exit 0, FP to SP delta 32, caller SP 0x00016f26a718, pc 0x000150000544] // Leaked secret: TOP_SECRET_DATA // DebugPrint: 0x107a00195cd1: [JS_OBJECT_TYPE] // - map: 0x107a00064bbd [FastProperties] // - prototype: 0x107a0004c721 // - elements: 0x107a000007bd [HOLEY_ELEMENTS] // - properties: 0x107a000007bd // - All own properties (excluding elements): { // 0x107a0006473d: [String] in OldSpace: #secret: 0x107a00064751 (const data field 0, attrs: [WEC]) @ Any, location: in-object // } // 0x107a00064bbd: [Map] in OldSpace // - map: 0x107a0004b7ad )> // - type: JS_OBJECT_TYPE // - instance size: 16 // - inobject properties: 1 // - unused property fields: 0 // - elements kind: HOLEY_ELEMENTS // - enum length: invalid // - stable_map // - back pointer: 0x107a00064b95 // - prototype_validity cell: 0x107a00000ad5 // - instance descriptors (own) #1: 0x107a00195ce1 // - prototype: 0x107a0004c721 // - constructor: 0x107a0004c231 // - dependent code: 0x107a000007cd // - construction counter: 0 // ================================================================= // ==13785==ERROR: LeakSanitizer: detected memory leaks // Direct leak of 4096 byte(s) in 1 object(s) allocated from