helloadhavan/github_issues huggingface dataset:
Repository: nodejs/node
Pull request: deps: fixup some minor coverity warnings

Fixes: https://github.com/nodejs/node/issues/56611


Changed files:
filename: deps/ncrypto/ncrypto.cc
patch: @@ -1346,8 +1346,11 @@ DHPointer DHPointer::New(BignumPointer&& p, BignumPointer&& g) {
   if (DH_set0_pqg(dh.get(), p.get(), nullptr, g.get()) != 1) return {};
 
   // If the call above is successful, the DH object takes ownership of the
-  // BIGNUMs, so we must release them here.
+  // BIGNUMs, so we must release them here. Unfortunately coverity does not
+  // know that so we need to tell it not to complain.
+  // coverity[resource_leak]
   p.release();
+  // coverity[resource_leak]
   g.release();
 
   return dh;
@@ -1430,7 +1433,10 @@ DataPointer DHPointer::generateKeys() const {
 
 size_t DHPointer::size() const {
   if (!dh_) return 0;
-  return DH_size(dh_.get());
+  int ret = DH_size(dh_.get());
+  // DH_size can return a -1 on error but we just want to return a 0
+  // in that case so we don't wrap around when returning the size_t.
+  return ret >= 0 ? static_cast<size_t>(ret) : 0;
 }
 
 DataPointer DHPointer::computeSecret(const BignumPointer& peer) const {
@@ -1459,6 +1465,10 @@ DataPointer DHPointer::computeSecret(const BignumPointer& peer) const {
 bool DHPointer::setPublicKey(BignumPointer&& key) {
   if (!dh_) return false;
   if (DH_set0_key(dh_.get(), key.get(), nullptr) == 1) {
+    // If DH_set0_key returns successfully, then dh_ takes ownership of the
+    // BIGNUM, so we must release it here. Unfortunately coverity does not
+    // know that so we need to tell it not to complain.
+    // coverity[resource_leak]
     key.release();
     return true;
   }
@@ -1468,6 +1478,10 @@ bool DHPointer::setPublicKey(BignumPointer&& key) {
 bool DHPointer::setPrivateKey(BignumPointer&& key) {
   if (!dh_) return false;
   if (DH_set0_key(dh_.get(), nullptr, key.get()) == 1) {
+    // If DH_set0_key returns successfully, then dh_ takes ownership of the
+    // BIGNUM, so we must release it here. Unfortunately coverity does not
+    // know that so we need to tell it not to complain.
+    // coverity[resource_leak]
     key.release();
     return true;
   }
Repository: ggml-org/llama.cpp
Pull request: ggml : allow CUDA graphs when using pipeline parallelism

Due to changes in the graph in each evaluation when pipeline parallelism is enabled, CUDA graphs could not be used. This change ensures that during generation the graphs will not change, allowing the use of CUDA graphs when pipeline parallelism is enabled.

Fixes #13751

Changed files:
filename: ggml/src/ggml-backend.cpp
patch: @@ -1598,6 +1598,9 @@ void ggml_backend_sched_synchronize(ggml_backend_sched_t sched) {
     for (int i = 0; i < sched->n_backends; i++) {
         ggml_backend_synchronize(sched->backends[i]);
     }
+    // reset the current copy to 0 so that the graphs will be similar during generation
+    // necessary for CUDA graphs
+    sched->cur_copy = 0;
 }
 
 void ggml_backend_sched_set_eval_callback(ggml_backend_sched_t sched, ggml_backend_sched_eval_callback callback, void * user_data) {
Repository: huggingface/transformers
Pull request: Fix `Optional` typing

# What does this PR do?

Make style CI green again

cc @ydshieh 

Changed files:
filename: src/transformers/models/beit/image_processing_beit_fast.py
patch: @@ -237,7 +237,7 @@ def preprocess(
 
         return BatchFeature(data=data)
 
-    def post_process_semantic_segmentation(self, outputs, target_sizes: List[Tuple] = None):
+    def post_process_semantic_segmentation(self, outputs, target_sizes: Optional[List[Tuple]] = None):
         """
         Converts the output of [`BeitForSemanticSegmentation`] into semantic segmentation maps. Only supports PyTorch.
 

filename: src/transformers/models/paligemma/modeling_paligemma.py
patch: @@ -275,7 +275,7 @@ def _update_causal_mask(
         past_key_values=None,
         cache_position=None,
         input_tensor=None,
-        is_training: bool = None,
+        is_training: Optional[bool] = None,
     ):
         if self.config.text_config._attn_implementation == "flash_attention_2":
             if attention_mask is not None and 0.0 in attention_mask:
Repository: vercel/next.js
Pull request: Turbopack: Make `turbo-tasks-env` crate Rust 2024

Wrapped env setting in `unsafe` blocks.


Closes PACK-4596

Changed files:
filename: turbopack/crates/turbo-tasks-env/Cargo.toml
patch: @@ -3,7 +3,7 @@ name = "turbo-tasks-env"
 version = "0.1.0"
 description = "TBD"
 license = "MIT"
-edition = "2021"
+edition = "2024"
 
 [lib]
 bench = false

filename: turbopack/crates/turbo-tasks-env/src/command_line.rs
patch: @@ -1,7 +1,7 @@
 use turbo_rcstr::RcStr;
-use turbo_tasks::{mark_session_dependent, FxIndexMap, Vc};
+use turbo_tasks::{FxIndexMap, Vc, mark_session_dependent};
 
-use crate::{sorted_env_vars, EnvMap, ProcessEnv, GLOBAL_ENV_LOCK};
+use crate::{EnvMap, GLOBAL_ENV_LOCK, ProcessEnv, sorted_env_vars};
 
 /// Load the environment variables defined via command line.
 #[turbo_tasks::value]

filename: turbopack/crates/turbo-tasks-env/src/custom.rs
patch: @@ -2,7 +2,7 @@ use anyhow::Result;
 use turbo_rcstr::RcStr;
 use turbo_tasks::{ResolvedVc, Vc};
 
-use crate::{case_insensitive_read, EnvMap, ProcessEnv};
+use crate::{EnvMap, ProcessEnv, case_insensitive_read};
 
 /// Allows providing any custom env values that you'd like, deferring the prior
 /// envs if a key is not overridden.

filename: turbopack/crates/turbo-tasks-env/src/dotenv.rs
patch: @@ -1,11 +1,11 @@
 use std::{env, sync::MutexGuard};
 
-use anyhow::{anyhow, Context, Result};
+use anyhow::{Context, Result, anyhow};
 use turbo_rcstr::RcStr;
 use turbo_tasks::{FxIndexMap, ReadRef, ResolvedVc, ValueToString, Vc};
 use turbo_tasks_fs::{FileContent, FileSystemPath};
 
-use crate::{sorted_env_vars, EnvMap, ProcessEnv, GLOBAL_ENV_LOCK};
+use crate::{EnvMap, GLOBAL_ENV_LOCK, ProcessEnv, sorted_env_vars};
 
 /// Load the environment variables defined via a dotenv file, with an
 /// optional prior state that we can lookup already defined variables
@@ -95,13 +95,13 @@ fn restore_env(
 ) {
     for key in from.keys() {
         if !to.contains_key(key) {
-            env::remove_var(key);
+            unsafe { env::remove_var(key) };
         }
     }
     for (key, value) in to {
         match from.get(key) {
             Some(v) if v == value => {}
-            _ => env::set_var(key, value),
+            _ => unsafe { env::set_var(key, value) },
         }
     }
 }
Repository: ggml-org/llama.cpp
Pull request: model: minicpm should use llm_build_granite


Changed files:
filename: src/llama-model.cpp
patch: @@ -13260,7 +13260,6 @@ llm_graph_result_ptr llama_model::build_graph(
 
     switch (arch) {
         case LLM_ARCH_LLAMA:
-        case LLM_ARCH_MINICPM:
             {
                 llm = std::make_unique<llm_build_llama>(*this, params, gf);
             } break;
@@ -13501,6 +13500,7 @@ llm_graph_result_ptr llama_model::build_graph(
             } break;
         case LLM_ARCH_GRANITE:
         case LLM_ARCH_GRANITE_MOE:
+        case LLM_ARCH_MINICPM:
             {
                 llm = std::make_unique<llm_build_granite>(*this, params, gf);
             } break;
Repository: nodejs/node
Pull request: src: initialize FSReqWrapSync in path that uses it

The goal is to fix this error reported by Coverity:

![image](https://github.com/user-attachments/assets/4a4bf96d-1be0-41d0-b2bd-9929f6248b07)


Changed files:
filename: src/node_file.cc
patch: @@ -2482,7 +2482,6 @@ static void WriteString(const FunctionCallbackInfo<Value>& args) {
     }
   } else {  // write(fd, string, pos, enc, undefined, ctx)
     CHECK_EQ(argc, 6);
-    FSReqWrapSync req_wrap_sync;
     FSReqBase::FSReqBuffer stack_buffer;
     if (buf == nullptr) {
       if (!StringBytes::StorageSize(isolate, value, enc).To(&len))
@@ -2496,6 +2495,7 @@ static void WriteString(const FunctionCallbackInfo<Value>& args) {
       buf = *stack_buffer;
     }
     uv_buf_t uvbuf = uv_buf_init(buf, len);
+    FSReqWrapSync req_wrap_sync("write");
     FS_SYNC_TRACE_BEGIN(write);
     int bytesWritten = SyncCall(env, args[5], &req_wrap_sync, "write",
                                 uv_fs_write, fd, &uvbuf, 1, pos);
Repository: electron/electron
Pull request: fix: close all open sheets before closing window on macOS

Backport of #43706

See that PR for details.


Notes: Fixed closing a window with more than one attached sheet on macOS.

Changed files:
filename: shell/browser/native_window_mac.mm
patch: @@ -352,8 +352,11 @@ static bool FromV8(v8::Isolate* isolate,
   // [window_ performClose:nil], the window won't close properly
   // even after the user has ended the sheet.
   // Ensure it's closed before calling [window_ performClose:nil].
-  if ([window_ attachedSheet])
+  // If multiple sheets are open, they must all be closed.
+  while ([window_ attachedSheet]) {
     [window_ endSheet:[window_ attachedSheet]];
+  }
+  DCHECK_EQ([[window_ sheets] count], 0UL);
 
   // window_ could be nil after performClose.
   bool should_notify = is_modal() && parent() && IsVisible();

filename: spec/api-browser-window-spec.ts
patch: @@ -116,6 +116,14 @@ describe('BrowserWindow module', () => {
       await closed;
     });
 
+    it('should work if called when multiple messageBoxes are showing', async () => {
+      const closed = once(w, 'closed');
+      dialog.showMessageBox(w, { message: 'Hello Error' });
+      dialog.showMessageBox(w, { message: 'Hello Error' });
+      w.close();
+      await closed;
+    });
+
     it('closes window without rounded corners', async () => {
       await closeWindow(w);
       w = new BrowserWindow({ show: false, frame: false, roundedCorners: false });
Repository: denoland/deno
Pull request: fix(ext/node): add `vm.constants`


Changed files:
filename: ext/node/polyfills/vm.js
patch: @@ -27,7 +27,7 @@ import { ERR_INVALID_ARG_TYPE } from "ext:deno_node/internal/errors.ts";
 
 import { primordials } from "ext:core/mod.js";
 
-const { Symbol, ArrayPrototypeForEach } = primordials;
+const { Symbol, ArrayPrototypeForEach, ObjectFreeze } = primordials;
 
 const kParsingContext = Symbol("script parsing context");
 
@@ -349,8 +349,22 @@ export function measureMemory(_options) {
   notImplemented("measureMemory");
 }
 
+const USE_MAIN_CONTEXT_DEFAULT_LOADER = Symbol(
+  "USE_MAIN_CONTEXT_DEFAULT_LOADER",
+);
+const DONT_CONTEXTIFY = Symbol("DONT_CONTEXTIFY");
+
+export const constants = {
+  __proto__: null,
+  USE_MAIN_CONTEXT_DEFAULT_LOADER,
+  DONT_CONTEXTIFY,
+};
+
+ObjectFreeze(constants);
+
 export default {
   Script,
+  constants,
   createContext,
   createScript,
   runInContext,
Repository: vercel/next.js
Pull request: Turbopack: Make `turbo-tasks-malloc` crate Rust 2024

Wrapped env setting in `unsafe` blocks. The calling functions were already `unsafe`.


Closes PACK-4601

Changed files:
filename: turbopack/crates/turbo-tasks-malloc/Cargo.toml
patch: @@ -3,7 +3,7 @@ name = "turbo-tasks-malloc"
 version = "0.1.0"
 description = "A wrapper around mimalloc or the system allocator that tracks allocations"
 license = "MIT"
-edition = "2021"
+edition = "2024"
 autobenches = false
 
 [lib]

filename: turbopack/crates/turbo-tasks-malloc/src/lib.rs
patch: @@ -84,28 +84,28 @@ fn base_alloc() -> &'static impl GlobalAlloc {
 
 unsafe impl GlobalAlloc for TurboMalloc {
     unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
-        let ret = base_alloc().alloc(layout);
+        let ret = unsafe { base_alloc().alloc(layout) };
         if !ret.is_null() {
             add(layout.size());
         }
         ret
     }
 
     unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
-        base_alloc().dealloc(ptr, layout);
+        unsafe { base_alloc().dealloc(ptr, layout) };
         remove(layout.size());
     }
 
     unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
-        let ret = base_alloc().alloc_zeroed(layout);
+        let ret = unsafe { base_alloc().alloc_zeroed(layout) };
         if !ret.is_null() {
             add(layout.size());
         }
         ret
     }
 
     unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
-        let ret = base_alloc().realloc(ptr, layout, new_size);
+        let ret = unsafe { base_alloc().realloc(ptr, layout, new_size) };
         if !ret.is_null() {
             let old_size = layout.size();
             update(old_size, new_size);
Repository: denoland/deno
Pull request: fix(ext/node): export `process.allowedNodeEnvironmentFlags`


Changed files:
filename: ext/node/polyfills/process.ts
patch: @@ -748,6 +748,8 @@ Object.defineProperty(Process.prototype, "allowedNodeEnvironmentFlags", {
   },
 });
 
+export const allowedNodeEnvironmentFlags = ALLOWED_FLAGS;
+
 Process.prototype.features = { inspector: false };
 
 // TODO(kt3k): Get the value from --no-deprecation flag.
Repository: nodejs/node
Pull request: child_process: fix parsing messages with splitted length field

Fixes: https://github.com/nodejs/node/issues/55834


Changed files:
filename: lib/internal/child_process/serialization.js
patch: @@ -61,7 +61,12 @@ const advanced = {
   *parseChannelMessages(channel, readData) {
     if (readData.length === 0) return;
 
-    ArrayPrototypePush(channel[kMessageBuffer], readData);
+    if (channel[kMessageBufferSize] && channel[kMessageBuffer][0].length < 4) {
+      // Message length split into two buffers, so let's concatenate it.
+      channel[kMessageBuffer][0] = Buffer.concat([channel[kMessageBuffer][0], readData]);
+    } else {
+      ArrayPrototypePush(channel[kMessageBuffer], readData);
+    }
     channel[kMessageBufferSize] += readData.length;
 
     // Index 0 should always be present because we just pushed data into it.

filename: test/parallel/test-child-process-advanced-serialization-splitted-length-field.js
patch: @@ -0,0 +1,24 @@
+'use strict';
+const common = require('../common');
+const child_process = require('child_process');
+
+// Regression test for https://github.com/nodejs/node/issues/55834
+const msgLen = 65521;
+let cnt = 10;
+
+if (process.argv[2] === 'child') {
+  const msg = Buffer.allocUnsafe(msgLen);
+  (function send() {
+    if (cnt--) {
+      process.send(msg, send);
+    } else {
+      process.disconnect();
+    }
+  })();
+} else {
+  const child = child_process.spawn(process.execPath, [__filename, 'child'], {
+    stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
+    serialization: 'advanced'
+  });
+  child.on('message', common.mustCall(cnt));
+}
Repository: electron/electron
Pull request: fix: close all open sheets before closing window on macOS

#### Description of Change

<!--
Thank you for your Pull Request. Please provide a description above and review
the requirements below.

Contributors guide: https://github.com/electron/electron/blob/main/CONTRIBUTING.md
-->

On macOS, if there are multiple "sheets" (e.g. dialogs or modals) attached to a window and `close()` is called, the top sheet is closed, but the others remain open and the window is not closed. This PR fixes the issue by looping to close all attached sheets.

An example reproduction is included below, and this PR adds a test to avoid future breakage.

```javascript
import { app, dialog, BrowserWindow } from "electron";
app.whenReady().then(() => {
  const win = new BrowserWindow();
  dialog.showMessageBox(win, { message: "Test", buttons: ["OK"] });
  dialog.showMessageBox(win, { message: "Test", buttons: ["OK"] });
  setTimeout(() => win.close(), 1000);
});
```

#### Checklist
<!-- Remove items that do not apply. For completed items, change [ ] to [x]. -->

- [x] PR description included and stakeholders cc'd
- [ ] `npm test` passes
   - Some of the tests failed when I ran them locally. However, all the `BrowserWindow.close()` tests pass, and all the tests which failed with this change applied also failed when I built directly from `main`. This is likely just some oddity of my setup.
- [x] tests are [changed or added](https://github.com/electron/electron/blob/main/docs/development/testing.md)
- [x] [PR release notes](https://github.com/electron/clerk/blob/main/README.md) describe the change in a way relevant to app developers, and are [capitalized, punctuated, and past tense](https://github.com/electron/clerk/blob/main/README.md#examples).

#### Release Notes

Notes: Fixed closing a window with more than one attached sheet on macOS.

Changed files:
filename: shell/browser/native_window_mac.mm
patch: @@ -352,8 +352,11 @@ static bool FromV8(v8::Isolate* isolate,
   // [window_ performClose:nil], the window won't close properly
   // even after the user has ended the sheet.
   // Ensure it's closed before calling [window_ performClose:nil].
-  if ([window_ attachedSheet])
+  // If multiple sheets are open, they must all be closed.
+  while ([window_ attachedSheet]) {
     [window_ endSheet:[window_ attachedSheet]];
+  }
+  DCHECK_EQ([[window_ sheets] count], 0UL);
 
   // window_ could be nil after performClose.
   bool should_notify = is_modal() && parent() && IsVisible();

filename: spec/api-browser-window-spec.ts
patch: @@ -117,6 +117,14 @@ describe('BrowserWindow module', () => {
       await closed;
     });
 
+    it('should work if called when multiple messageBoxes are showing', async () => {
+      const closed = once(w, 'closed');
+      dialog.showMessageBox(w, { message: 'Hello Error' });
+      dialog.showMessageBox(w, { message: 'Hello Error' });
+      w.close();
+      await closed;
+    });
+
     it('closes window without rounded corners', async () => {
       await closeWindow(w);
       w = new BrowserWindow({ show: false, frame: false, roundedCorners: false });
Repository: denoland/deno
Pull request: fix(ext/node): add stubs for `node:trace_events`


Changed files:
filename: ext/node/lib.rs
patch: @@ -621,6 +621,7 @@ deno_core::extension!(deno_node,
     "node:timers" = "timers.ts",
     "node:timers/promises" = "timers/promises.ts",
     "node:tls" = "tls.ts",
+    "node:trace_events" = "trace_events.ts",
     "node:tty" = "tty.js",
     "node:url" = "url.ts",
     "node:util" = "util.ts",

filename: ext/node/polyfills/01_require.js
patch: @@ -151,6 +151,7 @@ import test from "node:test";
 import timers from "node:timers";
 import timersPromises from "node:timers/promises";
 import tls from "node:tls";
+import traceEvents from "node:trace_events";
 import tty from "node:tty";
 import url from "node:url";
 import utilTypes from "node:util/types";
@@ -260,6 +261,7 @@ function setupBuiltinModules() {
     timers,
     "timers/promises": timersPromises,
     tls,
+    traceEvents,
     tty,
     url,
     util,

filename: ext/node/polyfills/trace_events.ts
patch: @@ -0,0 +1,27 @@
+// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
+
+import { ERR_INVALID_ARG_TYPE } from "ext:deno_node/internal/errors.ts";
+
+class Tracing {
+  enabled = false;
+  categories = "";
+}
+
+function createTracing(opts) {
+  if (typeof opts !== "object" || opts == null) {
+    throw new ERR_INVALID_ARG_TYPE("options", "Object", opts);
+  }
+
+  return new Tracing(opts);
+}
+
+function getEnabledCategories() {
+  return "";
+}
+
+export { createTracing, getEnabledCategories };
+
+export default {
+  createTracing,
+  getEnabledCategories,
+};
Repository: facebook/react
Pull request: [DevTools] Log page URL in internal build

## Summary

This is to add a new field `page_url` in the Meta internal build so we have better understanding of where errors are happening

## How did you test this change?

Tested with a local build and dev server

Changed files:
filename: packages/react-devtools-extensions/src/main.js
patch: @@ -115,7 +115,17 @@ function createPanelIfReactLoaded() {
 
       const tabId = chrome.devtools.inspectedWindow.tabId;
 
-      registerDevToolsEventLogger('extension');
+      registerDevToolsEventLogger('extension', async () => {
+        // TODO: after we upgrade to Manifest V3, chrome.tabs.query returns a Promise
+        // without the callback.
+        return new Promise(resolve => {
+          chrome.tabs.query({active: true, currentWindow: true}, tabs => {
+            resolve({
+              page_url: tabs[0]?.url,
+            });
+          });
+        });
+      });
 
       function initBridgeAndStore() {
         const port = chrome.runtime.connect({

filename: packages/react-devtools-shared/src/Logger.js
patch: @@ -33,7 +33,7 @@ export type LogEvent =
       +inspected_element_number_of_hooks: number | null,
     |};
 
-export type LogFunction = LogEvent => void;
+export type LogFunction = LogEvent => void | Promise<void>;
 
 let logFunctions: Array<LogFunction> = [];
 export const logEvent: LogFunction =

filename: packages/react-devtools-shared/src/registerDevToolsEventLogger.js
patch: @@ -15,8 +15,17 @@ import {enableLogger} from 'react-devtools-feature-flags';
 let loggingIFrame = null;
 let missedEvents = [];
 
-export function registerDevToolsEventLogger(surface: string) {
-  function logEvent(event: LogEvent) {
+type LoggerContext = {|
+  page_url: ?string,
+|};
+
+export function registerDevToolsEventLogger(
+  surface: string,
+  fetchAdditionalContext: ?() =>
+    | LoggerContext
+    | ?(() => Promise<LoggerContext>),
+): void {
+  async function logEvent(event: LogEvent) {
     if (enableLogger) {
       if (loggingIFrame != null) {
         loggingIFrame.contentWindow.postMessage(
@@ -26,6 +35,9 @@ export function registerDevToolsEventLogger(surface: string) {
             context: {
               surface,
               version: process.env.DEVTOOLS_VERSION,
+              ...(fetchAdditionalContext != null
+                ? await fetchAdditionalContext()
+                : {}),
             },
           },
           '*',
Repository: electron/electron
Pull request: fix: close all open sheets before closing window on macOS

Backport of #43706

See that PR for details.


Notes: Fixed closing a window with more than one attached sheet on macOS.

Changed files:
filename: shell/browser/native_window_mac.mm
patch: @@ -346,8 +346,11 @@ static bool FromV8(v8::Isolate* isolate,
   // [window_ performClose:nil], the window won't close properly
   // even after the user has ended the sheet.
   // Ensure it's closed before calling [window_ performClose:nil].
-  if ([window_ attachedSheet])
+  // If multiple sheets are open, they must all be closed.
+  while ([window_ attachedSheet]) {
     [window_ endSheet:[window_ attachedSheet]];
+  }
+  DCHECK_EQ([[window_ sheets] count], 0UL);
 
   // window_ could be nil after performClose.
   bool should_notify = is_modal() && parent() && IsVisible();

filename: spec/api-browser-window-spec.ts
patch: @@ -116,6 +116,14 @@ describe('BrowserWindow module', () => {
       await closed;
     });
 
+    it('should work if called when multiple messageBoxes are showing', async () => {
+      const closed = once(w, 'closed');
+      dialog.showMessageBox(w, { message: 'Hello Error' });
+      dialog.showMessageBox(w, { message: 'Hello Error' });
+      w.close();
+      await closed;
+    });
+
     it('closes window without rounded corners', async () => {
       await closeWindow(w);
       w = new BrowserWindow({ show: false, frame: false, roundedCorners: false });