Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cppclean crash on specific header #76

Closed
jwpeterson opened this issue Nov 2, 2015 · 7 comments
Closed

cppclean crash on specific header #76

jwpeterson opened this issue Nov 2, 2015 · 7 comments
Labels

Comments

@jwpeterson
Copy link

Hi,

Not sure if you really want bug reports about specific files here, but in trying to run cppclean on this particular header I get a crash with the following stack trace:

Traceback (most recent call last):
  File "/opt/miniconda/bin/cppclean", line 140, in <module>
    sys.exit(main())
  File "/opt/miniconda/bin/cppclean", line 133, in main
    quiet=args.quiet):
  File "/opt/miniconda/lib/python2.7/site-packages/cpp/find_warnings.py", line 518, in run
    hunter.find_warnings()
  File "/opt/miniconda/lib/python2.7/site-packages/cpp/find_warnings.py", line 119, in find_warnings
    self._find_header_warnings()
  File "/opt/miniconda/lib/python2.7/site-packages/cpp/find_warnings.py", line 390, in _find_header_warnings
    self._find_unused_warnings(included_files, forward_declarations)
  File "/opt/miniconda/lib/python2.7/site-packages/cpp/find_warnings.py", line 381, in _find_unused_warnings
    self._determine_uses(included_files, forward_declarations)
  File "/opt/miniconda/lib/python2.7/site-packages/cpp/find_warnings.py", line 348, in _determine_uses
    _process_function_body(node, node.namespace)
  File "/opt/miniconda/lib/python2.7/site-packages/cpp/find_warnings.py", line 318, in _process_function_body
    _add_use(t.name, namespace)
  File "/opt/miniconda/lib/python2.7/site-packages/cpp/find_warnings.py", line 274, in _add_use
    name = file_use_node[1].filename
KeyError: 1
@myint
Copy link
Owner

myint commented Nov 2, 2015

I don't know if it is the cause of the bug, but this seems to use the _lookup_in_all_namespaces() code path. Either way, the end result is that a dict gets stored in the symbol lookup table rather than the expected tuple.

Thanks

@myint myint added the bug label Nov 2, 2015
@jwpeterson
Copy link
Author

OK, if it helps, I also get the same (I think) crash on a much shorter (186 lines instead of 2282 lines) file.

@jwpeterson
Copy link
Author

This one also crashes in the same way, and is only 144 lines. If I comment out all the explicit instantiations in the file, which are of the form:

template<>
inline
Real WendlandRBF<3,0>::operator()(Real rad) const
{
  if (rad > _rcut) return 0.;

  rad /= _rcut;

  return Utility::pow<2>(1.-rad);
}

then cppclean runs fine, for whatever that's worth.

@r-e-d
Copy link
Collaborator

r-e-d commented Nov 7, 2015

Hi,

Any bug report is fine. It's easier to debug if you reduce the testcase like in your last post but a complete file is also ok.

Neither of these files seems to crash after the latest patch. Can you confirm that this is fixed for you ? In this case, we can close this issue.

@jwpeterson
Copy link
Author

Can you confirm that this is fixed for you ? In this case, we can close this issue.

It looks like it's working -- I no longer seem to get the invalid warnings about unused forward declarations and the headers that cppclean was crashing on previously now seem to work. Thanks!

BTW, I just cloned the repo and used the cppclean script there directly. Can I easily pip install the Github version in place of 0.5? I have not used pip much before, unfortunately.

@myint
Copy link
Owner

myint commented Nov 10, 2015

Something like:

$ pip uninstall cppclean
$ pip install git+https://github.com/myint/cppclean

@jwpeterson
Copy link
Author

Thanks, that worked great.

BTW since the problem seems to be resolved I'm closing the issue...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants