vue: Infinite loop in vue-template-compiler

Version

2.6.10

Reproduction link

https://github.com/oguimbal/vuebug

Steps to reproduce

git clone git@github.com:oguimbal/vuebug.git
npm i
npm start

Wait a couple of seconds, and your compilation process will be frozen.

If you attach a debugger to the node process, you will see the infinite loop in generateCodeFrame() method of vue-template-compiler:

bug

What is expected?

I would expect the compiler not to freeze

What is actually happening?

The compiler is freezing

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 1
  • Comments: 15 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Well I have found the culprit 😂 https://github.com/vuejs/vue/blob/d2db6af1a55fdb4d65746fb67f7bfbced7d916f0/src/compiler/codeframe.js#L8

This line. There’re many warnings that do not provide the end position. For those warnings, end is calculated by source.length. However, in the following for-loop, count is incremented by lineLength + 1, which is incorrect if the line ends with CRLF. Thus the infinite loop.

Also, this only happens when the template does not have an indentation because otherwise Vue would have normalized the template source during de-indentation

I just reproduced this issue… The repository URL in OP is different from the one in the screenshot. The correct one is https://github.com/oguimbal/vuebug-simple After cloning this repo & change the line endings I can reproduce the frozen output bug.