oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
72.82k stars 2.64k forks source link

[Crash] robot.js LoadLibrary failed: A dynamic link library (DLL) #12621

Closed tiagorangel2011 closed 2 weeks ago

tiagorangel2011 commented 1 month ago

How can we reproduce the crash?

package.json

{
  "name": "mousekm",
  "module": "index.js",
  "type": "module",
  "devDependencies": {
    "@types/bun": "latest"
  },
  "peerDependencies": {
    "typescript": "^5.0.0"
  },
  "dependencies": {
    "robotjs": "^0.6.0"
  }
}

index.js

import { setInterval } from 'bun:timers';
import robot from 'robotjs';

let previousMousePosition = robot.getMousePos();
let totalDistance = 0;

function calculateDistance(x1, y1, x2, y2) {
  return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
}

setInterval(() => {
  const currentMousePosition = robot.getMousePos();
  const distance = calculateDistance(
    previousMousePosition.x,
    previousMousePosition.y,
    currentMousePosition.x,
    currentMousePosition.y
  );

  totalDistance += distance;
  previousMousePosition = currentMousePosition;

  const distanceInKilometers = totalDistance / 1000000;
  console.log(`Mouse has traveled: ${distanceInKilometers.toFixed(6)} km`);
}, 100);

jsconfig.json

{
  "compilerOptions": {
    // Enable latest features
    "lib": ["ESNext", "DOM"],
    "target": "ESNext",
    "module": "ESNext",
    "moduleDetection": "force",
    "jsx": "react-jsx",
    "allowJs": true,

    // Bundler mode
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "verbatimModuleSyntax": true,
    "noEmit": true,

    // Best practices
    "strict": true,
    "skipLibCheck": true,
    "noFallthroughCasesInSwitch": true,

    // Some stricter flags (disabled by default)
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "noPropertyAccessFromIndexSignature": false
  }
}

Relevant log output

1 | var robotjs = require('./build/Release/robotjs.node');
        ^
TypeError: LoadLibrary failed: A dynamic link library (DLL) in
      at C:\<path>\node_modules\robotjs\index.js:1:5

Bun v1.1.17 (Windows x64)
============================================================
Bun v1.1.17 (bb66bba1) Windows x64
Args: "C:\Users\HUAWEI\.bun\bin\bun.exe" "run" "index.js"
Features: jsc tsconfig(2) 
Builtins: "bun:main" "node:timers" 
Elapsed: 375ms | User: 62ms | Sys: 93ms
RSS: 100.00MB | Peak: 100.00MB | Commit: 0.14GB | Faults: 24676

panic(main thread): Segmentation fault at address 0x7FFAB780976C
oh no: Bun has crashed. This indicates a bug in Bun, not your code.

To send a redacted crash report to Bun's team,
please file a GitHub issue using the link below:

 https://bun.report/1.1.17/wr1bb66bbaAiggggE_CU\ntdll.dll+k/gBCU\ntdll.dll6wxbCU\ntdll.dll8vsbCa\KERNEL32.DLL21gRCa\ucrtbase.dlloq2wBCa\ucrtbase.dll089mBsy+2Fkuf+k3gHA20//Bpp09voC

Stack Trace (bun.report)

Bun v1.1.17 (bb66bba) on windows x86_64 [RunCommand]

Segmentation fault at address 0x7FFAB780976C

github-actions[bot] commented 1 month ago

@tiagorangel2011, the latest version of Bun is v1.1.20, but this crash was reported on Bun v1.1.17.

Are you able to reproduce this crash on the latest version of Bun?

bun upgrade
tiagorangel2011 commented 1 month ago

Yes, the crash is still there after upgrading.

1 | var robotjs = require('./build/Release/robotjs.node');
        ^
TypeError: LoadLibrary failed: A dynamic link library (DLL) in
      at C:\<path>\node_modules\robotjs\index.js:1:5

Bun v1.1.20 (Windows x64)
============================================================
Bun v1.1.20 (ae194892) Windows x64
CPU: sse42 avx avx2
Args: "C:\Users\HUAWEI\.bun\bin\bun.exe" "run" "index.js"
Features: jsc tsconfig(2) 
Builtins: "bun:main" "node:timers" 
Elapsed: 625ms | User: 46ms | Sys: 93ms
RSS: 100.49MB | Peak: 100.49MB | Commit: 0.14GB | Faults: 24792

panic(main thread): Segmentation fault at address 0x7FFAF0AB976C
oh no: Bun has crashed. This indicates a bug in Bun, not your code.

To send a redacted crash report to Bun's team,
please file a GitHub issue using the link below:

 https://bun.report/1.1.20/wr1ae19489AiggggC_CU\ntdll.dll+k/gBCU\ntdll.dll6wxbCU\ntdll.dll8vsbCa\KERNEL32.DLL21gR66wgjDonxgjDsuz5Fk1f+tphHA20//Bpp0xqP
dayblox commented 1 month ago

Same thing with the cap lib

Bun v1.1.20 (ae19489) on windows x86_64 [AutoCommand]

Segmentation fault at address 0x7FF9BF4C3DB0

>
Jarred-Sumner commented 2 weeks ago

RobotJS uses V8 C++ APIs

@190n is actively implementing support for V8 C++ APIs in Bun

Please follow along in #4290

Jarred-Sumner commented 2 weeks ago

Duplicate of #4290