Skip to content

Infinite loop while parsing template with deprecation warning #4250

@clalancette

Description

@clalancette

First, I want to thank you for developing and maintaining this tool. We use it heavily in https://github.com/ros2/ros2 .

I've found what looks to be an infinite loop problem in uncrustify with a particular piece of code in our codebase. The original code is here, but the problematic function is:

class AnySubscriptionCallback
{
  template<typename SetT>
#if !defined(RCLCPP_AVOID_DEPRECATIONS_FOR_UNIT_TESTS)
  [[deprecated("use 'void(std::shared_ptr<const MessageT>)' instead")]]
#endif
  void
  set_deprecated(std::function<void(std::shared_ptr<SetT>)> callback)
  {
    callback_variant_ = callback;
  }
};

I'm currently running the following version of uncrustify (built from source today):

$ ./uncrustify --version
Uncrustify_d-0.78.1-138-e312b0e41

For this test, I'm using the default configuration file from this project.

When I run the above, like the following:

./uncrustify -c etc/defaults.cfg /path/to/code/above.cpp

Then uncrustify goes into an infinite loop. If I remove the template argument, it doesn't loop forever. If I remove the deprecation warning, it doesn't loop forever. If I make it a standalone function (not inside the class), it doesn't loop forever.

Going back through uncrustify history, here are some working and failing versions:

  • uncrustify-0.72.0 - works
  • uncrustify-0.73 - works
  • uncrustify-0.74.0 - loops forever
  • uncrustify-0.75.1 - loops forever
  • uncrustify-0.78.1-138-e312b0e41 - loops forever

I can't attach a debug.txt (as produced by the -p option), since the infinite loop prevents that from being created. Also, setting debug_max_number_of_loops seems to have no effect here, and it loops forever anyway.

I can get some debug information by running:

./uncrustify -c etc/defaults.cfg /path/to/code/above.cpp -L A 2>A.txt

You can find the results of that in https://gist.github.com/clalancette/5cf4a89ebf3d707d7eba82711c46efba .

Please let me know if you need any other information from me.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions