doctrine/sql-formatter

Suspected endless loop in 1.5.0 version

Housik opened this issue · 3 comments

Our php application using 1.5.0 is reaching execution time out. I analysed which packages have been changed - no app code updated, just libs (there was cca 3 libs) and I identified doctrine/sql-formatter as potential candidate causing endless loop, because it has in code new while loop. When I rollback to working app version and updated only doctrine/sql-formatter and issue appeared again...

Please @mvorisek double check src/Tokenizer.php -> all while loops, especially the one on 912 line, and 907 line, if there is no possibility to cause endless while loop.

@Housik Thanks for the report. Since this happened in an application of yours, may you please provide a PHPUnit test that reproduces the problem isolated in SQLformatter?

@Housik I will look into it but of course repro is needed.

Dump all $string inputs at line https://github.com/doctrine/sql-formatter/blob/1.5.0/src/Tokenizer.php#L906 and post here the last dumped input string.

It was really difficult to investigate the issue and at the end it looks like we forgot to shift major Oracle DB version in Doctrine ORM configuration (Oracle was upgraded same week as this library). OCI8 php extension then sent some "incompatible" command to Oracle and caused php thread to freeze/timeout. So you can close the issue as resolved and may be the text will help somebody in the future. Anyway, thank you very much for cooperation.