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

dmd segfaults on endless mixin recursion #19514

Open
dlangBugzillaToGithub opened this issue Dec 4, 2018 · 2 comments
Open

dmd segfaults on endless mixin recursion #19514

dlangBugzillaToGithub opened this issue Dec 4, 2018 · 2 comments
Labels

Comments

@dlangBugzillaToGithub
Copy link

Dennis (@dkorpel) reported this on 2018-12-04T14:14:03Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=19465

CC List

  • Stefan Koch

Description

Code:
```
enum string s = "__traits(compiles, mixin(s))";

static if (__traits(compiles, mixin(s))) {
    enum b = 2;
}
```

Output:
Segmentation fault (core dumped)

Concocted example, not something I encountered in actual code. Still, "dmd should never segfault" so filing this as a minor bug.
@dlangBugzillaToGithub
Copy link
Author

uplink.coder commented on 2018-12-04T16:43:06Z

Hmm, I think if you are asking for a stack-overflow you should not be surprised if you get it.

This is one of these problems which you get by interpreting a turing-complete language at compile-time.

Introducing an artificial recursion limit has been done, but people (weka) had to increase it in their fork.

Checking for a limit is not _huge_ deal but it is work which does not have to be done.

@dlangBugzillaToGithub
Copy link
Author

dkorpel commented on 2018-12-04T21:42:58Z

Yeah, I don't know if/how this should be "fixed", but notably endless recursion in CTFE:
`` 
enum a = f();
int f() {return f();}
```
Results in:
Error: function `onlineapp.f` CTFE recursion limit exceeded

While endless recursion in mixin without __traits(compiles, ...):
```
enum string s = "mixin(s);";
mixin(s);
```
Results in, after a while:
Error: out of memory

@thewilsonator thewilsonator added the Severity:ICE Internal Compiler Error label Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants