Closed Tschet1 closed 2 years ago
I've run into an issue where generation with CMock takes significant time (multiple minutes for a single mock).
The issue seems to be a runaway regular expression https://www.regular-expressions.info/catastrophic.html
here: https://github.com/ThrowTheSwitch/CMock/blob/3806f7ebe34b17b002b8e2d6b9fdcd72e67c4f24/lib/cmock_header_parser.rb#L503
To recreate, check the following snippet on regex101: https://regex101.com/r/cx91Wh/1
I did not fully understand the meaning of the first part of the regex, but I would propose changing /([\w\s\*]+)+\s+(\w+)\s*\(((?:[\w\s\*]*,?)*)\s*\)*/ to /([\w\s\*]+)\s+(\w+)\s*\(((?:[\w\s\*]*,?)*)\s*\)*/
/([\w\s\*]+)+\s+(\w+)\s*\(((?:[\w\s\*]*,?)*)\s*\)*/
/([\w\s\*]+)\s+(\w+)\s*\(((?:[\w\s\*]*,?)*)\s*\)*/
Proposed fix in https://github.com/ThrowTheSwitch/CMock/pull/381
Fixed in https://github.com/ThrowTheSwitch/CMock/pull/381
I've run into an issue where generation with CMock takes significant time (multiple minutes for a single mock).
The issue seems to be a runaway regular expression https://www.regular-expressions.info/catastrophic.html
here: https://github.com/ThrowTheSwitch/CMock/blob/3806f7ebe34b17b002b8e2d6b9fdcd72e67c4f24/lib/cmock_header_parser.rb#L503
To recreate, check the following snippet on regex101: https://regex101.com/r/cx91Wh/1
I did not fully understand the meaning of the first part of the regex, but I would propose changing
/([\w\s\*]+)+\s+(\w+)\s*\(((?:[\w\s\*]*,?)*)\s*\)*/
to/([\w\s\*]+)\s+(\w+)\s*\(((?:[\w\s\*]*,?)*)\s*\)*/