Skip to content

Scary error when generating large number of RuntimeGeneratedFunctions #13

Open
@tisztamo

Description

@tisztamo

The MWE fills an array with simple generated functions and calls them in a loop. Works for me when n=50_000, but not when n=65535.

julia> using RuntimeGeneratedFunctions
       RuntimeGeneratedFunctions.init(@__MODULE__)

       function genfuncs(n)
           fs = Any[]
           for i=1:n
               a = rand()
               ex = :(function f(x)
                   return x * $a
               end)
               f = @RuntimeGeneratedFunction(ex)
               push!(fs, f)
           end
           return fs
       end

       function calc(fs)
           sum = 0.0
           for i = eachindex(fs) 
               sum += fs[i](42.0)
           end
           return sum
       end

       fs = genfuncs(100_000)
       calc(fs)
ERROR: UndefVarError: mul_float not defined
Stacktrace:
 [1] * at ./float.jl:405 [inlined]
 [2] macro expansion at ./REPL[1]:9 [inlined]
 [3] macro expansion at /home/krisztian/.julia/packages/RuntimeGeneratedFunctions/fIcZp/src/RuntimeGeneratedFunctions.jl:80 [inlined]
 [4] macro expansion at ./none:0 [inlined]
 [5] generated_callfunc at ./none:0 [inlined]
 [6] (::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{var"#_RuntimeGeneratedFunctions_ModTag",(0x92, 0xb5, 0xf6, 0xed, 0xbb, 0x56, 0xdf, 0xe8, 0x21, 0x03, 0xee, 0xa3, 0xe5, 0x65, 0x4c, 0xf8, 0x80, 0xb3, 0xe2, 0x57, 0x59, 0x5a, 0x10, 0x91, 0xd3, 0x39, 0xc9, 0xe2, 0x7b, 0xc5, 0x09, 0xcd, 0xbf, 0xa5, 0xcd, 0x04, 0xa1, 0x99, 0xac, 0x0d, 0xf0, 0x49, 0x08, 0x53, 0xf3, 0x01, 0x0e, 0xff, 0x94, 0x1e, 0x19, 0x76, 0xd1, 0x78, 0xe1, 0x43, 0xc3, 0xa5, 0x47, 0xc1, 0xda, 0x0b, 0x8a, 0xf4),(:x,)})(::Float64) at /home/krisztian/.julia/packages/RuntimeGeneratedFunctions/fIcZp/src/RuntimeGeneratedFunctions.jl:68
 [7] calc(::Array{Any,1}) at ./REPL[1]:20
 [8] top-level scope at REPL[1]:26

julia> versioninfo()
Julia Version 1.5.2
Commit 539f3ce943 (2020-09-23 23:17 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)

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