Sync fork to upstream v0.91.1 (drop re-add GHA SHA pins, merge 353 upstream commits) - #6
Sync fork to upstream v0.91.1 (drop re-add GHA SHA pins, merge 353 upstream commits)#6ajbt200128 wants to merge 357 commits into
Conversation
this should result in lower overhead for single threaded situations such as lwt or eio.
for shutdown processes, it's really preferable to use level-triggered primitives rather than edge-triggered callbacks. Switch is fairly robust. It's named Aswitch here, "A" means atomic and is also used to avoid name collision with Eio. Util_atomic provides a convenience CAS loop, with backoff.
…metrics we can now know how big the batches we drop are
do not look for an ambient trace ID if parent is explicitly set to none!
in case of a program that forks worker subprocesses, eager initialization means each subprocess starts off with the same initialized state. Instead we do this lazily and each subprocess will get its own state.
This reverts commit 53199e3.
This reverts commit 669e426.
Brings in the 353 upstream commits since `refactor: move the Mutex.protect backport into `Util_mutex``, up to `prepare for 0.91.1`.
|
|
| let delete = ignore | ||
|
|
||
| let wait self ~should_keep_waiting = | ||
| Mutex.lock self.mutex; |
There was a problem hiding this comment.
Semgrep identified an issue in your code:
wait can leave self.mutex locked when the wait predicate or condition wait raises, causing subsequent callers to deadlock.
More details about this
wait acquires self.mutex with Mutex.lock and releases it only after the while should_keep_waiting () loop. If should_keep_waiting () or Condition.wait self.cond self.mutex raises an exception, execution skips Mutex.unlock self.mutex, leaving the mutex locked and potentially deadlocking every later caller that waits on this queue condition.
To resolve this comment:
✨ Commit fix suggestion
- Replace the manual lock/unlock sequence in
waitwithMutex.protect. - Move the loop into the protected function:
Mutex.protect self.mutex (fun () -> while should_keep_waiting () do Condition.wait self.cond self.mutex done). - Remove the separate
Mutex.unlock self.mutexcall.Mutex.protectreleasesself.mutexboth on normal completion and whenshould_keep_waitingorCondition.waitraises an exception.
💬 Ignore this finding
Reply with Semgrep commands to ignore this finding.
/fp <comment>for false positive/ar <comment>for acceptable risk/other <comment>for all other reasons
Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by mutex-lock-exn.
You can view more details about this finding in the Semgrep AppSec Platform.
| with e -> | ||
| let bt = Printexc.get_raw_backtrace () in | ||
| finally (Error (e, bt)); | ||
| raise e |
There was a problem hiding this comment.
Semgrep identified an issue in your code:
raise e discards the original backtrace captured for the exception from thunk (), so callers may see a misleading stack trace rooted in this handler.
More details about this
The with e -> handler correctly captures the exception’s raw backtrace in bt and passes it to finally (Error (e, bt)), but raise e then re-raises e without that backtrace. The caller therefore receives a stack trace rooted at this re-raise site rather than the original failure in thunk (), making the exception harder to diagnose and potentially hiding the operation that actually failed.
To resolve this comment:
✨ Commit fix suggestion
| raise e | |
| Printexc.raise_with_backtrace e bt |
View step-by-step instructions
- Keep capturing the raw backtrace immediately in the exception handler, before calling
finally. - Replace
raise ewithPrintexc.raise_with_backtrace e bt:with e -> let bt = Printexc.get_raw_backtrace () in finally (Error (e, bt)); Printexc.raise_with_backtrace e bt
- Preserve the existing
btvalue when reporting the error tofinally, so the exception is re-raised with its original stack trace.
💬 Ignore this finding
Reply with Semgrep commands to ignore this finding.
/fp <comment>for false positive/ar <comment>for acceptable risk/other <comment>for all other reasons
Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by bad-reraise.
You can view more details about this finding in the Semgrep AppSec Platform.
|
|
||
| let[@inline] sampled self = self.flags land (1 lsl Flags.sampled) != 0 | ||
|
|
||
| let[@inline] is_remote self = self.flags land (1 lsl Flags.remote) != 0 |
There was a problem hiding this comment.
Semgrep identified an issue in your code:
is_remote uses physical inequality for an integer bitmask check, which can misclassify whether the remote flag is set. The comparison should use structural integer semantics.
More details about this
is_remote uses OCaml’s physical inequality operator != when comparing the integer result of self.flags land (1 lsl Flags.remote) with 0. This check is intended to test the numeric value of the remote flag bit; using physical inequality makes the comparison depend on value representation rather than integer structure and can produce incorrect flag detection. The same comparison pattern also appears in sampled, so the flag-state checks are inconsistent with their intended numeric semantics.
To resolve this comment:
✨ Commit fix suggestion
- Replace the physical inequality operator
!=with the structural inequality operator<>inis_remote:
let[@inline] is_remote self = self.flags land (1 lsl Flags.remote) <> 0 - Verify that the comparison remains against the integer literal
0;<>correctly compares the computed integer value with zero.
💬 Ignore this finding
Reply with Semgrep commands to ignore this finding.
/fp <comment>for false positive/ar <comment>for acceptable risk/other <comment>for all other reasons
Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by physical-not-equal.
You can view more details about this finding in the Semgrep AppSec Platform.
| |} | ||
|
|
||
| let write_file file s = | ||
| let oc = open_out file in |
There was a problem hiding this comment.
Semgrep identified an issue in your code:
'open_out' behaves differently on Windows and on Unix-like systems with respect to line endings. To get the same behavior everywhere, use 'open_out_bin' or 'open_out_gen [Open_binary]'. If you really want LF-to-CRLF translations to take place when running on Windows, use 'open_out_gen [Open_text]'.
To resolve this comment:
🔧 No guidance has been designated for this issue. Fix according to your organization's approved methods.
💬 Ignore this finding
Reply with Semgrep commands to ignore this finding.
/fp <comment>for false positive/ar <comment>for acceptable risk/other <comment>for all other reasons
Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by prefer-write-in-binary-mode.
You can view more details about this finding in the Semgrep AppSec Platform.
| @@ -0,0 +1,23 @@ | |||
| let copy_file src dst = | |||
| let ic = open_in src in | |||
| let oc = open_out dst in | |||
There was a problem hiding this comment.
Semgrep identified an issue in your code:
'open_out' behaves differently on Windows and on Unix-like systems with respect to line endings. To get the same behavior everywhere, use 'open_out_bin' or 'open_out_gen [Open_binary]'. If you really want LF-to-CRLF translations to take place when running on Windows, use 'open_out_gen [Open_text]'.
To resolve this comment:
🔧 No guidance has been designated for this issue. Fix according to your organization's approved methods.
💬 Ignore this finding
Reply with Semgrep commands to ignore this finding.
/fp <comment>for false positive/ar <comment>for acceptable risk/other <comment>for all other reasons
Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by prefer-write-in-binary-mode.
You can view more details about this finding in the Semgrep AppSec Platform.
| @@ -0,0 +1,23 @@ | |||
| let copy_file src dst = | |||
| let ic = open_in src in | |||
There was a problem hiding this comment.
Semgrep identified an issue in your code:
'open_in' behaves differently on Windows and on Unix-like systems with respect to line endings. To get the same behavior everywhere, use 'open_in_bin' or 'open_in_gen [Open_binary]'. If you really want CRLF-to-LF translations to take place when running on Windows, use 'open_in_gen [Open_text]'.
To resolve this comment:
🔧 No guidance has been designated for this issue. Fix according to your organization's approved methods.
💬 Ignore this finding
Reply with Semgrep commands to ignore this finding.
/fp <comment>for false positive/ar <comment>for acceptable risk/other <comment>for all other reasons
Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by prefer-read-in-binary-mode.
You can view more details about this finding in the Semgrep AppSec Platform.
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 | ||
| - uses: actions/checkout@v6 |
There was a problem hiding this comment.
GitHub Actions step uses a mutable tag or branch reference. Tags and branch names can be silently repointed by the action owner, enabling supply-chain attacks — as seen in the trivy-action and kics-github-action compromises. Pin the reference to a full 40-character commit SHA instead, e.g. uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608.
🎈 Fixed in commit 7f34132 🎈
Restores SHA pinning on top of the upstream v0.91.1 sync, per Semgrep's org-wide policy. Kept as a separate commit on top of the merge so the next upstream sync can revert just this one instead of conflicting on every workflow file. Pins the versions upstream declares rather than bumping them: actions/checkout v6 -> d23441a4 # v6.1.0 peaceiris/actions-gh-pages v3 -> 373f7f26 # v3.9.3 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
this reverts leif's github sha pinning commits, pulls in upstream, then re-applies the sha pinning