| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Expand Up | @@ -140,10 +140,10 @@ impl CompilationSource { | |||||||||||||||||||||||||||||
| let mut code_map = HashMap::new(); | ||||||||||||||||||||||||||||||
| let paths = fs::read_dir(path) | ||||||||||||||||||||||||||||||
| .or_else(|e| { | ||||||||||||||||||||||||||||||
| if cfg!(windows) { | ||||||||||||||||||||||||||||||
| if let Ok(real_path) = fs::read_to_string(path.canonicalize().unwrap()) { | ||||||||||||||||||||||||||||||
| return fs::read_dir(real_path.trim()); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| if cfg!(windows) | ||||||||||||||||||||||||||||||
| && let Ok(real_path) = fs::read_to_string(path.canonicalize().unwrap()) | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| return fs::read_dir(real_path.trim()); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
Comment thread
Comment on lines
+143
to
147
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality🛠️ Refactor suggestion Avoid panic in error-fallback path (unwrap in or_else) path.canonicalize().unwrap() can panic while handling an error; keep this path panic-free. - .or_else(|e| {
- if cfg!(windows)
- && let Ok(real_path) = fs::read_to_string(path.canonicalize().unwrap())
- {
- return fs::read_dir(real_path.trim());
- }
- Err(e)
- })
+ .or_else(|e| {
+ if cfg!(windows)
+ && let Ok(canonical) = path.canonicalize()
+ && let Ok(real_path) = fs::read_to_string(&canonical)
+ {
+ return fs::read_dir(real_path.trim());
+ }
+ Err(e)
+ })
Suggested change
In derive-impl/src/compile_bytecode.rs around lines 143-147, the error-fallback
path uses path.canonicalize().unwrap() which can panic; replace the unwrap with
safe error handling by first attempting canonicalize and only proceeding if it
succeeds (e.g., if let Ok(canonical) = path.canonicalize() { if let
Ok(real_path) = fs::read_to_string(&canonical) { return
fs::read_dir(real_path.trim()); } } ), so both canonicalize and read_to_string
are checked for Ok before calling read_dir, keeping the fallback panic-free.
Sorry, something went wrong.
All reactions
|
||||||||||||||||||||||||||||||
| Err(e) | ||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||
| Expand Down Expand Up | @@ -195,14 +195,14 @@ impl CompilationSource { | |||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||
| let code = compile_path(&path).or_else(|e| { | ||||||||||||||||||||||||||||||
| if cfg!(windows) { | ||||||||||||||||||||||||||||||
| if let Ok(real_path) = fs::read_to_string(path.canonicalize().unwrap()) { | ||||||||||||||||||||||||||||||
| let joined = path.parent().unwrap().join(real_path.trim()); | ||||||||||||||||||||||||||||||
| if joined.exists() { | ||||||||||||||||||||||||||||||
| return compile_path(&joined); | ||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||
| return Err(e); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| if cfg!(windows) | ||||||||||||||||||||||||||||||
| && let Ok(real_path) = fs::read_to_string(path.canonicalize().unwrap()) | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| let joined = path.parent().unwrap().join(real_path.trim()); | ||||||||||||||||||||||||||||||
| if joined.exists() { | ||||||||||||||||||||||||||||||
| return compile_path(&joined); | ||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||
| return Err(e); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| Err(e) | ||||||||||||||||||||||||||||||
| Expand Down | ||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -378,12 +378,11 @@ mod _contextvars { | |
| let ctx = ctxs.last()?; | ||
| let cached_ptr = zelf.cached.as_ptr(); | ||
| debug_assert!(!cached_ptr.is_null()); | ||
| if let Some(cached) = unsafe { &*cached_ptr } { | ||
| if zelf.cached_id.load(Ordering::SeqCst) == ctx.get_id() | ||
| && cached.idx + 1 == ctxs.len() | ||
| { | ||
| return Some(cached.object.clone()); | ||
| } | ||
| if let Some(cached) = unsafe { &*cached_ptr } | ||
| && zelf.cached_id.load(Ordering::SeqCst) == ctx.get_id() | ||
| && cached.idx + 1 == ctxs.len() | ||
| { | ||
| return Some(cached.object.clone()); | ||
|
Comment thread
Comment on lines
+381
to
+385
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality⚠️ Potential issue Potential UB: dereferencing AtomicCell::as_ptr without synchronization. Reading unsafe { &*cached_ptr } races with concurrent store/swap on cached, risking undefined behavior. This preexisted the refactor, but the let-chain keeps the hazard. Consider replacing cached: AtomicCell<Option<ContextVarCache>> with a synchronization primitive suited for non-Copy data:
If keeping AtomicCell, you need a design that avoids borrowing through as_ptr (e.g., store Arc<ContextVarCache> and atomically swap/load the Arc). I can open an issue and sketch a safe refactor using ArcSwapOption if you’d like. 🤖 Prompt for AI AgentsIn stdlib/src/contextvars.rs around lines 381-385 the code unsafely dereferences cached_ptr from AtomicCell::as_ptr which races with concurrent store/swap and can produce UB; fix by replacing the AtomicCell<Option<ContextVarCache>> with a synchronization primitive that supports safe non-Copy data (either RwLock<Option<ContextVarCache>> for a simple fix, or arc-swap’s ArcSwapOption<ContextVarCache> for lock-free reads). Update all reads to use a read lock or ArcSwapOption::load (and clone the Arc) instead of dereferencing raw pointers; alternatively, if you must keep AtomicCell, change it to store Arc<ContextVarCache> and atomically swap/load Arcs and never borrow through as_ptr. Ensure all unsafe derefs are removed and replace with safe load/clone or read-guard access.
Sorry, something went wrong.
All reactions
|
||
| } | ||
| let vars = ctx.borrow_vars(); | ||
| let obj = vars.get(zelf)?; | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Expand Up | @@ -86,23 +86,22 @@ mod _scproxy { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .and_then(|v| v.downcast::<CFNumber>()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .and_then(|v| v.to_i32()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .unwrap_or(0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if enabled { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if let Some(host) = proxy_dict | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if enabled | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| && let Some(host) = proxy_dict | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .find(host_key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .and_then(|v| v.downcast::<CFString>()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let h = std::borrow::Cow::<str>::from(&host); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let v = if let Some(port) = proxy_dict | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .find(port_key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .and_then(|v| v.downcast::<CFNumber>()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .and_then(|v| v.to_i32()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let h = std::borrow::Cow::<str>::from(&host); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let v = if let Some(port) = proxy_dict | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .find(port_key) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .and_then(|v| v.downcast::<CFNumber>()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .and_then(|v| v.to_i32()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| format!("http://{h}:{port}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| format!("http://{h}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| result.set_item(proto, vm.new_pyobj(v), vm)?; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| format!("http://{h}:{port}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| format!("http://{h}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| result.set_item(proto, vm.new_pyobj(v), vm)?; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment thread
Comment on lines
+94
to
+104
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality🛠️ Refactor suggestion ⚠️ Potential issue Cow from CFString won’t compile; build the String explicitly CFString doesn’t coerce to &str, so Cow::<str>::from(&host) is invalid on macOS builds. Convert to String (or format host directly) and avoid the extra Cow. Apply: - let h = std::borrow::Cow::<str>::from(&host);
- let v = if let Some(port) = proxy_dict
+ let host_s = host.to_string();
+ let proxy_url = if let Some(port) = proxy_dict
.find(port_key)
.and_then(|v| v.downcast::<CFNumber>())
.and_then(|v| v.to_i32())
{
- format!("http://{h}:{port}")
+ format!("http://{host_s}:{port}")
} else {
- format!("http://{h}")
+ format!("http://{host_s}")
};
- result.set_item(proto, vm.new_pyobj(v), vm)?;
+ result.set_item(proto, vm.new_pyobj(proxy_url), vm)?;
Suggested change
In stdlib/src/scproxy.rs around lines 94 to 104, the code uses
Cow::<str>::from(&host) where host is a CFString-derived value; CFString doesn't
coerce to &str so that conversion fails to compile. Replace the Cow usage by
constructing an owned String from host (e.g. host.to_string() or format!("{}",
host)) and use that String when formatting the URL (or interpolate host directly
into format! calls) so the code produces an owned Rust String before calling
vm.new_pyobj(v).
Sorry, something went wrong.
All reactions
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Ok(()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Expand Down | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality💡 Verification agent
🧩 Analysis chainMSRV bump to 1.89.0: verify CI/toolchain/docs match
Looks good for enabling let-chain guards. Please ensure CI images, rust-toolchain files, and any MSRV docs are updated accordingly across the workspace.
Run to spot divergences:
🏁 Script executed:
Length of output: 918
🏁 Script executed:
Length of output: 204
Pin the workspace toolchain to 1.89.0
🤖 Prompt for AI Agentsrust-toolchain.toml still reads channel = "stable"—update it to channel = "1.89.0" (and ensure your CI images reference that exact version). No MSRV references were found in README.md or a docs/ directory.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.