Repository navigation
Commit e963497
authored
internal/gzip: fix goroutine leak in ReadCloserLevel (#2347)
Move defer r.Close() and defer pw.Close() to the top of the goroutine
so they execute regardless of which error path exits the function.
Previously, r.Close() was only called inside the io.Copy error path
and the happy-path end, leaving it unclosed when gw.Close() or
bw.Flush() failed.
When r wraps a limitedReadCloser (used by the pullLimiter introduced
in #2271), failing to close r permanently leaks the limiter token
slot. Under layout.WriteImage (used by kaniko for build-stage caching),
this eventually deadlocks because all slots are occupied.
Also add defer gw.Close() after gw creation so the gzip writer is
always properly finalized.
Fixes #2342
Signed-off-by: Aaron <[email protected]>1 parent 02649ea commit e963497
1 file changed
Lines changed: 8 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
56 | 60 | | |
57 | 61 | | |
58 | 62 | | |
59 | 63 | | |
| 64 | + | |
| 65 | + | |
60 | 66 | | |
61 | 67 | | |
62 | | - | |
63 | | - | |
64 | 68 | | |
65 | 69 | | |
66 | 70 | | |
67 | | - | |
68 | 71 | | |
69 | 72 | | |
70 | 73 | | |
71 | 74 | | |
72 | | - | |
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
76 | 78 | | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | 79 | | |
82 | 80 | | |
83 | 81 | | |
| |||
0 commit comments