🐛 Bug report: Boolean union (.union()) call hangs indefinitely with no feedback (uninterruptible)
- Dominant language
- Python
- Stars
- 5.8k
- Forks
- 541
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 5
Description
## To Reproduce
When performing a `.union()` between solids that are exactly coplanar or tangentially touching, CadQuery (via OCC) hangs indefinitely with no feedback or exception.
The process consumes CPU but never returns, and cannot be interrupted by `Ctrl+C` or `threading` timeouts.
Minimal reproducible example:
```python
import cadquery as cq
# Sketch 0
wp_sketch0 = cq.Workplane(cq.Plane(
cq.Vector(-0.750, 0.000, -0.344),
cq.Vector(1.000, 0.000, -0.000),
cq.Vector(0.000, -1.000, 0.000)
))
loop0 = (
wp_sketch0.moveTo(0.750, 0.000)
.lineTo(0.750, 0.347)
.lineTo(0.434, 0.347)
.threePointArc((0.364, 0.343), (0.332, 0.332))
.lineTo(0.332, 0.000)
.threePointArc((0.000, 0.036), (0.000, 0.000))
.close()
)
solid0 = wp_sketch0.add(loop0).extrude(0.148)
solid = solid0
# Sketch 1
wp_sketch1 = cq.Workplane(cq.Plane(
cq.Vector(-0.438, 0.000, 0.000),
cq.Vector(1.000, 0.000, -0.000),
cq.Vector(0.000, -1.000, 0.000)
))
loop1 = wp_sketch1.moveTo(0.442, 0.000).circle(0.442)
solid1 = wp_sketch1.add(loop1).extrude(0.148)
solid = solid.union(solid1)
# Sketch 2
wp_sketch2 = cq.Workplane(cq.Plane(
cq.Vector(-0.438, 0.000, -0.148),
cq.Vector(1.000, 0.000, -0.000),
cq.Vector(0.000, -1.000, 0.000)
))
loop2 = wp_sketch2.moveTo(0.442, 0.000).circle(0.442)
solid2 = wp_sketch2.add(loop2).extrude(0.148)
# This line hangs forever — cannot be interrupted or caught
solid = solid.union(solid2)
````
**Behavior:**
* Hangs forever at the last line (`solid.union(solid2)`).
* No Python exception is raised.
* `Ctrl+C` or thread-based timeout cannot stop it.
* If the Z-position of the plane in the last sketch is changed from `-0.438` → `+0.438`, the problem disappears (so it depends on geometry alignment).
---
## Backtrace
There is no Python traceback because the process never raises an exception or returns.
The Python process must be forcibly terminated.
---
## Environment
OS:
Ubuntu 22.04
Using:
Python script (run from command line)
CadQuery version:
2.6.0
---
**Suggested improvement:**
* Add a timeout or interruptible mechanism for boolean operations.
* Raise a Python exception (or return `None`) if a boolean fails or exceeds a time threshold.
* Optionally provide a “safe mode” such as `solid.union(other, safe=True, max_time=10)`.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.