sveltejs / kit

web development, streamlined
https://kit.svelte.dev
MIT License
18.49k stars 1.89k forks source link

`@sveltejs/enhanced-img` causes a coredump #11214

Closed amr3k closed 9 months ago

amr3k commented 9 months ago

Describe the bug

Using @sveltejs/enhanced-img causes the server to fail with this message:

munmap_chunk(): invalid pointer
[1]    341224 IOT instruction (core dumped)  pnpm dev

Reproduction

Logs

No response

System Info

System:
    OS: Linux 6.6 Arch Linux
    CPU: (8) x64 Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
    Memory: 5.85 GB / 15.58 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 18.19.0 - ~/.nvm/versions/node/v18.19.0/bin/node
    npm: 10.2.3 - ~/.nvm/versions/node/v18.19.0/bin/npm
    pnpm: 8.11.0 - ~/.local/share/pnpm/pnpm
    bun: 1.0.15 - ~/.bun/bin/bun
  Browsers:
    Chromium: 120.0.6099.62
  npmPackages:
    @sveltejs/adapter-auto: ^2.1.1 => 2.1.1 
    @sveltejs/enhanced-img: ^0.1.5 => 0.1.5 
    @sveltejs/kit: ^1.27.7 => 1.27.7 
    svelte: 5.0.0-next.19 => 5.0.0-next.19 
    vite: ^5.0.6 => 5.0.6

Severity

blocking an upgrade

Additional Information

I couldn't reproduce in stackblitz.

eltigerchino commented 9 months ago

I can't reproduce this. https://stackblitz.com/edit/sveltejs-kit-template-default-xw6jml?description=The%20default%20SvelteKit%20template,%20generated%20with%20create-svelte&file=vite.config.js&title=SvelteKit%20Default%20Template Please provide a minimal reproduction.

benallfree commented 9 months ago

@eltigerchino If it helps anyone, I've got it here https://github.com/pockethost/pockethost/actions/runs/7152645710/job/19478195164#step:6:342

Builds fine on local (OS X) but not in CI

eltigerchino commented 9 months ago

@benallfree you need to provide a newly created project that reproduces the coredump.

amr3k commented 9 months ago

@benallfree Have you been able to fix it?

benallfree commented 9 months ago

@amr3k Unfortunately no, and it looks like they closed the issue :(

@eltigerchino can we please leave this issue open, I think it is real as it has been reported by several users. I did not create the issue I was just trying to add a breadcrumb.

magick93 commented 9 months ago

I'm experiencing the same.

  System:
    OS: Linux 6.5 Ubuntu 23.10 23.10 (Mantic Minotaur)
    CPU: (8) x64 AMD Ryzen 5 3550H with Radeon Vega Mobile Gfx
    Memory: 7.07 GB / 30.78 GB
    Container: Yes
    Shell: 5.2.15 - /bin/bash
  Binaries:
    Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
    npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
    pnpm: 8.12.1 - ~/.nvm/versions/node/v20.10.0/bin/pnpm
    bun: 1.0.8 - ~/.bun/bin/bun
  Browsers:
    Chrome: 120.0.6099.109
  npmPackages:
    @sveltejs/adapter-auto: ^2.1.1 => 2.1.1 
    @sveltejs/enhanced-img: ^0.1.6 => 0.1.6 
    @sveltejs/kit: ^1.27.6 => 1.27.6 
    svelte: ^4.2.4 => 4.2.4 
    vite: ^4.5.0 => 4.5.0 
eltigerchino commented 9 months ago

Please provide a minimal reproduction in a repository. It will help us identify the issue more easily

benallfree commented 9 months ago

For anyone who can devote some time, I think the easiest reproduction is to create a github action that attempts to build a Sveltekit project that uses this feature. There is something about the github CI environment that causes the core dump.

@eltigerchino

amr3k commented 9 months ago

Update:

I was able to narrow down the issue to another package NOT related to svelte, which uses an outdated version of sharp. So this issue should be closed, I will however put my solution here for future reference.


Explanation

The issue in my case was the using of @dotlottie/player-component along with @sveltejs/enhanced-img in the same project.

@sveltejs/enhanced-img uses sharp===0.33.1 while @dotlottie/player-component uses sharp as follows:

> pnpm why sharp
dependencies:
@dotlottie/player-component 2.7.3
└─┬ @dotlottie/common 0.7.4
  └─┬ @dotlottie/dotlottie-js 0.6.0
    ├── sharp 0.32.5
    └─┬ sharp-phash 2.1.0
      └── sharp 0.32.5 peer
@sveltejs/enhanced-img 0.1.7
└─┬ vite-imagetools 6.2.8
  └─┬ imagetools-core 6.0.3
    └── sharp 0.33.1

The interesting part is that using @dotlottie/player-component without @sveltejs/enhanced-img works fine and vice versa, but putting those together causes that error!


Solution

Apart from waiting for @dotlottie/dotlottie-js to update their dependencies, there's another solution to force pnpm to use sharp 0.33.1 for all of my dependencies.

This is done by the following steps:

module.exports = {
  hooks: {
    readPackage(packageJson) {
      if (packageJson.dependencies && packageJson.dependencies['sharp']) {
        packageJson.dependencies['sharp'] = '^0.33.1';
      }
      return packageJson;
    },
  },
};
MahmoodKhalil57 commented 5 months ago
module.exports = {
  hooks: {
    readPackage(packageJson) {
      if (packageJson.dependencies && packageJson.dependencies['sharp']) {
        packageJson.dependencies['sharp'] = '^0.33.1';
      }
      return packageJson;
    },
  },
};

Thank you senpai

realskyquest commented 4 months ago

Hello and sorry to bump this issue, I had the same exact issue as @amr3k

Using linux mint 21.x with pnpm, perhaps this issue should be added to documentation, just in case other linux users face issues