Commit 12e6ebd
fix: 5 more instances of the stale-write clone bug in string/regexp splitting
Continuing the sweep from bbd1ddb (grepped for the "publish empty, grow
visible" idiom and its variants across every file that calls
vmAllocManagedSlice, not just the ones with an explanatory comment
already attached). Found the identical shape in:
- string.zig: nativeStrSplit (both the empty-separator/rune and
separator-based branches), nativeStrFields, and the split-with-limit
function — each grows a published array_managed length by one
element per split/field while writing through a captured local, in a
loop whose body (substring/makeDynString) can allocate.
- regexp.zig: nativeReFindAll and the split function that follows it —
same shape, one array_managed element written per regex match.
All five: pre-fill the destination with .null and publish the full
length immediately instead of growing it visible incrementally, then
read/write through the owning Object's own field per iteration rather
than the captured local — same fix as core.clone (6e4b81c), host_abi's
wire decoding (10837a5), and template's path splitting (bbd1ddb).
Also checked and ruled out as non-instances: core.zig's nativeGcStats/
nativeGcStatsExt (superficially similar "publish empty then fill"
shape, but every value written is a scalar .int or a ctx.cs.internStr
string — internStr allocates from the chunk's own permanent bump
region, never the collectible managed heap, so nothing in either loop
can trigger compactManagedHeap at all).
Verified: zig build compiler-test (native Debug, -Dgc_stress=true, and
-Dheap_paranoia=true) all 993/993. Manually verified via the rebuilt
CLI: std.string.split (both separator forms), std.string.fields,
regexp find_all, and regexp split all produce correct output.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C3pMYWS2xy8zitUkpJaiZU1 parent bbd1ddb commit 12e6ebd
2 files changed
Lines changed: 65 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
560 | 560 | | |
561 | 561 | | |
562 | 562 | | |
563 | | - | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
564 | 573 | | |
565 | 574 | | |
566 | 575 | | |
567 | 576 | | |
568 | | - | |
569 | | - | |
| 577 | + | |
| 578 | + | |
570 | 579 | | |
571 | 580 | | |
572 | 581 | | |
| |||
629 | 638 | | |
630 | 639 | | |
631 | 640 | | |
632 | | - | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
633 | 647 | | |
634 | 648 | | |
635 | 649 | | |
636 | 650 | | |
637 | | - | |
638 | | - | |
| 651 | + | |
| 652 | + | |
639 | 653 | | |
640 | 654 | | |
641 | 655 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
41 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
42 | 54 | | |
43 | 55 | | |
44 | 56 | | |
| |||
48 | 60 | | |
49 | 61 | | |
50 | 62 | | |
51 | | - | |
| 63 | + | |
| 64 | + | |
52 | 65 | | |
53 | 66 | | |
54 | | - | |
55 | 67 | | |
56 | 68 | | |
57 | 69 | | |
58 | 70 | | |
59 | 71 | | |
60 | 72 | | |
61 | 73 | | |
62 | | - | |
| 74 | + | |
| 75 | + | |
63 | 76 | | |
64 | | - | |
65 | 77 | | |
66 | 78 | | |
67 | 79 | | |
68 | | - | |
| 80 | + | |
| 81 | + | |
69 | 82 | | |
70 | | - | |
71 | 83 | | |
72 | 84 | | |
73 | 85 | | |
| |||
270 | 282 | | |
271 | 283 | | |
272 | 284 | | |
273 | | - | |
274 | | - | |
275 | | - | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
276 | 291 | | |
277 | 292 | | |
278 | 293 | | |
| |||
285 | 300 | | |
286 | 301 | | |
287 | 302 | | |
288 | | - | |
| 303 | + | |
289 | 304 | | |
290 | | - | |
291 | 305 | | |
292 | | - | |
293 | 306 | | |
294 | 307 | | |
295 | 308 | | |
| |||
426 | 439 | | |
427 | 440 | | |
428 | 441 | | |
429 | | - | |
430 | | - | |
431 | | - | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
432 | 448 | | |
433 | 449 | | |
434 | 450 | | |
| |||
437 | 453 | | |
438 | 454 | | |
439 | 455 | | |
440 | | - | |
| 456 | + | |
441 | 457 | | |
442 | 458 | | |
443 | 459 | | |
444 | | - | |
445 | | - | |
| 460 | + | |
| 461 | + | |
446 | 462 | | |
447 | | - | |
| 463 | + | |
448 | 464 | | |
449 | | - | |
450 | | - | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
451 | 468 | | |
452 | 469 | | |
453 | 470 | | |
| |||
457 | 474 | | |
458 | 475 | | |
459 | 476 | | |
460 | | - | |
| 477 | + | |
| 478 | + | |
461 | 479 | | |
462 | 480 | | |
463 | | - | |
464 | 481 | | |
465 | 482 | | |
466 | | - | |
| 483 | + | |
| 484 | + | |
467 | 485 | | |
468 | | - | |
469 | 486 | | |
470 | 487 | | |
471 | 488 | | |
| |||
0 commit comments