Skip to content

Conversation

@NicoHinderling
Copy link
Contributor

@NicoHinderling NicoHinderling commented Jan 14, 2026

We were seeing a build with some extremely long symbols that can cause the demangling process to hang. This is an idea for curbing the impact:

  1. adding a 30s timeout for each chunk
  2. skipping symbols that have more than 1500 characters

@NicoHinderling NicoHinderling marked this pull request as ready for review January 14, 2026 19:55
@NicoHinderling NicoHinderling force-pushed the add-more-limits-to-demangling branch from fc5f3a8 to e5d8c3a Compare January 14, 2026 20:00
Comment on lines +208 to +214
result = subprocess.run(
command_parts, capture_output=True, text=True, check=True, timeout=DEFAULT_DEMANGLE_TIMEOUT
)
except subprocess.TimeoutExpired:
elapsed = time.time() - start_time
logger.warning(f"Chunk {chunk_idx} timed out after {elapsed:.1f}s")
return {}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The subprocess.run call does not explicitly terminate the child process when a TimeoutExpired exception is caught, which could lead to orphan processes.
Severity: HIGH

Suggested Fix

In the except subprocess.TimeoutExpired block, add logic to explicitly terminate the child process. You can access the process via the .child attribute of the TimeoutExpired exception object and call its .kill() method to ensure it is properly cleaned up.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/launchpad/utils/apple/cwl_demangle.py#L208-L214

Potential issue: When the `subprocess.run` call in `cwl_demangle.py` times out, the
`TimeoutExpired` exception is caught, but the child `cwl-demangle` process may not be
terminated. This could lead to an accumulation of zombie or orphan processes, consuming
system resources. While the behavior of `subprocess.run` on timeout can vary between
Python versions, explicitly terminating the process is the safest approach to ensure
proper resource cleanup, a pattern seen elsewhere in the codebase.

Did we get this right? 👍 / 👎 to inform future reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants