Skip to content

a fresh node startup has populated RegExp statics #43740

Closed
@ljharb

Description

@ljharb

Version

v18.5.0

Platform

n/a

Subsystem

No response

What steps will reproduce the bug?

node -pe 'RegExp.$_' will print out WeakRef.

node, and then RegExp.$_, will print out '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'.

This also applies to $&.

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior?

No response

What do you see instead?

I expect the empty string for all RegExp statics.

This is a problem for a few reasons:

  1. it exposes internal regular expression usage in node core
  2. the value might change from any version to any version, so if anyone's foolish enough to rely on it, they'll break in a non-major
  3. it's unseemly

If there's a point, right before node starts running user code, and right before the repl becomes available, then we could execute a trivial regular expression operation to clear all the statics.

Alternatively, this may be exposing non-primordial regex usage, and it's likely that switching to primordials (since I believe they'd update the statics on the primordial RegExp instead of the global RegExp) would solve this as well.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions