Skip to content

new EventEmitter() instanceof EventEmitter segfaults (exit 139, no output) #10556

Description

@proggeramlug

Found by the package audit (while fixing #10430/#10431) on Perry 7661bc0 (v0.5.1589), Linux x64. An instanceof
check of an EventEmitter instance against the EventEmitter constructor crashes the process with SIGSEGV before any
output is flushed (including earlier console.log lines).

Reproduction

main.ts:

import { EventEmitter } from "node:events";
import EE from "node:events";
const e = new EventEmitter();
console.log("named", e instanceof EventEmitter);
console.log("default", new EE() instanceof EE);
class Sub extends EventEmitter {}
console.log("sub", new Sub() instanceof EventEmitter, new Sub() instanceof Sub);
node main.ts
PERRY_NO_AUTO_OPTIMIZE=1 perry compile main.ts -o main && ./main; echo "rc=$?"

(Also reproduces with default auto-optimize, per the reporter.)

Expected (Node 26.5.1)

named true
default true
sub true true

Actual (Perry)

Segmentation fault (core dumped)
rc=139

Impact

x instanceof EventEmitter is how many libraries detect emitters/streams (ws, socket.io, mqtt, ioredis, pino,
bunyan, util.inherits-based code). Any such check crashes the process.

Notes

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    package-auditFound by the 2026 package audit: compiling real npm packages from source instead of native bindings

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions