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

Segmentation fault when running vite dev #11

Closed
Xenfo opened this issue Apr 8, 2023 · 18 comments
Closed

Segmentation fault when running vite dev #11

Xenfo opened this issue Apr 8, 2023 · 18 comments
Labels
dep-issue Issue in an upstream dependency

Comments

@Xenfo
Copy link

Xenfo commented Apr 8, 2023

I'm using Vite with the React SWC plugin.

import react from "@vitejs/plugin-react-swc";
import * as fs from "fs";
import { defineConfig } from "vitest/config";

const CERT_PATH = "../certs/cert.pem";
const KEY_PATH = "../certs/key.pem";

export default defineConfig({
  plugins: [
    react({
      plugins: [
        ["@swc-jotai/react-refresh", {}],
        ["@swc-jotai/debug-label", {}],
      ],
    }),
  ]
});

I navigate to the dev URL and I get Segmentation fault and vite dev crashes.

@Xenfo Xenfo changed the title Segmentation fault Segmentation fault when running vite dev Apr 9, 2023
@Thisen
Copy link
Collaborator

Thisen commented Apr 11, 2023

Can you provide a reproduction?

@Xenfo
Copy link
Author

Xenfo commented Apr 11, 2023

Just create a Vite app using the SWC version of the React plugin and add Jotai's plugins. Basically just copy the config I provided. Then run dev and visit the server URL.

@Xenfo
Copy link
Author

Xenfo commented Apr 16, 2023

For a more detailed guide:

npm create vite@latest demo # Select React as the framework and TypeScript + SWC as the variant.

image

Install the swc-jotai plugins and the copy this config into vite.config.ts:

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react({
      plugins: [
        ["@swc-jotai/debug-label", {}],
        ["@swc-jotai/react-refresh", {}],
      ],
    }),
  ],
});

Run yarn dev. This vanilla example doesn't segfault for me but it still errors and doesn't render with the following:

thread '<unnamed>' panicked at 'assertion failed: prev.start > max', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.0-beta.2/src/engine/trap/frame_info.rs:224:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failed to handle: assertion failed: prev.start > max
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.0-beta.2/src/engine/trap/frame_info.rs:220:39

@Thisen
Copy link
Collaborator

Thisen commented May 1, 2023

Can you try it out with latest versions of the plugins?

@Xenfo
Copy link
Author

Xenfo commented May 1, 2023

Now I get this.

[client] thread '<unnamed>' panicked at 'assertion failed: prev.start > max', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.0/src/engine/trap/frame_info.rs:224:9
[client] note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[client] failed to handle: assertion failed: prev.start > max
[client] thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.0/src/engine/trap/frame_info.rs:220:39
[client] failed to handle: called `Result::unwrap()` on an `Err` value: PoisonError { .. }
[client] thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.0/src/engine/trap/frame_info.rs:220:39
[client] failed to handle: called `Result::unwrap()` on an `Err` value: PoisonError { .. }
[client] thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.0/src/engine/trap/frame_info.rs:220:39
[client] failed to handle: called `Result::unwrap()` on an `Err` value: PoisonError { .. }
[client] thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.0/src/engine/trap/frame_info.rs:220:39
[client] thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: PoisonError { .. }', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.0/src/engine/trap/frame_info.rs:220:39

@Thisen
Copy link
Collaborator

Thisen commented May 3, 2023

@Xenfo can you test whether @swc/plugin-noop works in your setup?
https://github.com/swc-project/plugins/blob/main/packages/noop/package.json

@Xenfo

This comment was marked as resolved.

@Xenfo

This comment was marked as outdated.

@Xenfo
Copy link
Author

Xenfo commented May 3, 2023

@swc/plugin-noop works now, it was an issue with my monorepo setup. I checked and confirmed that swc-jotai plugins are still broken, even on a newly generated Vite project.

@Thisen
Copy link
Collaborator

Thisen commented May 4, 2023

Alright, thanks for confirming @Xenfo.

Please provide a reproduction in CodeSandbox or a cloneable repo. Then I can look into it.

@Thisen
Copy link
Collaborator

Thisen commented May 4, 2023

Actually, this is an issue in Wasmer:
wasmerio/wasmer#3793

@Thisen Thisen added dep-issue Issue in an upstream dependency and removed needs reproduction labels May 4, 2023
@pawelblaszczyk5
Copy link

Hello,
Here is the minimal reproduction with clean Vite + SWC setup: https://github.com/pawelblaszczyk5/swc-jotai-repro

It indeed seems to be some issue inside of wasmer, at least from stacktrace

thread '<unnamed>' panicked at 'assertion failed: prev.start > max', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.2.0/src/engine/trap/frame_info.rs:224:9

@KDederichs
Copy link

It does seem to do the same thing on NextJS btw (13.4.8)

thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("<path>/node_modules/.pnpm/next@13.4.8_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/client/components/error-boundary.js")'

Caused by:
    0: failed to invoke `<path>/node_modules/.pnpm/@swc-jotai+react-refresh@0.0.8/node_modules/@swc-jotai/react-refresh/swc_jotai_react_refresh.wasm` as js transform plugin at <path>/node_modules/.pnpm/@swc-jotai+react-refresh@0.0.8/node_modules/@swc-jotai/react-refresh/swc_jotai_react_refresh.wasm
    1: RuntimeError: unreachable
           at <unnamed> (<module>[1929]:0x96f9f)
           at <unnamed> (<module>[1924]:0x96d63)
           at <unnamed> (<module>[1923]:0x96d32)
           at <unnamed> (<module>[1910]:0x95ed2)
           at <unnamed> (<module>[1909]:0x95dff)
           at <unnamed> (<module>[1918]:0x965d4)
           at <unnamed> (<module>[2051]:0xa4552)
           at <unnamed> (<module>[2099]:0xaaf0c)
           at <unnamed> (<module>[314]:0x3ffcf)
           at <unnamed> (<module>[100]:0x18ea2)
           at <unnamed> (<module>[123]:0x206cf)
           at <unnamed> (<module>[124]:0x20f28)
           at <unnamed> (<module>[99]:0x18a79)
           at <unnamed> (<module>[97]:0x17a1a)
           at <unnamed> (<module>[123]:0x20aae)
           at <unnamed> (<module>[47]:0x7e77)
           at <unnamed> (<module>[19]:0x1b86)
           at <unnamed> (<module>[17]:0x1aae)
           at <unnamed> (<module>[16]:0x189a)
           at <unnamed> (<module>[347]:0x4993b)
           at <unnamed> (<module>[2195]:0xb1617)', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc-0.263.26/src/plugin.rs:162:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("<path>/node_modules/.pnpm/next@13.4.8_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/app-render/entry-base.js")'

the noop plugin works just fine

@thecuvii
Copy link

Looks like wasmerio/wasmer#3793 has been fixed.

@Thisen
Copy link
Collaborator

Thisen commented Jul 24, 2023

Looks like wasmerio/wasmer#3793 has been fixed.

Thanks for the reminder! I'll look into updating the crates soon.

@masterbater
Copy link

wen fix?

@ornakash
Copy link

Looks like wasmerio/wasmer#3793 has been fixed.

Thanks for the reminder! I'll look into updating the crates soon.

Thank you!

@Thisen
Copy link
Collaborator

Thisen commented Aug 15, 2023

Sorry for the wait people! Holiday season is over in Europe and I had the time to look into this.

I have published both packages in 0.1.0, hopefully the issues are fixed. If not, create a new issue.

@Thisen Thisen closed this as completed Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dep-issue Issue in an upstream dependency
Projects
None yet
Development

No branches or pull requests

7 participants