hardhat
hardhat copied to clipboard
Infinite Loop in Source Map Parsing
It is possible to cause an infinite loop in the source map parsing if an empty buffer ends up being passed through to this function. It will just loop forever.
https://github.com/NomicFoundation/hardhat/blob/98b7548525080c91a45cc3d3971f2d0248f62695/packages/hardhat-core/src/internal/hardhat-network/stack-traces/source-maps.ts#L76-L84
I think that there should be a check added to ensure that this doesn't loop forever to prevent hardhat from crashing on bad input.
It is possible to create an empty buffer if the string passed to this function has a 0x prefix.
https://github.com/NomicFoundation/hardhat/blob/98b7548525080c91a45cc3d3971f2d0248f62695/packages/hardhat-core/src/internal/hardhat-network/stack-traces/library-utils.ts#L20-L33
This is only possible if there is a bug in the creation of the compiler output JSON file which incorrectly serializes the object bytecode with a 0x prefix.
This issue is also being tracked on Linear.
We use Linear to manage our development process, but we keep the conversations on Github.
LINEAR-ID: 390b3faa-6306-4f67-bb1a-2308b4489fc6
One option would be to pass compilerOutputBytecodeObject through remove0x or similar
This issue was marked as stale because it didn't have any activity in the last 30 days. If you think it's still relevant, please leave a comment indicating so. Otherwise, it will be closed in 7 days.