Skip to content

builtins.match regression: stack overflow on large strings #2147

@xzfc

Description

@xzfc

NixOS 18.03:

Welcome to Nix version 2.0. Type :? for help.

nix-repl> large-string = let self = a: if a == 0 then "a" else let s = self (a - 1); in s+s; in self 19 # string of 524288 bytes

nix-repl> builtins.match ".*" large-string
error: stack overflow (possible infinite recursion)

NixOS 17.09:

$ nix-repl
Welcome to Nix version 1.11.16. Type :? for help.

nix-repl> large-string = let self = a: if a == 0 then "a" else let s = self (a - 1); in s+s; in self 19 # string of 524288 bytes

nix-repl> builtins.match ".*" large-string
[ ]

Due to this regression, nixpkgs-mozilla overlay stoped working on NixOS 18.03. mozilla/nixpkgs-mozilla#90

I've reduced the case to the following:

$ nix repl
Welcome to Nix version 2.0. Type :? for help.

nix-repl> builtins.match ".*[\n]([0-9a-f]*)  linux-x86_64/en-US/firefox-60.0.tar.bz2..*" (builtins.readFile (builtins.fetchurl http://download.cdn.mozilla.net/pub/firefox/releases/60.0/SHA512SUMS ))
error: stack overflow (possible infinite recursion)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugregressionSomething doesn't work anymore
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions