
distcc - issue #99
include_server crash: local variable 'resolved' referenced before assignment
distcc 3.2rc1 SVN r755, Ubuntu 11.10, gcc 4.6.1
File(s) from the linux 3.x kernel build expose include_server bug: include_server crashes with "local variable 'resolved' referenced before assignment" (log below).
Attached patch fixes the crash, but warrants further review... Does the patch fully implement the intended functionality now, or is another else clause required (i.e. if neither 'quote' nor 'angle' matches, then what should happen?)
$ pump make -C debian/build/build-generic drivers/acpi/osl.o CC=distcc
CC drivers/acpi/osl.o WARNING include server: Preprocessing locally. Include server internal error: '<type 'exceptions.UnboundLocalError'>: ("local variable 'resolved' referenced before assignment",)' for translation unit '/home/kamal/src/linux/ubuntu-oneiric/drivers/acpi/osl.c' ------- Include server stack trace ----------- Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/include_server/include_server.py", line 379, in handle include_analyzer.client_root_keeper)) File "/usr/lib/python2.7/site-packages/include_server/include_analyzer.py", line 260, in DoCompilationCommand self.ProcessCompilationCommand(currdir, parsed_command)) File "/usr/lib/python2.7/site-packages/include_server/include_analyzer.py", line 191, in ProcessCompilationCommand ())) File "/usr/lib/python2.7/site-packages/include_server/include_analyzer.py", line 142, in _ProcessFileFromCommandLine closure = self.RunAlgorithm(fpath_resolved_pair, fpath_real) File "/usr/lib/python2.7/site-packages/include_server/include_analyzer_memoizing_node.py", line 326, in RunAlgorithm filepath_real_idx) File "/usr/lib/python2.7/site-packages/include_server/include_analyzer_memoizing_node.py", line 574, in FindNode self.symbol_table)) File "/usr/lib/python2.7/site-packages/include_server/macro_eval.py", line 432, in ResolveExpr resolved_files.append(resolved)
UnboundLocalError: local variable 'resolved' referenced before assignment
Comment #1
Posted on Apr 4, 2012 by Helpful PandaThe regular expression will always match either the 'quote' or the 'angle'.
The bug arises because the result of the match can be an empty string. This happens e.g. if you have '#include ' where MACRO could potentially evaluate to an empty string. The code is testing if match_result.group('quote'): rather than if match_result.group('quote') != None: and this test fails when the match succeeds but matches an empty string.
But since an empty string can never be a valid include file name, it is fine for the include server to exclude that possibility from its analysis. (If the expression does actually evaluate to an empty string, the compiler will report an error.)
So your patch is fine.
- patch 1.07KB
Comment #2
Posted on Apr 4, 2012 by Helpful PandaAs I explained in response to another bug, I've given you commit permissions. Please use them wisely -- make sure to get all changes reviewed and approved before committing.
But this change looks good, so please feel free to go and commit this fix to our svn repository.
Comment #3
Posted on Apr 4, 2012 by Happy Ox(No comment was entered for this change.)
Comment #4
Posted on Apr 4, 2012 by Happy OxFix applied as SVN r759.
Status: Fixed