Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nim compiler is running into a recursion limit while trying to expand templates #1211

Open
shashankshampi opened this issue Oct 7, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@shashankshampi
Copy link

This issue can happen when there are too many nested templates or when the compiler can't efficiently manage deep template instantiations.

Current template: tests/asyncunit.nim
import unittest2, chronos

export unittest2, chronos

template asyncTeardown*(body: untyped): untyped =
teardown:
waitFor(
(
proc() {.async.} =
body
)()
)

template asyncSetup*(body: untyped): untyped =
setup:
waitFor(
(
proc() {.async.} =
body
)()
)

template asyncTest*(name: string, body: untyped): untyped =
test name:
waitFor(
(
proc() {.async.} =
body
)()
)

How to Reproduce:

Add the below test in file tests/pubsub/testgossipinternal.nim and then run any of them nim c -r tests/pubsub/testgossipinternal.nim "handle multiple SUBSCRIBE and UNSUBSCRIBE events"

Test file attached.
message.txt

Error Log:
This will crash with log below and when you do the same thing in the new file by adding the same test in the new file and running it works fine without any error.

error.log

@AlejandroCabeza
Copy link
Collaborator

Removed assignments so they are properly done during weekly.

@kaiserd kaiserd moved this from new to Pipeline in nim-libp2p Nov 29, 2024
@tersec
Copy link
Contributor

tersec commented Dec 8, 2024

I can't reproduce this on NIm v2.0.12, running within nimbus-eth2 nimbus-build-system environment:

$ ../../env.sh nim c -r tests/pubsub/testgossipinternal.nim "handle multiple SUBSCRIBE and UNSUBSCRIBE events"
... it compiles ...
GossipSub internal WRN 2024-12-08 13:42:23.761+01:00 service is already stopped                 topics="libp2p switch" tid=1946825 file=switch.nim:79
WRN 2024-12-08 13:42:23.761+01:00 TCP transport already stopped              topics="libp2p tcptransport" tid=1946825 file=tcptransport.nim:209
. (0.00s)
[Summary] 1 tests run (0.00s): 1 OK, 0 FAILED, 0 SKIPPED

@tersec
Copy link
Contributor

tersec commented Dec 8, 2024

With specific tests/pubsub/testgossipinternal.nim used attached.

testgossipinternal.nim.txt

Nim Compiler Version 2.0.12 [Linux: amd64]
Compiled at 2024-11-04
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: ce7c6f4f3365db2cc63bdd9d460c71ed937ee9e9
active boot switches: -d:release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Pipeline
Development

No branches or pull requests

4 participants