Stack Overflow in Type Inference with Julia 1.10.3 - Seeking Solutions

Hello,

I’m currently experiencing a problem with Julia version 1.10.3 on Linux (x86_64). I have encountered an internal error related to stack overflow during type inference. The error message suggests that it might be related to recursion involving very long tuples or argument lists. Here’s the specific error:


Internal error: stack overflow in type inference of shouldlog(Logging.ConsoleLogger, Base.CoreLogging.LogLevel, Module, Symbol, Symbol).
This might be caused by recursion over very long tuples or argument lists.
Internal error: encountered unexpected error during compilation of shouldlog:


Although my code does involve some recursion, it is not extensive. I’m wondering if anyone else has experienced similar issues or has insights into potential solutions for this type of problem. Any suggestions on how to handle or debug this error would be greatly appreciated.

Here are some details about my system and Julia installation:

OS: Linux (x86_64-linux-gnu)
CPU: Intel(R) Core™ i7-6600U CPU @ 2.60GHz
Julia Version: 1.10.3
LLVM version: libLLVM-15.0.7

Thank you in advance for any help or guidance you can provide!

Are you saying this is a regression in 1.10.3, i.e. your code has worked on previous Julia versions?

Apart from that you’re much more likely to get help if you provide an MWE.

No, I have not tested this code on previous versions of Julia; I am currently working with version 1.10.3. Below is a MWE that illustrates the issue I am encountering:

Function NEPA tries to find the optimal way to embed a virtual graph into a physical graph.

It uses recursion to explore different configurations and levels of embedding depth.

function NEPA(level::Int64, N::Int64, Physical_graph, Virtual_graph, second_virtual_graph)
# Base case: Perform a simulation when the deepest recursive level is reached.
if level == 0
# Perform a simulation with a copy of the physical graph to avoid altering the original,
# and use the current virtual graph to calculate a score.
score = simulation(copy(Physical_graph), Virtual_graph, second_virtual_graph)
return score
end

# Initialize best_score with negative infinity to ensure any actual score is higher.
best_score = -Inf

# Recursive call to explore different configurations by decreasing the level.
for i in 1:N
    score = NEPA(level - 1, N, Physical_graph, Virtual_graph, second_virtual_graph)
    if score > best_score
        best_score = score
    end
end
return best_score 

end

Simulation function to calculate a score based on the embedding of the virtual graph

into the physical graph. This function might also recursively call NEPA to test different

scenarios or variations of the virtual graph.

function simulation(Physical_graph, Virtual_graph, second_virtual_graph)
score = 0
# Test different configurations by recursively calling NEPA with a different virtual graph.
# This is done under certain conditions to explore additional possibilities.
# Previously, the code functioned correctly; however, after adding this line, an internal error occurred causing a stack overflow during type inference.
score += NEPA_modified(level, N, Physical_graph, second_virtual_graph) # A modified version of the NEPA function is used here, with adjustments to guarantee termination.

return score

end