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

nested macro repetions can cause fatal OOM #30561

Closed
colin-kiegel opened this issue Dec 26, 2015 · 3 comments
Closed

nested macro repetions can cause fatal OOM #30561

colin-kiegel opened this issue Dec 26, 2015 · 3 comments

Comments

@colin-kiegel
Copy link

oom in two lines

macro_rules! oom { ( $($( ),*)* ) => { } }
oom!( );

=> fatal out-of-memory (warning: DON'T try to compile this without sufficient precautions - my computer runs out of RAM in 2 seconds with 16GB RAM installed). It doesn't matter what inside or outside of the brackets .. $($( .. ),*)* ...

Tested on LINUX, reproducible with stable-1.5, beta-1.6 and nightly.

This modified version is caught by the compiler and safe

macro_rules! no_oom { ( $($( ),*);* ) => { } }
no_oom!( );
src/main.rs:5:1: 5:10 error: ambiguity: multiple successful parses
src/main.rs:5 no_oom!( );
              ^~~~~~~~~

It would be nice if the compiler could check for anything that might oom like this. I think the safe version gives a hint at what is going wrong with the first version.

@colin-kiegel
Copy link
Author

PS: Playpen will just kill the process
https://play.rust-lang.org/?gist=76fc85245426a4532655&version=stable

@jonas-schievink
Copy link
Contributor

Duplicate of #5067

@huonw
Copy link
Member

huonw commented Jan 5, 2016

Indeed, closing as a dupe. Thanks for filing!

@huonw huonw closed this as completed Jan 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants