# Test errors stage #yx6

**URL:** <https://forum.codecrafters.io/t/test-errors-stage-yx6/15346>\
**Category:** Challenges\
**Tags:** challenge:grep\
**Created:** [September 27, 2025, 8:05pm UTC](https://forum.codecrafters.io/t/test-errors-stage-yx6/15346 "2025-09-27T20:05:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![danilovict2](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/danilovict2/32/3024_2.png) [@danilovict2](https://forum.codecrafters.io/u/danilovict2)\
**Post date:** [September 27, 2025, 8:05pm UTC](https://forum.codecrafters.io/t/test-errors-stage-yx6/15346/1 "2025-09-27T20:05:51Z")

</div>

When I run tests for the stage #yx6 I get:

```bash
[tester::#YX6] Running tests for Stage #YX6 (File Search - Recursive search)
[tester::#YX6] [setup] echo "raspberry" > "dir/fruits-9393.txt"
[tester::#YX6] [setup] echo "pear" >> "dir/fruits-9393.txt"
[tester::#YX6] [setup] echo "carrot" > "dir/subdir/vegetables-8596.txt"
[tester::#YX6] [setup] echo "celery" >> "dir/subdir/vegetables-8596.txt"
[tester::#YX6] [setup] echo "cauliflower" >> "dir/subdir/vegetables-8596.txt"
[tester::#YX6] [setup] echo "peas" > "dir/vegetables-6093.txt"
[tester::#YX6] [setup] echo "carrot" >> "dir/vegetables-6093.txt"
[tester::#YX6] [setup] echo "cucumber" >> "dir/vegetables-6093.txt"
[tester::#YX6] $ ./your_program.sh -r -E .+er dir/
[your_program] thread 121 panic: reached unreachable code
[your_program] /usr/local/zig/lib/std/posix.zig:5244:18: 0x10f5b72 in lseek_SET (main)
[your_program] .BADF => unreachable, // always a race condition
[your_program] ^
[your_program] /usr/local/zig/lib/std/fs/Dir.zig:361:40: 0x10f031b in nextLinux (main)
[your_program] posix.lseek_SET(self.dir.fd, 0) catch unreachable; // EBADF here likely means that the Dir was not opened with iteration permissions
[your_program] ^
[your_program] /usr/local/zig/lib/std/fs/Dir.zig:345:34: 0x10e6847 in next (main)
[your_program] return self.nextLinux() catch |err| switch (err) {
[your_program] ^
[your_program] /usr/local/zig/lib/std/fs/Dir.zig:680:30: 0x10e5d20 in next (main)
[your_program] if (top.iter.next() catch |err| {
[your_program] ^
[your_program] /app/src/main.zig:48:27: 0x10eaf1c in recursiveSearch (main)
[your_program] while (try walker.next()) |entry| {
[your_program] ^
[your_program] /app/src/main.zig:25:42: 0x10ec954 in main (main)
[your_program] matched = try recursiveSearch(args[4], pattern, allocator);
[your_program] ^
[your_program] /usr/local/zig/lib/std/start.zig:656:37: 0x10e4afa in posixCallMainAndExit (main)
[your_program] const result = root.main() catch |err| {
[your_program] ^
[your_program] /usr/local/zig/lib/std/start.zig:271:5: 0x10e46ad in _start (main)
[your_program] asm volatile (switch (native_arch) {
[your_program] ^
[your_program] ???:?:?: 0x0 in ??? (???)
[tester::#YX6] Expected exit code 0, got 134
[tester::#YX6] Test failed (try setting 'debug: true' in your codecrafters.yml to see more details)

```

But when I run it on my machine, it works perfectly:

```bash
./your_program.sh -r -E .+er dir/
Text: carrot
Pattern: .+er
Starting Text: carrot
Current Text: carrot
One or More
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Starting Text: carrot
Starting Text: carrot
Current Text: t
Literal: e
Starting Text: carrot
Current Text: ot
Literal: e
Starting Text: carrot
Current Text: rot
Literal: e
Starting Text: carrot
Current Text: rrot
Literal: e
Starting Text: carrot
Current Text: arrot
Literal: e
Starting Text: carrot
Current Text: arrot
One or More
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Starting Text: carrot
Starting Text: carrot
Current Text: t
Literal: e
Starting Text: carrot
Current Text: ot
Literal: e
Starting Text: carrot
Current Text: rot
Literal: e
Starting Text: carrot
Current Text: rrot
Literal: e
Starting Text: carrot
Current Text: rrot
One or More
Wildcard
Wildcard
Wildcard
Wildcard
Starting Text: carrot
Starting Text: carrot
Current Text: t
Literal: e
Starting Text: carrot
Current Text: ot
Literal: e
Starting Text: carrot
Current Text: rot
Literal: e
Starting Text: carrot
Current Text: rot
One or More
Wildcard
Wildcard
Wildcard
Starting Text: carrot
Starting Text: carrot
Current Text: t
Literal: e
Starting Text: carrot
Current Text: ot
Literal: e
Starting Text: carrot
Current Text: ot
One or More
Wildcard
Wildcard
Starting Text: carrot
Starting Text: carrot
Current Text: t
Literal: e
Starting Text: carrot
Current Text: t
One or More
Wildcard
Starting Text: carrot
Text: celery
Pattern: .+er
Starting Text: celery
Current Text: celery
One or More
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Starting Text: celery
Starting Text: celery
Current Text: y
Literal: e
Starting Text: celery
Current Text: ry
Literal: e
Starting Text: celery
Current Text: ery
Literal: e
Current Text: ry
Literal: r
Text: cauliflower
Pattern: .+er
Starting Text: cauliflower
Current Text: cauliflower
One or More
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Starting Text: cauliflower
Starting Text: cauliflower
Current Text: r
Literal: e
Starting Text: cauliflower
Current Text: er
Literal: e
Current Text: r
Literal: r
Text:
Pattern: .+er
dir/subdir/vegetables-8596.txt:celery
cauliflower
Text: peas
Pattern: .+er
Starting Text: peas
Current Text: peas
One or More
Wildcard
Wildcard
Wildcard
Wildcard
Starting Text: peas
Starting Text: peas
Current Text: s
Literal: e
Starting Text: peas
Current Text: as
Literal: e
Starting Text: peas
Current Text: eas
Literal: e
Current Text: as
Literal: r
Starting Text: peas
Current Text: eas
One or More
Wildcard
Wildcard
Wildcard
Starting Text: peas
Starting Text: peas
Current Text: s
Literal: e
Starting Text: peas
Current Text: as
Literal: e
Starting Text: peas
Current Text: as
One or More
Wildcard
Wildcard
Starting Text: peas
Starting Text: peas
Current Text: s
Literal: e
Starting Text: peas
Current Text: s
One or More
Wildcard
Starting Text: peas
Text: carrot
Pattern: .+er
Starting Text: carrot
Current Text: carrot
One or More
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Starting Text: carrot
Starting Text: carrot
Current Text: t
Literal: e
Starting Text: carrot
Current Text: ot
Literal: e
Starting Text: carrot
Current Text: rot
Literal: e
Starting Text: carrot
Current Text: rrot
Literal: e
Starting Text: carrot
Current Text: arrot
Literal: e
Starting Text: carrot
Current Text: arrot
One or More
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Starting Text: carrot
Starting Text: carrot
Current Text: t
Literal: e
Starting Text: carrot
Current Text: ot
Literal: e
Starting Text: carrot
Current Text: rot
Literal: e
Starting Text: carrot
Current Text: rrot
Literal: e
Starting Text: carrot
Current Text: rrot
One or More
Wildcard
Wildcard
Wildcard
Wildcard
Starting Text: carrot
Starting Text: carrot
Current Text: t
Literal: e
Starting Text: carrot
Current Text: ot
Literal: e
Starting Text: carrot
Current Text: rot
Literal: e
Starting Text: carrot
Current Text: rot
One or More
Wildcard
Wildcard
Wildcard
Starting Text: carrot
Starting Text: carrot
Current Text: t
Literal: e
Starting Text: carrot
Current Text: ot
Literal: e
Starting Text: carrot
Current Text: ot
One or More
Wildcard
Wildcard
Starting Text: carrot
Starting Text: carrot
Current Text: t
Literal: e
Starting Text: carrot
Current Text: t
One or More
Wildcard
Starting Text: carrot
Text: cucumber
Pattern: .+er
Starting Text: cucumber
Current Text: cucumber
One or More
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Starting Text: cucumber
Starting Text: cucumber
Current Text: r
Literal: e
Starting Text: cucumber
Current Text: er
Literal: e
Current Text: r
Literal: r
Text:
Pattern: .+er
dir/vegetables-6093.txt:cucumber
Text: raspberry
Pattern: .+er
Starting Text: raspberry
Current Text: raspberry
One or More
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Wildcard
Starting Text: raspberry
Starting Text: raspberry
Current Text: y
Literal: e
Starting Text: raspberry
Current Text: ry
Literal: e
Starting Text: raspberry
Current Text: rry
Literal: e
Starting Text: raspberry
Current Text: erry
Literal: e
Current Text: rry
Literal: r
Text: pear
Pattern: .+er
Starting Text: pear
Current Text: pear
One or More
Wildcard
Wildcard
Wildcard
Wildcard
Starting Text: pear
Starting Text: pear
Current Text: r
Literal: e
Starting Text: pear
Current Text: ar
Literal: e
Starting Text: pear
Current Text: ear
Literal: e
Current Text: ar
Literal: r
Starting Text: pear
Current Text: ear
One or More
Wildcard
Wildcard
Wildcard
Starting Text: pear
Starting Text: pear
Current Text: r
Literal: e
Starting Text: pear
Current Text: ar
Literal: e
Starting Text: pear
Current Text: ar
One or More
Wildcard
Wildcard
Starting Text: pear
Starting Text: pear
Current Text: r
Literal: e
Starting Text: pear
Current Text: r
One or More
Wildcard
Starting Text: pear
Text:
Pattern: .+er
dir/fruits-9393.txt:raspberry
Match

```

My code is here: [GitHub - danilovict2/z-grep](https://github.com/danilovict2/z-grep)

---

<div class="post-metadata">

**Author:** ![danilovict2](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/danilovict2/32/3024_2.png) [@danilovict2](https://forum.codecrafters.io/u/danilovict2)\
**Post date:** [October 5, 2025, 1:35am UTC](https://forum.codecrafters.io/t/test-errors-stage-yx6/15346/4 "2025-10-05T01:35:56Z")

</div>

I’m still having this issue and it’s just annoying because I can’t pass the last stage.

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [November 10, 2025, 7:28am UTC](https://forum.codecrafters.io/t/test-errors-stage-yx6/15346/5 "2025-11-10T07:28:03Z")

</div>

Hey @danilovict2, setting `.iterate = true` should resolve the issue.

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/a/4/a41d6e9fc01fe0530d782cce4616d455dddb2f7a.png)

> <https://github.com/ziglang/zig/blob/c58687225ba961c94b069f5bea3036267b80ebc6/lib/std/Io/Dir.zig#L94>

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [November 16, 2025, 1:40pm UTC](https://forum.codecrafters.io/t/test-errors-stage-yx6/15346/7 "2025-11-16T13:40:53Z")

</div>

Closing this thread due to inactivity. If you still need assistance, feel free to reopen or start a new discussion!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [November 21, 2025, 1:40pm UTC](https://forum.codecrafters.io/t/test-errors-stage-yx6/15346/8 "2025-11-21T13:40:58Z")

</div>

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.
