Infrequent printing concurrency bug
Maintainers usually reply within 1 day
@maciejpirog is already working on this.
Since Aug 12, 2025.
Assessment
This issue has not been assessed yet.
Description
Describe the bug
Printing is not thread-safe. Relevant once #123 is merged.
To Reproduce
# run this command in a loop until error with some rule, in the opengrep repo:
#
# opengrep-cli --experimental --timeout 5 --max-memory 5000 -j 8 -c <some-rule>.yaml src/ libs/
$ n=0; while time opengrep-cli scan --experimental --timeout 5 --max-memory 5000 -j 8 -c <some-rule>.yaml src/ libs/ 2> >(tee /dev/stderr | grep -q "ERROR" && exit 1); do ((n++)); done; echo "failed after $((n+1)) attempts"
[01.62][ERROR]: Error: exception Invalid_argument: String.sub / Bytes.sub
Raised at Stdlib.invalid_arg in file "stdlib.ml", line 30, characters 20-45
Called from Stdlib__String.sub in file "string.ml" (inlined), line 43, characters 2-23
Called from Str.string_after in file "str.ml" (inlined), line 24, characters 23-59
Called from Matches_report.cut in file "src/osemgrep/reporting/Matches_report.ml", line 176, characters 4-27
Called from Matches_report.pp_finding.(fun) in file "src/osemgrep/reporting/Matches_report.ml", line 244, characters 25-55
Called from Stdlib__List.fold_left in file "list.ml", line 123, characters 24-34
Called from Matches_report.pp_finding in file "src/osemgrep/reporting/Matches_report.ml", lines 198-250, characters 4-28
Called from Matches_report.pp_text_outputs.print_one_match in file "src/osemgrep/reporting/Matches_report.ml", lines 379-381, characters 4-13
Called from List_.iter_with_view_into_neighbor_elements.loop in file "libs/commons/List_.ml", line 134, characters 8-28
Called from Stdlib__List.iter in file "list.ml", line 112, characters 12-15
Called from Output.output_result in file "src/osemgrep/reporting/Output.ml", line 253, characters 2-71
Called from Scan_subcommand.check_targets_with_rules in file "src/osemgrep/cli_scan/Scan_subcommand.ml", lines 660-663, characters 12-41
Called from Scan_subcommand.run_scan_conf in file "src/osemgrep/cli_scan/Scan_subcommand.ml", lines 805-813, characters 8-61
Called from CLI.dispatch_subcommand in file "src/osemgrep/cli/CLI.ml", line 196, characters 20-57
Called from CLI.safe_run in file "src/osemgrep/cli/CLI.ml", line 228, characters 8-12
opengrep-cli --experimental --timeout 5 --max-memory 5000 -j 8 -c ... src/ libs/ 5.03s user 1.28s system 382% cpu 1.650 total
failed after 5101 attempts
What is the priority of the bug to you?
- P0: blocking your adoption of Opengrep or workflow
- P1: important to fix or quite annoying
- P2: regular bug that should get fixed
- Dominant language
- OCaml
- Stars
- 3.2k
- Forks
- 272
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 29
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from opengrep/opengrep
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Support Containerfile alongside DockerfilePossibly taken @maciejpirog claimed this 2 days ago. Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opengrep/opengrep#953 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 56/100
Maintainers usually reply within 1 day
-
Proxy credentials in HTTPS_PROXY are not sent, rule downloads fail with 407 since 2.0.0Possibly taken @dimitris-m claimed this 1 day ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 68/100
opengrep/opengrep#954 · 1 assignee ·
Maintainers usually reply within 1 day
-
YAML validation in 2.x.x is too strict - rejects top x-* keysPossibly taken @dimitris-m claimed this 4 days ago. Openbug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
opengrep/opengrep#952 · 1 assignee ·
Maintainers usually reply within 1 day