Skip to content

Commit

Permalink
Fixed deadlock caused by too many error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
teared committed Sep 1, 2021
1 parent 4805ea8 commit 6204a83
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
24 changes: 17 additions & 7 deletions commands/vex_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,29 @@ def worker(self, executable, context, compile_all, include_dirs, vex_output, sni
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
proc = subprocess.Popen(cmd, startupinfo=startupinfo, stderr=subprocess.PIPE, universal_newlines=True)
proc.wait()
vcc_output = proc.stderr.read()
try:
_, vcc_output = proc.communicate(timeout=30)
vcc_output = vcc_output.strip()
if vcc_output:
try:
vcc_output = self.format_output(vcc_output, file_path, snippet, code, generated_code, vars['file'])
except: # Catch any errors during formatting.
vcc_output = "Add-on error: can't parse VCC output for this input"
else:
vcc_output = 'Successfully compiled in %.02fs' % (time.time() - self.started)
except subprocess.TimeoutExpired:
# The child process is not killed if the timeout expires,
# so kill the child process and finish communication.
proc.kill()
proc.communicate()
vcc_output = 'VCC execution timeout: compilation took longer than 30 seconds'

# Delete generated code file.
if snippet:
os.remove(file_path)

self.output.run_command('append', {
'characters': self.format_output(vcc_output, file_path, snippet, code, generated_code, vars['file']),
'characters': vcc_output,
'force': True,
'scroll_to_end': True
})
Expand Down Expand Up @@ -302,10 +316,6 @@ def format_output(self, vcc_output, file_path='', snippet=False, code='', genera
TODO: fix splitting the whole path inside for loop.
"""
vcc_output = vcc_output.strip()
if not vcc_output:
return 'Successfully compiled in %.02fs' % (time.time() - self.started)

parsed = []
for line in vcc_output.split('\n'):
match = re.match(r'^(.+?):(?:(\d+):(\d+(?:-\d+)?):)?\s+(.+?):\s+(.+)$', line)
Expand Down
3 changes: 2 additions & 1 deletion messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"7.1.2": "messages/7.1.2.txt",
"7.1.3": "messages/7.1.3.txt",
"7.1.4": "messages/7.1.4.txt",
"7.1.5": "messages/7.1.5.txt"
"7.1.5": "messages/7.1.5.txt",
"7.1.6": "messages/7.1.6.txt"
}
16 changes: 16 additions & 0 deletions messages/7.1.6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Houdini add-on for Sublime Text:
https://github.com/teared/VEX


Release 7.1.6


1. Fixed internal deadlock caused by too many error messages:

VCC process waits for the OS pipe buffer to accept more data,
which caused the add-on stuck in the "VCC is currently running..." state.

The deadlock may have caused files to get stuck in the temp folder.
Temporary filename pattern: tmpxxxxxx

2. Added compilation timeout of 30 seconds.

0 comments on commit 6204a83

Please sign in to comment.