helloadhavan/github_issues huggingface dataset:
Repository: ggml-org/llama.cpp
Pull request: server : fix thread.join() on exit

Supersede #12813

Resolve #12180

@qnixsynapse can you try if this fixes the issue?


Changed files:
filename: examples/server/server.cpp
patch: @@ -1705,6 +1705,8 @@ struct server_queue {
 };
 
 struct server_response {
+    bool running = true;
+
     // for keeping track of all tasks waiting for the result
     std::unordered_set<int> waiting_task_ids;
 
@@ -1759,6 +1761,10 @@ struct server_response {
         while (true) {
             std::unique_lock<std::mutex> lock(mutex_results);
             condition_results.wait(lock, [&]{
+                if (!running) {
+                    SRV_DBG("%s : queue result stop\n", __func__);
+                    std::terminate(); // we cannot return here since the caller is HTTP code
+                }
                 return !queue_results.empty();
             });
 
@@ -1789,6 +1795,10 @@ struct server_response {
             }
 
             std::cv_status cr_res = condition_results.wait_for(lock, std::chrono::seconds(timeout));
+            if (!running) {
+                SRV_DBG("%s : queue result stop\n", __func__);
+                std::terminate(); // we cannot return here since the caller is HTTP code
+            }
             if (cr_res == std::cv_status::timeout) {
                 return nullptr;
             }
@@ -1818,6 +1828,12 @@ struct server_response {
             }
         }
     }
+
+    // terminate the waiting loop
+    void terminate() {
+        running = false;
+        condition_results.notify_all();
+    }
 };
 
 struct server_context {
@@ -4491,9 +4507,10 @@ int main(int argc, char ** argv) {
     svr->new_task_queue = [&params] { return new httplib::ThreadPool(params.n_threads_http); };
 
     // clean up function, to be called before exit
-    auto clean_up = [&svr]() {
+    auto clean_up = [&svr, &ctx_server]() {
         SRV_INF("%s: cleaning up before exit...\n", __func__);
         svr->stop();
+        ctx_server.queue_results.terminate();
         llama_backend_free();
     };
 
@@ -4534,7 +4551,7 @@ int main(int argc, char ** argv) {
 
     if (!ctx_server.load_model(params)) {
         clean_up();
-        // t.join(); // FIXME: see below
+        t.join();
         LOG_ERR("%s: exiting due to model loading error\n", __func__);
         return 1;
     }
@@ -4582,7 +4599,7 @@ int main(int argc, char ** argv) {
     ctx_server.queue_tasks.start_loop();
 
     clean_up();
-    // t.join(); // FIXME: http thread may stuck if there is an on-going request. we don't need to care about this for now as the HTTP connection will already be closed at this point, but it's better to fix this
+    t.join();
 
     return 0;
 }
Repository: denoland/deno
Pull request: fix(ext/node): don't panic on invalid utf-8 in pem

Fixes #24143

Changed files:
filename: ext/node/ops/crypto/mod.rs
patch: @@ -1493,8 +1493,13 @@ fn parse_private_key(
 ) -> Result<pkcs8::SecretDocument, AnyError> {
   match format {
     "pem" => {
-      let (_, doc) =
-        pkcs8::SecretDocument::from_pem(std::str::from_utf8(key).unwrap())?;
+      let pem = std::str::from_utf8(key).map_err(|err| {
+        type_error(format!(
+          "Invalid PEM private key: not valid utf8 starting at byte {}",
+          err.valid_up_to()
+        ))
+      })?;
+      let (_, doc) = pkcs8::SecretDocument::from_pem(pem)?;
       Ok(doc)
     }
     "der" => {
@@ -1600,8 +1605,13 @@ fn parse_public_key(
 ) -> Result<pkcs8::Document, AnyError> {
   match format {
     "pem" => {
-      let (label, doc) =
-        pkcs8::Document::from_pem(std::str::from_utf8(key).unwrap())?;
+      let pem = std::str::from_utf8(key).map_err(|err| {
+        type_error(format!(
+          "Invalid PEM private key: not valid utf8 starting at byte {}",
+          err.valid_up_to()
+        ))
+      })?;
+      let (label, doc) = pkcs8::Document::from_pem(pem)?;
       if label != "PUBLIC KEY" {
         return Err(type_error("Invalid PEM label"));
       }

filename: tests/unit_node/crypto/crypto_key_test.ts
patch: @@ -415,3 +415,27 @@ Deno.test("generate rsa export public key", async function () {
   const der = publicKey.export({ format: "der", type: "spki" });
   assert(der instanceof Uint8Array);
 });
+
+Deno.test("create public key with invalid utf-8 string", function () {
+  // This is an invalid UTF-8 string because it contains a lone utf-16 surrogate.
+  const invalidPem = Buffer.from(new Uint8Array([0xE2, 0x28, 0xA1]));
+  assertThrows(
+    () => {
+      createPublicKey(invalidPem);
+    },
+    Error,
+    "not valid utf8",
+  );
+});
+
+Deno.test("create private key with invalid utf-8 string", function () {
+  // This is an invalid UTF-8 string because it contains a lone utf-16 surrogate.
+  const invalidPem = Buffer.from(new Uint8Array([0xE2, 0x28, 0xA1]));
+  assertThrows(
+    () => {
+      createPrivateKey(invalidPem);
+    },
+    Error,
+    "not valid utf8",
+  );
+});
Repository: huggingface/transformers
Pull request: Fix test

# What does this PR do?

Device context manager is not the intended API to use with `from_pretrained`.
It used to work before, BUT ONLY with `low_cpu_mem_usage=False`, so without consistency.

Will try to investigate if we can easily detect the context and turch it into a simple `device_map` however.


Changed files:
filename: tests/test_modeling_common.py
patch: @@ -860,11 +860,12 @@ def test_causal_lm_can_accept_kwargs(self):
                         model_eager = AutoModelForCausalLM.from_config(config, torch_dtype=torch.float32)
 
                     model_eager.save_pretrained(tmpdir)
-                    with torch.device(torch_device):
-                        model = AutoModelForCausalLM.from_pretrained(tmpdir, torch_dtype=torch.float32)
-                        inputs_dict["num_items_in_batch"] = inputs_dict["input_ids"].shape[0]
-                        inputs_dict["labels"] = inputs_dict["input_ids"]
-                        _ = model(**inputs_dict, return_dict=False)
+                    model = AutoModelForCausalLM.from_pretrained(
+                        tmpdir, torch_dtype=torch.float32, device_map=torch_device
+                    )
+                    inputs_dict["num_items_in_batch"] = inputs_dict["input_ids"].shape[0]
+                    inputs_dict["labels"] = inputs_dict["input_ids"]
+                    _ = model(**inputs_dict, return_dict=False)
 
     def test_training_gradient_checkpointing(self):
         # Scenario - 1 default behaviour
Repository: vercel/next.js
Pull request: Revert standalone extension change for module type

We don't need to change the extension as the main fix is to ensure the `package.json` is copied to the standalone folder. The extension change was for more correctness but can cause breakage for anyone using `type: 'module'` as they will need to update their flows for the new `.mjs` extension. Since this is un-necessary breakage this reverts that piece of the fix. 

x-ref: https://github.com/vercel/next.js/pull/77944#discussion_r2035618277

Changed files:
filename: packages/next/src/build/utils.ts
patch: @@ -1687,7 +1687,7 @@ export async function copyTracedFiles(
   const serverOutputPath = path.join(
     outputPath,
     path.relative(tracingRoot, dir),
-    moduleType ? 'server.mjs' : 'server.js'
+    'server.js'
   )
   await fs.mkdir(path.dirname(serverOutputPath), { recursive: true })
 

filename: test/production/standalone-mode/type-module/index.test.ts
patch: @@ -41,7 +41,7 @@ describe('type-module', () => {
 
     expect(fs.existsSync(join(standalonePath, 'package.json'))).toBe(true)
 
-    const serverFile = join(standalonePath, 'server.mjs')
+    const serverFile = join(standalonePath, 'server.js')
     const appPort = await findPort()
     const server = await initNextServerScript(
       serverFile,
Repository: nodejs/node
Pull request: doc: include git node release --promote to steps

Refs: https://github.com/nodejs/node-core-utils/pull/835


Changed files:
filename: doc/contributing/releases.md
patch: @@ -707,12 +707,23 @@ the build before moving forward. Use the following list as a baseline:
 
 ### 11. Tag and sign the release commit
 
-Once you have produced builds that you're happy with, create a new tag. By
-waiting until this stage to create tags, you can discard a proposed release if
-something goes wrong or additional commits are required. Once you have created a
-tag and pushed it to GitHub, you _**must not**_ delete and re-tag. If you make
-a mistake after tagging then you'll have to version-bump and start again and
-count that tag/version as lost.
+Once you have produced builds that you're happy with you can either run
+`git node release --promote`
+
+```bash
+git node release -S --promote https://github.com/nodejs/node/pull/XXXX
+```
+
+to automate the remaining steps until step 16 or you can perform it manually
+following the below steps.
+
+***
+
+Create a new tag: By waiting until this stage to create tags, you can discard
+a proposed release if something goes wrong or additional commits are required.
+Once you have created a tag and pushed it to GitHub, you _**must not**_ delete
+and re-tag. If you make a mistake after tagging then you'll have to version-bump
+and start again and count that tag/version as lost.
 
 Tag summaries have a predictable format. Look at a recent tag to see:
Repository: facebook/react
Pull request: prevent unused exec getCurrentValue after re-render

`getCurrentValue` at line `270` always run after a re-render but `useState` skipped after first render, so we can add it to the initial function to prevent that

@bvaughn


Changed files:
filename: packages/react-devtools-shared/src/devtools/views/hooks.js
patch: @@ -264,11 +264,11 @@ export function useSubscription<Value>({
   getCurrentValue: () => Value,
   subscribe: (callback: Function) => () => void,
 |}): Value {
-  const [state, setState] = useState({
+  const [state, setState] = useState(() => ({
     getCurrentValue,
     subscribe,
     value: getCurrentValue(),
-  });
+  }));
 
   if (
     state.getCurrentValue !== getCurrentValue ||
Repository: facebook/react
Pull request: Add isArray in devTools utils

Also here I replaced `Array.isArray` with `isArray` from 'shared' package

Changed files:
filename: packages/react-devtools-shared/src/isArray.js
patch: @@ -0,0 +1,12 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ *
+ * @flow
+ */
+
+const isArray = Array.isArray;
+
+export default isArray;

filename: packages/react-devtools-shared/src/utils.js
patch: @@ -48,6 +48,7 @@ import {
 } from 'react-devtools-shared/src/types';
 import {localStorageGetItem, localStorageSetItem} from './storage';
 import {meta} from './hydration';
+import isArray from './isArray';
 
 import type {ComponentFilter, ElementType} from './types';
 import type {LRUCache} from 'react-devtools-shared/src/types';
@@ -475,7 +476,7 @@ export function deletePathInObject(
   if (object != null) {
     const parent = getInObject(object, path.slice(0, length - 1));
     if (parent) {
-      if (Array.isArray(parent)) {
+      if (isArray(parent)) {
         parent.splice(((last: any): number), 1);
       } else {
         delete parent[last];
@@ -496,7 +497,7 @@ export function renamePathInObject(
       const lastOld = oldPath[length - 1];
       const lastNew = newPath[length - 1];
       parent[lastNew] = parent[lastOld];
-      if (Array.isArray(parent)) {
+      if (isArray(parent)) {
         parent.splice(((lastOld: any): number), 1);
       } else {
         delete parent[lastOld];
@@ -580,7 +581,7 @@ export function getDataType(data: Object): DataType {
         return 'number';
       }
     case 'object':
-      if (Array.isArray(data)) {
+      if (isArray(data)) {
         return 'array';
       } else if (ArrayBuffer.isView(data)) {
         return hasOwnProperty.call(data.constructor, 'BYTES_PER_ELEMENT')
@@ -799,7 +800,7 @@ export function formatDataForPreview(
           // To mimic their behavior, detect if we've been given an entries tuple.
           //   Map(2) {"abc" => 123, "def" => 123}
           //   Set(2) {"abc", 123}
-          if (Array.isArray(entryOrEntries)) {
+          if (isArray(entryOrEntries)) {
             const key = formatDataForPreview(entryOrEntries[0], true);
             const value = formatDataForPreview(entryOrEntries[1], false);
             formatted += `${key} => ${value}`;
Repository: denoland/deno
Pull request: fix(ext/node): use primordials in `ext/node/polyfills/string_decoder.ts`

Towards #24236

Changed files:
filename: ext/node/polyfills/string_decoder.ts
patch: @@ -20,9 +20,6 @@
 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
 // USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-// TODO(petamoriken): enable prefer-primordials for node polyfills
-// deno-lint-ignore-file prefer-primordials
-
 // Logic and comments translated pretty much one-to-one from node's impl
 // (https://github.com/nodejs/node/blob/ba06c5c509956dc413f91b755c1c93798bb700d4/src/string_decoder.cc)
 
@@ -35,11 +32,19 @@ import {
   NodeError,
 } from "ext:deno_node/internal/errors.ts";
 
-import { primordials } from "ext:core/mod.js";
+import { core, primordials } from "ext:core/mod.js";
 const {
   ArrayBufferIsView,
   ObjectDefineProperties,
+  Symbol,
+  MathMin,
+  DataViewPrototypeGetBuffer,
+  ObjectPrototypeIsPrototypeOf,
+  String,
+  TypedArrayPrototypeGetBuffer,
+  StringPrototypeToLowerCase,
 } = primordials;
+const { isTypedArray } = core;
 
 const { MAX_STRING_LENGTH } = constants;
 
@@ -50,7 +55,7 @@ type Any = any;
 function normalizeEncoding(enc?: string): string {
   const encoding = castEncoding(enc ?? null);
   if (!encoding) {
-    if (typeof enc !== "string" || enc.toLowerCase() !== "raw") {
+    if (typeof enc !== "string" || StringPrototypeToLowerCase(enc) !== "raw") {
       throw new ERR_UNKNOWN_ENCODING(
         enc as Any,
       );
@@ -64,7 +69,8 @@ function normalizeEncoding(enc?: string): string {
  */
 
 function isBufferType(buf: Buffer) {
-  return buf instanceof Buffer && buf.BYTES_PER_ELEMENT;
+  return ObjectPrototypeIsPrototypeOf(Buffer.prototype, buf) &&
+    buf.BYTES_PER_ELEMENT;
 }
 
 function normalizeBuffer(buf: Buffer) {
@@ -79,7 +85,9 @@ function normalizeBuffer(buf: Buffer) {
     return buf;
   } else {
     return Buffer.from(
-      buf.buffer,
+      isTypedArray(buf)
+        ? TypedArrayPrototypeGetBuffer(buf)
+        : DataViewPrototypeGetBuffer(buf),
     );
   }
 }
@@ -94,6 +102,7 @@ function bufferToString(
   if (len > MAX_STRING_LENGTH) {
     throw new NodeError("ERR_STRING_TOO_LONG", "string exceeds maximum length");
   }
+  // deno-lint-ignore prefer-primordials
   return buf.toString(encoding as Any, start, end);
 }
 
@@ -136,7 +145,7 @@ function decode(this: StringDecoder, buf: Buffer) {
         }
       }
 
-      const bytesToCopy = Math.min(buf.length - bufIdx, this[kMissingBytes]);
+      const bytesToCopy = MathMin(buf.length - bufIdx, this[kMissingBytes]);
       buf.copy(
         this.lastChar,
         this[kBufferedBytes],
Repository: nodejs/node
Pull request: test_runner: mark context.plan() as stable

This function does not require a CLI flag, does not emit a warning, and is a fairly simple API that is already being used heavily in the ecosystem. This commit marks `context.plan()` as stable.

<!--
Before submitting a pull request, please read:

- the CONTRIBUTING guide at https://github.com/nodejs/node/blob/HEAD/CONTRIBUTING.md
- the commit message formatting guidelines at
  https://github.com/nodejs/node/blob/HEAD/doc/contributing/pull-requests.md#commit-message-guidelines

For code changes:
1. Include tests for any bug fixes or new features.
2. Update documentation if relevant.
3. Ensure that `make -j4 test` (UNIX), or `vcbuild test` (Windows) passes.

If you believe this PR should be highlighted in the Node.js CHANGELOG
please add the `notable-change` label.

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.
-->


Changed files:
filename: doc/api/test.md
patch: @@ -3345,10 +3345,12 @@ The name of the test.
 added:
   - v22.2.0
   - v20.15.0
+changes:
+  - version: REPLACEME
+    pr-url: https://github.com/nodejs/node/pull/55895
+    description: This function is no longer experimental.
 -->
 
-> Stability: 1 - Experimental
-
 * `count` {number} The number of assertions and subtests that are expected to run.
 
 This function is used to set the number of assertions and subtests that are expected to run
Repository: electron/electron
Pull request: build: update appveyor image to latest version

This PR updates appveyor.yml to the latest baked image, e-129.0.6644.0.

Notes: none

Changed files:
filename: appveyor-woa.yml
patch: @@ -29,7 +29,7 @@
 
 version: 1.0.{build}
 build_cloud: electronhq-16-core
-image: e-129.0.6638.0
+image: e-129.0.6644.0
 environment:
   GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache
   ELECTRON_OUT_DIR: Default

filename: appveyor.yml
patch: @@ -29,7 +29,7 @@
 
 version: 1.0.{build}
 build_cloud: electronhq-16-core
-image: e-129.0.6638.0
+image: e-129.0.6644.0
 environment:
   GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache
   ELECTRON_OUT_DIR: Default
Repository: ggml-org/llama.cpp
Pull request: musa: enable freediskspace for docker image build

*Make sure to read the [contributing guidelines](https://github.com/ggml-org/llama.cpp/blob/master/CONTRIBUTING.md) before submitting a PR*

I noticed that the MUSA Docker image workflow has been consistently failing with the following error:

```bash
ERROR: failed to solve: ResourceExhausted: write /var/lib/buildkit/runc-overlayfs/content/ingest/f098189623d73fff47c934ff8e22237dde514229da265af66eaf3162c1c28c8a/ref: no space left on device
```

This PR enables `freediskspace` to help mitigate the disk space issue.

Changed files:
filename: .github/workflows/docker.yml
patch: @@ -38,7 +38,7 @@ jobs:
           # Multi-stage build
           - { tag: "cpu", dockerfile: ".devops/cpu.Dockerfile", platforms: "linux/amd64,linux/arm64", full: true, light: true, server: true, freediskspace: false}
           - { tag: "cuda", dockerfile: ".devops/cuda.Dockerfile", platforms: "linux/amd64", full: true, light: true, server: true, freediskspace: false}
-          - { tag: "musa", dockerfile: ".devops/musa.Dockerfile", platforms: "linux/amd64", full: true, light: true, server: true, freediskspace: false}
+          - { tag: "musa", dockerfile: ".devops/musa.Dockerfile", platforms: "linux/amd64", full: true, light: true, server: true, freediskspace: true}
           - { tag: "intel", dockerfile: ".devops/intel.Dockerfile", platforms: "linux/amd64", full: true, light: true, server: true, freediskspace: false}
           - { tag: "vulkan", dockerfile: ".devops/vulkan.Dockerfile", platforms: "linux/amd64", full: true, light: true, server: true, freediskspace: false}
           # Note: the rocm images are failing due to a compiler error and are disabled until this is fixed to allow the workflow to complete
Repository: vercel/next.js
Pull request: Turbopack: use correct env var for uploading test results

### What?

Use the correct env var

Regression from #77894

Closes PACK-4311

Changed files:
filename: jest.config.js
patch: @@ -37,7 +37,7 @@ if (enableTestReport) {
   }
 
   let outputDirectory
-  if (process.env.TURBOPACK) {
+  if (process.env.IS_TURBOPACK_TEST) {
     outputDirectory = '<rootDir>/turbopack-test-junit-report'
   } else if (process.env.NEXT_RSPACK) {
     outputDirectory = '<rootDir>/rspack-test-junit-report'
Repository: facebook/react
Pull request: add hasOwnProperty to devTools backend

We always use `hasOwnProperty` from `shared` package like `isArray`, so I think this case is missed

@bvaughn 

Changed files:
filename: packages/react-devtools-shared/src/backend/renderer.js
patch: @@ -85,6 +85,7 @@ import {format} from './utils';
 import {enableProfilerChangedHookIndices} from 'react-devtools-feature-flags';
 import is from 'shared/objectIs';
 import isArray from 'shared/isArray';
+import hasOwnProperty from 'shared/hasOwnProperty';
 
 import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
 import type {
@@ -1380,13 +1381,13 @@ export function attach(
       return false;
     }
     const {deps} = memoizedState;
-    const hasOwnProperty = Object.prototype.hasOwnProperty.bind(memoizedState);
+    const boundHasOwnProperty = hasOwnProperty.bind(memoizedState);
     return (
-      hasOwnProperty('create') &&
-      hasOwnProperty('destroy') &&
-      hasOwnProperty('deps') &&
-      hasOwnProperty('next') &&
-      hasOwnProperty('tag') &&
+      boundHasOwnProperty('create') &&
+      boundHasOwnProperty('destroy') &&
+      boundHasOwnProperty('deps') &&
+      boundHasOwnProperty('next') &&
+      boundHasOwnProperty('tag') &&
       (deps === null || isArray(deps))
     );
   }