Skip to content
New issue

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

occational segfaults on tests type error #20450

Closed
scarf005 opened this issue Sep 11, 2023 · 4 comments · Fixed by #20495
Closed

occational segfaults on tests type error #20450

scarf005 opened this issue Sep 11, 2023 · 4 comments · Fixed by #20495
Assignees
Labels
bug Something isn't working correctly upstream Changes in upstream are required to solve these issues

Comments

@scarf005
Copy link
Contributor

2023-09-11_19-42-31.mp4

segfaults around 22s

Reproduce

run with deno test --watch -A test.ts.

Code used
/**
 * Converts first heading into frontmatter.
 */

import { assertEquals } from "https://deno.land/std@0.201.0/assert/assert_equals.ts"
import * as frontmatter from "https://deno.land/std@0.201.0/front_matter/yaml.ts"
import { walk } from "https://deno.land/std@0.201.0/fs/walk.ts"
import { asynciter } from "https://deno.land/x/asynciter@0.0.18/mod.ts"

// const files = await asynciter(walk("doc/src/content", { exts: ["md"], includeDirs: false }))
//   .map(({ path }) => path)
//   .concurrentUnorderedMap(async (path) => ({ path, text: await Deno.readTextFile(path) }))
//   .filter(({ text }) => frontmatter.test(text))
//   .map()
//   .collect()

// console.log(files)

const input = /*md*/ `

## Foo asdf

bar

### baz

qux
`

const output = /*md*/ `\
---
title: Foo asdf
---

bar

### baz

qux
`

const consumeFirstHeading = (lines: string[]): { heading: string; lines: string[] } => {
  // consume all empty lines with regex
  const spaces = lines.findIndex((line) => !line.match(/^\s*$/)) ?? 0
  // split into frontmatter and content

  const [frontmatter, ...content] = lines.slice(0, spaces)
  console.log({ frontmatter, content })
  return { heading: frontmatter, lines: content }
}

Deno.test("first heading is consumed into frontmatter", () => {
  const result = consumeFirstHeading(input.split("\n"))
  assertEquals(result, {
    heading: "Foo asdf",
    lines: ["bar", "", "### baz", "", "qux"],
  })
})

Versions

deno 1.36.4+0b3968c (canary, x86_64-unknown-linux-gnu)
v8 11.7.439.6
typescript 5.2.2
@bartlomieju bartlomieju added bug Something isn't working correctly upstream Changes in upstream are required to solve these issues labels Sep 11, 2023
@bartlomieju bartlomieju self-assigned this Sep 11, 2023
@bartlomieju
Copy link
Member

bartlomieju commented Sep 11, 2023

@scarf005 what is your Linux distro and version, and what do you get when you run uname -r?

@scarf005
Copy link
Contributor Author

...oh, forgot to mention. the kernel is built from home.

distro: Kubuntu 23.04 x86_64
kernel: 6.5.0 built from home
uname -r: 6.5.0-stock

@bartlomieju
Copy link
Member

@scarf005 are you using WASM in your project?

@scarf005
Copy link
Contributor Author

probably not, i've only used stdlib and asynciter. here's my configuration for reference.

deno.tar.gz

bartlomieju added a commit that referenced this issue Sep 14, 2023
This is a mitigation for segfaults happening in V8 on CPU with MPK
(memory protected keys).

After much trail and error we found that unless V8 platform is
initialized on main thread the segfaults start appears once JIT 
kicks in. "deno test" and "deno bench" were affected by
this problem.

Fixes #19926
Fixes #20243
Fixes #20450

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly upstream Changes in upstream are required to solve these issues
Projects
None yet
2 participants