TypeScript 检查导入元属性:调试失败,崩溃

2izufjch  于 6个月前  发布在  TypeScript
关注(0)|答案(4)|浏览(44)

🔎 搜索词

你好
这是来自 fuzzing crashes discussionthe first debug failure report 的另一个跟进工单

搜索词:

  • transpileModule
  • debug failure
  • crash
  • checkImportMetaProperty

🕗 版本与回归信息

⏯ Playground链接

  • 无响应*

💻 代码

const ts = require("typescript");

const hex_string = "2c726270726f746f74797065326f746f747970656201000000000000053c7b746f3b6f74796f6a7375747270726f3b6f747970652d7c7b7c3c7b643c7c3c7f004005041274747375747270726f3b70652d72742a40283c7f7f61776169747f7f7670652d7c7b7c3c7b643c7c3c7f000005045b1274747375743170726f3b70652d7c28696d706f72742a40283c7f7f5f7f7f7f7f00000061776169747f7f7661727b067b636f6e7374727563746f722e70726f746f7439707b6f6a737574722c726f3b6f747970652d7c7b7c3c7b643c7c3c7f000005041274747375747270726f63617f3d045f523c6e7b5b233c7c213c7576616e0a726c3c696d706f726c742e7d0c3c696d706f72742e7d0c7b746f7b746f5c5c745c745c745c745c745c745c745c745c745c745c745c745c745c745c745c745c745c745c745c745c745c745c74733d3d2b3333333328732e2e73706f726c742e7d0c3c696d706f72742e7d0c7b743d083e28732c08006172756e6b6e6f776e747275270b100d2e70726f746f7479707b7c3c7b743c7c3c5100007b7b75740b00000000652e0030002a00002c000000120c0b50000000007273000005041274747375740470726f3b7f7f7f7f7f7f7f2e283c7f7f61776169747f7f7670650d2d7c7b7c3c7b643c7c3c7f0000050412747473757432707211440f742c637b6f127d3d7b0500000000000000742c637b6f127d3d7b05000000000000007a21593a";
const input = hex_string.match(/.{1,2}/g).map(byte => String.fromCharCode(parseInt(byte, 16))).join('');
ts.transpileModule(input, {});

🙁 实际行为

TypeScript/node_modules/typescript/lib/typescript.js:119406
        throw e;
        ^

Error: Debug Failure. False expression: Containing file is missing import meta node flag.
    at checkImportMetaProperty (TypeScript/node_modules/typescript/lib/typescript.js:74543:13)
    at checkMetaProperty (TypeScript/node_modules/typescript/lib/typescript.js:74506:16)
    at checkExpressionWorker (TypeScript/node_modules/typescript/lib/typescript.js:77249:18)
    at checkExpression (TypeScript/node_modules/typescript/lib/typescript.js:77138:34)
    at maybeCheckExpression (TypeScript/node_modules/typescript/lib/typescript.js:76222:30)
    at BinaryExpressionStateMachine.onRight (TypeScript/node_modules/typescript/lib/typescript.js:76186:18)
    at Array.right (TypeScript/node_modules/typescript/lib/typescript.js:27825:36)
    at trampoline (TypeScript/node_modules/typescript/lib/typescript.js:27591:44)
    at TypeScript/node_modules/typescript/lib/typescript.js:76116:24
    at checkExpressionWorker (TypeScript/node_modules/typescript/lib/typescript.js:77261:18)

Node.js v18.16.0

🙂 预期行为

不会导致 Node.js 运行时崩溃

关于问题的附加信息

  • 无响应*
ttp71kqs

ttp71kqs1#

我得到了两个不同的减少重复的答案$x_1a_0b_1^x$.

oymdgrw7

oymdgrw72#

> require("typescript").transpileModule("|{var{n<{}}=", {})
Uncaught TypeError: Cannot read properties of undefined (reading 'kind')
    at isObjectBindingOrAssignmentPattern (D:\Throwaway\tbi\node_modules\typescript\lib\typescript.js:12348:18)
    at isBindingOrAssignmentPattern (D:\Throwaway\tbi\node_modules\typescript\lib\typescript.js:12345:12)
    at bindingOrAssignmentElementAssignsToName (D:\Throwaway\tbi\node_modules\typescript\lib\typescript.js:88998:9)
    at bindingOrAssignmentPatternAssignsToName (D:\Throwaway\tbi\node_modules\typescript\lib\typescript.js:89008:11)
    at bindingOrAssignmentElementAssignsToName (D:\Throwaway\tbi\node_modules\typescript\lib\typescript.js:88999:14)
    at flattenDestructuringAssignment (D:\Throwaway\tbi\node_modules\typescript\lib\typescript.js:88948:34)
    at visitBinaryExpression (D:\Throwaway\tbi\node_modules\typescript\lib\typescript.js:101749:16)
    at visitorWorker (D:\Throwaway\tbi\node_modules\typescript\lib\typescript.js:100507:18)
    at visitor (D:\Throwaway\tbi\node_modules\typescript\lib\typescript.js:100380:38)
    at visitNode (D:\Throwaway\tbi\node_modules\typescript\lib\typescript.js:86560:21)
yrdbyhpb

yrdbyhpb3#

为了我自己的将来参考

const ts = require("typescript");
const hex_string_start = "2c726270726f746f74797065326f746f747970656201000000000000053c7b746f3b6f74796f6a7375747270726f3b6f747970652d7c7b7c3c7b643c7c3c7f004005041274747375747270726f3b70652d72742a40283c7f7f61776169747f7f7670652d7c7b7c3c7b643c7c3c7f000005045b1274747375743170726f3b70652d7c28696d706f72742a40283c7f7f5f7f7f7f7f00000061776169747f7f7661727b067b636f6e7374727563746f722e70726f746f7439707b6f6a737574722c726f3b6f747970652d7c7b7c3c7b643c7c3c7f000005041274747375747270726f63617f3d045f523c6e7b5b233c7c213c7576616e0a726c3c696d706f726c742e7d0c3c696d706f72742e7d0c7b746f7b746f5c5c745c745c745c745c745c745c745c745c745c745c745c745c745c745c745c745c745c745c745c745c745c745c74733d3d2b3333333328732e2e73706f726c742e7d0c3c696d706f72742e7d0c7b743d083e28732c08006172756e6b6e6f776e747275270b100d2e70726f746f7479707b7c3c7b743c7c3c5100007b7b75740b00000000652e0030002a00002c000000120c0b50000000007273000005041274747375740470726f3b7f7f7f7f7f7f7f2e283c7f7f61776169747f7f7670650d2d7c7b7c3c7b643c7c3c7f0000050412747473757432707211440f742c637b6f127d3d7b0500000000000000742c637b6f127d3d7b05000000000000007a21593a";

let hex_string = hex_string_start;
while (true) {
    const parts = hex_string.split('');
    const spliceIndex = Math.floor(Math.random() * hex_string.length / 2) * 2;
    for (let i = 0; i <= Math.floor(Math.random() * 6); i++) {
        parts.splice(spliceIndex, 2);
    }
    const newString = parts.join("");
    const input = newString.match(/.{1,2}/g).map(byte => String.fromCharCode(parseInt(byte, 16))).join('');
    try {
        ts.transpileModule(input, {});
    } catch (e) {
        hex_string = newString;
        console.log(input);
        console.log(e);
    }
}
izj3ouym

izj3ouym4#

哦,有趣!我这边无法复现其他跟踪。猜想这使得这个问题更加相关👍。

相关问题