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

Rustc hangs infinitely and consumes increasingly more memory on specific macro expansion #123848

Open
blaumeise20 opened this issue Apr 12, 2024 · 6 comments
Assignees
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. I-hang Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@blaumeise20
Copy link

blaumeise20 commented Apr 12, 2024

Coming here from rust-lang/rust-clippy#12414.

I found a very specific macro that causes the Rust compiler to hang infinitely while doing cargo check and consumes increasingly more memory over time, going into the 100s of gigabytes sometimes (it is put in swap then of course). This already caused my computer to crash multiple times...

fn main() {
    macro_rules! handle {
        ($($tt:tt)*) => {
            handle! {
                @@internal
                done: [$($tt)*],

                $($tt:tt)*
            }
        };

        (
            @@internal
            done: [$($done:tt)*],

            $method:ident Request: $req:ident($req_ty:ty) -> $res_ty:ty;
            $($rest:tt)*
        ) => {

        }
    }

    handle! {
        "initialize" Request: initialize(InitializeParams) -> InitializeResult;
    }
}

The problematic function is most likely rustc_expand::mbe::transcribe::transcribe.

A related issue is #95698, where the compiler also hangs during macro expansion.

Meta

rustc --version --verbose:

rustc 1.79.0-nightly (a07f3eb43 2024-04-11)
binary: rustc
commit-hash: a07f3eb43acc5df851e15176c7081a900a30a4d7
commit-date: 2024-04-11
host: x86_64-apple-darwin
release: 1.79.0-nightly
LLVM version: 18.1.3
Backtrace (using /usr/bin/sample)

Sampling process 33710 for 3 seconds with 1 millisecond of run time between samples
Sampling completed, processing symbols...
Analysis of sampling clippy-driver (pid 33710) every 1 millisecond
Process:         clippy-driver [33710]
Path:            /Users/USER/*/clippy-driver
Load Address:    0x1015cb000
Identifier:      clippy-driver
Version:         0
Code Type:       X86-64
Platform:        macOS
Parent Process:  cargo [32710]

Date/Time:       2024-04-12 13:11:35.607 +0200
Launch Time:     2024-04-12 13:06:00.199 +0200
OS Version:      macOS 12.6.1 (21G217)
Report Version:  7
Analysis Tool:   /usr/bin/sample

Physical footprint:         56.5G
Physical footprint (peak):  60.7G
----

Call graph:
    2104 Thread_487557   DispatchQueue_1: com.apple.main-thread  (serial)
    + 2104 start  (in dyld) + 462  [0x1102fa52e]
    +   2104 main  (in clippy-driver) + 44  [0x1015cf53c]
    +     2104 std::rt::lang_start_internal::hdcddb0d85f21ad14  (in libstd-1039e11c5d925359.dylib) + 800  [0x10294c9e0]
    +       2104 _RNCINvNtCshMRpXYz6a4z_3std2rt10lang_startuE0Cs6mbwj9oXxZo_13clippy_driver  (in clippy-driver) + 12  [0x1015d2c1c]
    +         2104 _RINvNtNtCshMRpXYz6a4z_3std10sys_common9backtrace28___rust_begin_short_backtraceFEuuECs6mbwj9oXxZo_13clippy_driver  (in clippy-driver) + 6  [0x1015d2c06]
    +           2104 _RNvCs6mbwj9oXxZo_13clippy_driver4main  (in clippy-driver) + 88  [0x1015cf028]
    +             2104 _RINvCs8WQfvkw6ssu_17rustc_driver_impl20catch_with_exit_codeNCNvCs6mbwj9oXxZo_13clippy_driver4mains_0EBZ_  (in clippy-driver) + 25  [0x1015d2919]
    +               2104 _RINvNtCshMRpXYz6a4z_3std9panicking3tryINtNtCsgErFe9f61or_4core6result6ResultuNtCshP7gWT6i98I_10rustc_span15ErrorGuaranteedEINtNtNtBF_5panic11unwind_safe16AssertUnwindSafeNCNvCs6mbwj9oXxZo_13clippy_driver4mains_0EEB2M_  (in clippy-driver) + 2937  [0x1015d0489]
    +                 2104 _RNvMs_Cs8WQfvkw6ssu_17rustc_driver_implNtB4_11RunCompiler3run  (in librustc_driver-786f82f604ab2a46.dylib) + 7464  [0x110f9ab48]
    +                   2104 _RINvNtCs8jMw6wNA80y_15rustc_interface9interface12run_compilerINtNtCsgErFe9f61or_4core6result6ResultuNtCshP7gWT6i98I_10rustc_span15ErrorGuaranteedENCNvCs8WQfvkw6ssu_17rustc_driver_impl12run_compiler0EB2o_  (in librustc_driver-786f82f604ab2a46.dylib) + 719  [0x110f74f1f]
    +                     2104 _RINvNtCs8jMw6wNA80y_15rustc_interface4util31run_in_thread_pool_with_globalsNCINvNtB4_9interface12run_compilerINtNtCsgErFe9f61or_4core6result6ResultuNtCshP7gWT6i98I_10rustc_span15ErrorGuaranteedENCNvCs8WQfvkw6ssu_17rustc_driver_impl12run_compiler0E0B1J_EB3a_  (in librustc_driver-786f82f604ab2a46.dylib) + 1267  [0x110fcc2d3]
    +                       2104 _RINvNtCshMRpXYz6a4z_3std9panicking3tryINtNtCsgErFe9f61or_4core6result6ResultuNtCshP7gWT6i98I_10rustc_span15ErrorGuaranteedEINtNtNtBF_5panic11unwind_safe16AssertUnwindSafeNCINvNtNtB4_6thread6scoped5scopeNCINvNtCs8jMw6wNA80y_15rustc_interface4util26run_in_thread_with_globalsNCINvB3j_31run_in_thread_pool_with_globalsNCINvNtB3l_9interface12run_compilerBA_NCNvCs8WQfvkw6ssu_17rustc_driver_impl12run_compiler0E0BA_E0BA_E0BA_E0EEB5J_  (in librustc_driver-786f82f604ab2a46.dylib) + 220  [0x110faca5c]
    +                         2104 _RNvMs6_NtCshMRpXYz6a4z_3std6threadINtB5_9JoinInnerINtNtCsgErFe9f61or_4core6result6ResultuNtCshP7gWT6i98I_10rustc_span15ErrorGuaranteedEE4joinCs8WQfvkw6ssu_17rustc_driver_impl  (in librustc_driver-786f82f604ab2a46.dylib) + 25  [0x110fc27d9]
    +                           2104 std::sys::pal::unix::thread::Thread::join::h33ea18036170bba5  (in libstd-1039e11c5d925359.dylib) + 16  [0x102970bf0]
    +                             2104 _pthread_join  (in libsystem_pthread.dylib) + 358  [0x7ff81219fc95]
    +                               2104 __ulock_wait  (in libsystem_kernel.dylib) + 10  [0x7ff8121630ea]
    2104 Thread_487559: rustc
      2104 thread_start  (in libsystem_pthread.dylib) + 15  [0x7ff812199f6b]
        2104 _pthread_start  (in libsystem_pthread.dylib) + 125  [0x7ff81219e4e1]
          2104 std::sys::pal::unix::thread::Thread::new::thread_start::h4e12f963b39b12dc  (in libstd-1039e11c5d925359.dylib) + 41  [0x102970a99]
            2104 _RNSNvYNCINvMNtCshMRpXYz6a4z_3std6threadNtBa_7Builder16spawn_unchecked_NCNCINvNtCs8jMw6wNA80y_15rustc_interface4util26run_in_thread_with_globalsNCINvB1d_31run_in_thread_pool_with_globalsNCINvNtB1f_9interface12run_compilerINtNtCsgErFe9f61or_4core6result6ResultuNtCshP7gWT6i98I_10rustc_span15ErrorGuaranteedENCNvCs8WQfvkw6ssu_17rustc_driver_impl12run_compiler0E0B3w_E0B3w_E00B3w_Es_0INtNtNtB3B_3ops8function6FnOnceuE9call_once6vtableB4X_  (in librustc_driver-786f82f604ab2a46.dylib) + 217  [0x110fc20d9]
              2104 _RINvNtNtCshMRpXYz6a4z_3std10sys_common9backtrace28___rust_begin_short_backtraceNCNCINvNtCs8jMw6wNA80y_15rustc_interface4util26run_in_thread_with_globalsNCINvB1m_31run_in_thread_pool_with_globalsNCINvNtB1o_9interface12run_compilerINtNtCsgErFe9f61or_4core6result6ResultuNtCshP7gWT6i98I_10rustc_span15ErrorGuaranteedENCNvCs8WQfvkw6ssu_17rustc_driver_impl12run_compiler0E0B3F_E0B3F_E00B3F_EB56_  (in librustc_driver-786f82f604ab2a46.dylib) + 53  [0x110fc1ce5]
                2104 _RINvCshP7gWT6i98I_10rustc_span27create_session_globals_thenINtNtCsgErFe9f61or_4core6result6ResultuNtB2_15ErrorGuaranteedENCINvNtCs8jMw6wNA80y_15rustc_interface4util31run_in_thread_pool_with_globalsNCINvNtB22_9interface12run_compilerBV_NCNvCs8WQfvkw6ssu_17rustc_driver_impl12run_compiler0E0BV_E0EB3P_  (in librustc_driver-786f82f604ab2a46.dylib) + 94  [0x110fc6f8e]
                  2104 _RINvMs_Cs3enEvTP6dgC_10scoped_tlsINtB5_9ScopedKeyNtCshP7gWT6i98I_10rustc_span14SessionGlobalsE3setNCINvNtCs8jMw6wNA80y_15rustc_interface4util31run_in_thread_pool_with_globalsNCINvNtB1F_9interface12run_compilerINtNtCsgErFe9f61or_4core6result6ResultuNtBN_15ErrorGuaranteedENCNvCs8WQfvkw6ssu_17rustc_driver_impl12run_compiler0E0B3l_E0B3l_EB4p_  (in librustc_driver-786f82f604ab2a46.dylib) + 4765  [0x110fb9dbd]
                    2104 _RINvCshP7gWT6i98I_10rustc_span14set_source_mapINtNtCsgErFe9f61or_4core6result6ResultuNtB2_15ErrorGuaranteedENCNCINvNtCs8jMw6wNA80y_15rustc_interface9interface12run_compilerBI_NCNvCs8WQfvkw6ssu_17rustc_driver_impl12run_compiler0E00EB2R_  (in librustc_driver-786f82f604ab2a46.dylib) + 778  [0x110fc693a]
                      2104 _RINvMs5_NtCs8jMw6wNA80y_15rustc_interface7queriesNtNtB8_9interface8Compiler5enterNCNCNvCs8WQfvkw6ssu_17rustc_driver_impl12run_compiler00INtNtCsgErFe9f61or_4core6result6ResultINtNtB2f_6option6OptionNtB6_6LinkerENtCshP7gWT6i98I_10rustc_span15ErrorGuaranteedEEB1n_  (in librustc_driver-786f82f604ab2a46.dylib) + 261  [0x110f73fb5]
                        2104 _RINvMs9_NtNtCs9usXs34tWkh_12rustc_middle2ty7contextNtB6_10GlobalCtxt5enterNCNCNCNvCs8WQfvkw6ssu_17rustc_driver_impl12run_compiler00s0_0RINtNtCsgknmb9fsrSu_21rustc_data_structures5steal5StealTNtB8_19ResolverAstLoweringINtNtCsceWSuvLJyfM_5alloc4sync3ArcNtNtCs9ztQ7ZR3AJk_9rustc_ast3ast5CrateEEEEB1i_  (in librustc_driver-786f82f604ab2a46.dylib) + 125  [0x110fe839d]
                          2104 _RNvNtNtNtCskwrFfgy0e6l_16rustc_query_impl10query_impl21resolver_for_lowering14get_query_incr26___rust_end_short_backtrace  (in librustc_driver-786f82f604ab2a46.dylib) + 239  [0x1126c63ef]
                            2104 _RINvNtNtCs12HGkTBO5Jg_18rustc_query_system5query8plumbing17try_execute_queryINtCskwrFfgy0e6l_16rustc_query_impl13DynamicConfigINtNtB4_6caches11SingleCacheINtNtNtCs9usXs34tWkh_12rustc_middle5query5erase6ErasedAhj8_EEKb0_KB3s_KB3s_ENtNtB1f_8plumbing9QueryCtxtKb1_EB1f_  (in librustc_driver-786f82f604ab2a46.dylib) + 3075  [0x11244e463]
                              2104 _RNvYNCNvNtNtCskwrFfgy0e6l_16rustc_query_impl10query_impl21resolver_for_lowering13dynamic_querys0_0INtNtNtCsgErFe9f61or_4core3ops8function6FnOnceTNtNtNtCs9usXs34tWkh_12rustc_middle2ty7context6TyCtxtuEE9call_onceBa_  (in librustc_driver-786f82f604ab2a46.dylib) + 25  [0x1125f8119]
                                2104 _RINvNtCskwrFfgy0e6l_16rustc_query_impl8plumbing28___rust_begin_short_backtraceNCNCNvNtNtB4_10query_impl21resolver_for_lowering13dynamic_querys0_00INtNtNtCs9usXs34tWkh_12rustc_middle5query5erase6ErasedAhj8_EEB4_  (in librustc_driver-786f82f604ab2a46.dylib) + 13  [0x11254d9cd]
                                  2104 _RNvNtCs8jMw6wNA80y_15rustc_interface6passes21resolver_for_lowering  (in librustc_driver-786f82f604ab2a46.dylib) + 1894  [0x1118283b6]
                                    2104 _RINvMNtCsIDeUcMcX3F_13rustc_session5utilsNtNtB5_7session7Session4timeNtNtCs9ztQ7ZR3AJk_9rustc_ast3ast5CrateNCNvNtCs8jMw6wNA80y_15rustc_interface6passes20configure_and_expands_0EB1N_  (in librustc_driver-786f82f604ab2a46.dylib) + 653  [0x111853f1d]
                                      2104 _RNvMs1_NtCskTRKI6kLupa_12rustc_expand6expandNtB5_13MacroExpander12expand_crate  (in librustc_driver-786f82f604ab2a46.dylib) + 1208  [0x11117e3e8]
                                        2104 _RNvMs1_NtCskTRKI6kLupa_12rustc_expand6expandNtB5_13MacroExpander21fully_expand_fragment  (in librustc_driver-786f82f604ab2a46.dylib) + 4191  [0x11117f6ef]
                                          2104 _RNvXs_NtNtCskTRKI6kLupa_12rustc_expand3mbe11macro_rulesNtB4_23MacroRulesMacroExpanderNtNtB8_4base15TTMacroExpander6expand  (in librustc_driver-786f82f604ab2a46.dylib) + 4139  [0x11119e02b]
                                            1496 _RNvNtNtCskTRKI6kLupa_12rustc_expand3mbe10transcribe10transcribe  (in librustc_driver-786f82f604ab2a46.dylib) + 2224,374,...  [0x1111bc5d0,0x1111bbe96,...]
                                            252 _RNvNtNtCskTRKI6kLupa_12rustc_expand3mbe10transcribe10transcribe  (in librustc_driver-786f82f604ab2a46.dylib) + 2928  [0x1111bc890]
                                            ! 252 _RNvMs_NtCshP7gWT6i98I_10rustc_span10source_mapNtB4_9SourceMap11is_imported  (in librustc_driver-786f82f604ab2a46.dylib) + 245,321,...  [0x1129b87b5,0x1129b8801,...]
                                            157 _RNvNtNtCskTRKI6kLupa_12rustc_expand3mbe10transcribe10transcribe  (in librustc_driver-786f82f604ab2a46.dylib) + 2429  [0x1111bc69d]
                                            ! 55 _RINvNtCs9ztQ7ZR3AJk_9rustc_ast9mut_visit11visit_tokenNtNtNtCskTRKI6kLupa_12rustc_expand3mbe10transcribe6MarkerEBV_  (in librustc_driver-786f82f604ab2a46.dylib) + 1431  [0x1110eeeb7]
                                            ! : 55 _RNvXNtNtCskTRKI6kLupa_12rustc_expand3mbe10transcribeNtB2_6MarkerNtNtCs9ztQ7ZR3AJk_9rustc_ast9mut_visit10MutVisitor10visit_span  (in librustc_driver-786f82f604ab2a46.dylib) + 197,13,...  [0x1111bbae5,0x1111bba2d,...]
                                            ! 52 _RINvNtCs9ztQ7ZR3AJk_9rustc_ast9mut_visit11visit_tokenNtNtNtCskTRKI6kLupa_12rustc_expand3mbe10transcribe6MarkerEBV_  (in librustc_driver-786f82f604ab2a46.dylib) + 127  [0x1110ee99f]
                                            ! : 52 _RNvXNtNtCskTRKI6kLupa_12rustc_expand3mbe10transcribeNtB2_6MarkerNtNtCs9ztQ7ZR3AJk_9rustc_ast9mut_visit10MutVisitor10visit_span  (in librustc_driver-786f82f604ab2a46.dylib) + 274,512,...  [0x1111bbb32,0x1111bbc20,...]
                                            ! 50 _RINvNtCs9ztQ7ZR3AJk_9rustc_ast9mut_visit11visit_tokenNtNtNtCskTRKI6kLupa_12rustc_expand3mbe10transcribe6MarkerEBV_  (in librustc_driver-786f82f604ab2a46.dylib) + 104,111,...  [0x1110ee988,0x1110ee98f,...]
                                            106 _RNvNtNtCskTRKI6kLupa_12rustc_expand3mbe10transcribe10transcribe  (in librustc_driver-786f82f604ab2a46.dylib) + 2173  [0x1111bc59d]
                                            ! 78 _RNvMs5_NtCshP7gWT6i98I_10rustc_span6symbolNtB5_25MacroRulesNormalizedIdent3new  (in librustc_driver-786f82f604ab2a46.dylib) + 27,34,...  [0x1129d1b4b,0x1129d1b52,...]
                                            ! 28 _RNvMs5_NtCshP7gWT6i98I_10rustc_span6symbolNtB5_25MacroRulesNormalizedIdent3new  (in librustc_driver-786f82f604ab2a46.dylib) + 174  [0x1129d1bde]
                                            !   20 _RINvMs_Cs3enEvTP6dgC_10scoped_tlsINtB5_9ScopedKeyNtCshP7gWT6i98I_10rustc_span14SessionGlobalsE4withNCINvMs4_NtBN_7hygieneNtB1I_11HygieneData4withNtB1I_13SyntaxContextNCNvMs5_B1I_B2j_24normalize_to_macro_rules0E0B2j_EBN_  (in librustc_driver-786f82f604ab2a46.dylib) + 182,55,...  [0x1129c1c16,0x1129c1b97,...]
                                            !   8 _RINvMs_Cs3enEvTP6dgC_10scoped_tlsINtB5_9ScopedKeyNtCshP7gWT6i98I_10rustc_span14SessionGlobalsE4withNCINvMs4_NtBN_7hygieneNtB1I_11HygieneData4withNtB1I_13SyntaxContextNCNvMs5_B1I_B2j_24normalize_to_macro_rules0E0B2j_EBN_  (in librustc_driver-786f82f604ab2a46.dylib) + 25  [0x1129c1b79]
                                            !     6 _RNvNvNvCshP7gWT6i98I_10rustc_span15SESSION_GLOBALS3FOO7___getit  (in librustc_driver-786f82f604ab2a46.dylib) + 13  [0x1129c07ed]
                                            !     + 6 tlv_get_addr  (in libdyld.dylib) + 0,13  [0x7ff8121a543c,0x7ff8121a5449]
                                            !     2 _RNvNvNvCshP7gWT6i98I_10rustc_span15SESSION_GLOBALS3FOO7___getit  (in librustc_driver-786f82f604ab2a46.dylib) + 0,14  [0x1129c07e0,0x1129c07ee]
                                            93 _RNvNtNtCskTRKI6kLupa_12rustc_expand3mbe10transcribe10transcribe  (in librustc_driver-786f82f604ab2a46.dylib) + 2212  [0x1111bc5c4]
                                              93 _RNvNtNtCskTRKI6kLupa_12rustc_expand3mbe10transcribe18lookup_cur_matched  (in librustc_driver-786f82f604ab2a46.dylib) + 457,290,...  [0x1111be449,0x1111be3a2,...]

Total number in stack (recursive counted multiple, when >=5):

Sort by top of stack, same collapsed (when >= 5):
        __ulock_wait  (in libsystem_kernel.dylib)        2104
        _RNvNtNtCskTRKI6kLupa_12rustc_expand3mbe10transcribe10transcribe  (in librustc_driver-786f82f604ab2a46.dylib)        1496
        _RNvMs_NtCshP7gWT6i98I_10rustc_span10source_mapNtB4_9SourceMap11is_imported  (in librustc_driver-786f82f604ab2a46.dylib)        252
        _RNvXNtNtCskTRKI6kLupa_12rustc_expand3mbe10transcribeNtB2_6MarkerNtNtCs9ztQ7ZR3AJk_9rustc_ast9mut_visit10MutVisitor10visit_span  (in librustc_driver-786f82f604ab2a46.dylib)        107
        _RNvNtNtCskTRKI6kLupa_12rustc_expand3mbe10transcribe18lookup_cur_matched  (in librustc_driver-786f82f604ab2a46.dylib)        93
        _RNvMs5_NtCshP7gWT6i98I_10rustc_span6symbolNtB5_25MacroRulesNormalizedIdent3new  (in librustc_driver-786f82f604ab2a46.dylib)        78
        _RINvNtCs9ztQ7ZR3AJk_9rustc_ast9mut_visit11visit_tokenNtNtNtCskTRKI6kLupa_12rustc_expand3mbe10transcribe6MarkerEBV_  (in librustc_driver-786f82f604ab2a46.dylib)        50
        _RINvMs_Cs3enEvTP6dgC_10scoped_tlsINtB5_9ScopedKeyNtCshP7gWT6i98I_10rustc_span14SessionGlobalsE4withNCINvMs4_NtBN_7hygieneNtB1I_11HygieneData4withNtB1I_13SyntaxContextNCNvMs5_B1I_B2j_24normalize_to_macro_rules0E0B2j_EBN_  (in librustc_driver-786f82f604ab2a46.dylib)        20
        tlv_get_addr  (in libdyld.dylib)        6

Binary Images:
       0x1015cb000 -        0x101cb6fff +clippy-driver (0) <7968FA1F-FB81-3C1B-8822-49C290855DDB> /Users/*/clippy-driver
       0x102929000 -        0x1029f0ff7 +libstd-1039e11c5d925359.dylib (0) <75A791AD-B806-37DC-8256-648F36237AAE> /Users/*/libstd-1039e11c5d925359.dylib
       0x1090e8000 -        0x1092cffc7 +libtokio_macros-1b50412e0e4848af.dylib (0) <C9974F6D-3C56-3D00-B430-A961A8A7078D> /Users/*/path-to-my-project/*/libtokio_macros-1b50412e0e4848af.dylib
       0x10a080000 -        0x10a34ffcf +libserde_derive-ab298787990a684e.dylib (0) <09929B70-983B-3A99-848D-FE7028BA1AD9> /Users/*/path-to-my-project/*/libserde_derive-ab298787990a684e.dylib
       0x1102f5000 -        0x11035e567  dyld (960) <7B87A986-A153-33C4-8470-D56410B7F9D5> /usr/lib/dyld
       0x1103ad000 -        0x117ac0fe7 +librustc_driver-786f82f604ab2a46.dylib (0) <327B610B-A9D7-3935-BB1F-E176BE59A737> /Users/*/librustc_driver-786f82f604ab2a46.dylib
    0x7ff811ecf000 -     0x7ff811ed0ff2  libsystem_blocks.dylib (79.1) <CE5E8C55-9E28-3982-9B98-74230BAD820F> /usr/lib/system/libsystem_blocks.dylib
    0x7ff811ed1000 -     0x7ff811f0cfff  libxpc.dylib (2236.140.2) <97773259-BCCA-3435-B545-3818BB30EFEC> /usr/lib/system/libxpc.dylib
    0x7ff811f0d000 -     0x7ff811f25ffe  libsystem_trace.dylib (1375.140.2) <5E19C3FF-05E3-39AD-BF5F-118B4CA909E1> /usr/lib/system/libsystem_trace.dylib
    0x7ff811f26000 -     0x7ff811fb7fe7  libcorecrypto.dylib (1218.120.10) <FF2CCB3B-7A2C-32EE-904E-91FEE822EBD2> /usr/lib/system/libcorecrypto.dylib
    0x7ff811fb8000 -     0x7ff811fe3fff  libsystem_malloc.dylib (374.120.1) <47042ACD-A337-322A-8DB7-ECD59CC60D92> /usr/lib/system/libsystem_malloc.dylib
    0x7ff811fe4000 -     0x7ff81202affb  libdispatch.dylib (1325.120.2) <1A04B380-76E4-3E4B-B0FC-9837533D021D> /usr/lib/system/libdispatch.dylib
    0x7ff81202b000 -     0x7ff812064ff2  libobjc.A.dylib (841.13) <4D9B0DCA-7151-3875-B98E-B255DB8267A8> /usr/lib/libobjc.A.dylib
    0x7ff812065000 -     0x7ff812067ff7  libsystem_featureflags.dylib (56) <CAB9769A-0B25-311F-A2CB-375105985D22> /usr/lib/system/libsystem_featureflags.dylib
    0x7ff812068000 -     0x7ff8120f0ff7  libsystem_c.dylib (1507.100.9) <E42E9D7A-03B4-340B-B61E-DCD45FD4ACC0> /usr/lib/system/libsystem_c.dylib
    0x7ff8120f1000 -     0x7ff812149fff  libc++.1.dylib (1300.25) <E67AC91F-F1DC-30EC-84F3-83F5BDAD3434> /usr/lib/libc++.1.dylib
    0x7ff81214a000 -     0x7ff81215ffff  libc++abi.dylib (1300.25) <7B800BB6-32E7-3597-B292-2C4DA4C377B1> /usr/lib/libc++abi.dylib
    0x7ff812160000 -     0x7ff812197fff  libsystem_kernel.dylib (8020.240.7) <0EA0D8AC-C27B-3A71-A59B-EC3A6F116ACF> /usr/lib/system/libsystem_kernel.dylib
    0x7ff812198000 -     0x7ff8121a3ff7  libsystem_pthread.dylib (486.100.11) <B5454E27-E8C7-3FDB-B77F-714F1E82E70B> /usr/lib/system/libsystem_pthread.dylib
    0x7ff8121a4000 -     0x7ff8121affff  libdyld.dylib (960) <64C284B3-231B-391D-845C-A285DFA305CD> /usr/lib/system/libdyld.dylib
    0x7ff8121b0000 -     0x7ff8121b9fef  libsystem_platform.dylib (273.100.5) <A8A33774-6D44-35E9-AD2A-BAD9E4D5192A> /usr/lib/system/libsystem_platform.dylib
    0x7ff8121ba000 -     0x7ff8121e4fff  libsystem_info.dylib (554.120.2) <6D4B0DA7-8EFC-3E6D-B984-F49260C3C194> /usr/lib/system/libsystem_info.dylib
    0x7ff8147da000 -     0x7ff8147e3fff  libsystem_darwin.dylib (1507.100.9) <C8C06B65-C4DF-3C86-8D03-ACB8568EC261> /usr/lib/system/libsystem_darwin.dylib
    0x7ff814c00000 -     0x7ff814c0efff  libsystem_notify.dylib (301) <8FDAD401-BF94-33BD-AC95-6928272AF18D> /usr/lib/system/libsystem_notify.dylib
    0x7ff8170d4000 -     0x7ff8170eaffb  libsystem_networkextension.dylib (1471.141.2) <C5A08005-40ED-3596-AE02-3CDE5CBB9214> /usr/lib/system/libsystem_networkextension.dylib
    0x7ff817139000 -     0x7ff81714fff7  libsystem_asl.dylib (392.100.2) <4C84DA5F-6450-3B33-8CA5-E6775EB3C7BB> /usr/lib/system/libsystem_asl.dylib
    0x7ff818987000 -     0x7ff81898efff  libsystem_symptoms.dylib (1617.140.3) <643A7FA0-DC38-30CF-B755-8FFE9A768B30> /usr/lib/system/libsystem_symptoms.dylib
    0x7ff81ab0b000 -     0x7ff81ab27ffb  libsystem_containermanager.dylib (383.120.2) <4A6C44F7-FD36-3315-85EA-904106DB1995> /usr/lib/system/libsystem_containermanager.dylib
    0x7ff81b862000 -     0x7ff81b865ffb  libsystem_configuration.dylib (1163.140.3) <C8A8DB1F-A66B-3AB8-88F8-D3F81E13952F> /usr/lib/system/libsystem_configuration.dylib
    0x7ff81b866000 -     0x7ff81b86bff3  libsystem_sandbox.dylib (1657.240.1) <0DD33425-C3BC-376D-9FB7-17C21DF4CD2D> /usr/lib/system/libsystem_sandbox.dylib
    0x7ff81c5ae000 -     0x7ff81c5b0ff7  libquarantine.dylib (133.120.2) <DE4AFED5-17A7-3BBE-BC74-F59B0119F8BA> /usr/lib/system/libquarantine.dylib
    0x7ff81cc65000 -     0x7ff81cc69fff  libsystem_coreservices.dylib (133) <8C364FD4-92EB-3D96-903B-23556015AD00> /usr/lib/system/libsystem_coreservices.dylib
    0x7ff81ceb8000 -     0x7ff81cecaff7  libz.1.dylib (77.240.1) <FE8700B3-27A4-3E2E-B046-9A6192F17A58> /usr/lib/libz.1.dylib
    0x7ff81cecb000 -     0x7ff81cf2bfd7  libsystem_m.dylib (3204.80.2) <5873BB02-9C24-330E-BE3F-A69937620E64> /usr/lib/system/libsystem_m.dylib
    0x7ff81cf2c000 -     0x7ff81cf2cfff  libcharset.1.dylib (61) <FF123241-D1C4-301F-83D5-6A53F911B0CE> /usr/lib/libcharset.1.dylib
    0x7ff81cf2d000 -     0x7ff81cf32fff  libmacho.dylib (994) <1A2B574F-0D91-376B-8122-C9915A89B719> /usr/lib/system/libmacho.dylib
    0x7ff81cf4f000 -     0x7ff81cf5aff7  libcommonCrypto.dylib (60191.100.1) <1A00FE13-7DED-3B41-9655-EF210F31764E> /usr/lib/system/libcommonCrypto.dylib
    0x7ff81cf5b000 -     0x7ff81cf65fff  libunwind.dylib (202.2) <079E4280-10E2-3062-BC91-A190F3A0C07E> /usr/lib/system/libunwind.dylib
    0x7ff81cf66000 -     0x7ff81cf6dfff  liboah.dylib (254.25) <AFA80743-2279-362C-A4A4-F17A5C10806F> /usr/lib/liboah.dylib
    0x7ff81cf6e000 -     0x7ff81cf77fff  libcopyfile.dylib (180.100.3) <3F9E168D-0697-3311-86DE-63884A75299C> /usr/lib/system/libcopyfile.dylib
    0x7ff81cf78000 -     0x7ff81cf7ffff  libcompiler_rt.dylib (103.1) <C0F60CA9-4403-3539-8B35-FCDC19CDDCAD> /usr/lib/system/libcompiler_rt.dylib
    0x7ff81cf80000 -     0x7ff81cf84ff7  libsystem_collections.dylib (1507.100.9) <D3FEAEB6-20E5-316C-87CA-DAE981459D66> /usr/lib/system/libsystem_collections.dylib
    0x7ff81cf85000 -     0x7ff81cf87ff7  libsystem_secinit.dylib (107.100.5) <1073080D-83EA-3190-AB3F-F299FC7C042E> /usr/lib/system/libsystem_secinit.dylib
    0x7ff81cf88000 -     0x7ff81cf89fff  libremovefile.dylib (60) <0A06ABF0-FA65-3ADA-A46A-A6F7C62F5C15> /usr/lib/system/libremovefile.dylib
    0x7ff81cf8a000 -     0x7ff81cf8affb  libkeymgr.dylib (31) <16BAFDE1-B1FC-3A4B-B06B-709AB4E357AB> /usr/lib/system/libkeymgr.dylib
    0x7ff81cf8b000 -     0x7ff81cf92fff  libsystem_dnssd.dylib (1557.140.5.0.1) <1DFA63CE-158B-3B32-A6BD-9881C2B4045E> /usr/lib/system/libsystem_dnssd.dylib
    0x7ff81cf93000 -     0x7ff81cf97fff  libcache.dylib (85) <54431C2C-7EBD-3E17-AEA3-9A7FFD3403AC> /usr/lib/system/libcache.dylib
    0x7ff81cf98000 -     0x7ff81cf99fff  libSystem.B.dylib (1311.120.1) <413BCE19-ECE0-3D88-81E3-96CDBD099045> /usr/lib/libSystem.B.dylib
    0x7ff81cfd9000 -     0x7ff81d0c9fff  libiconv.2.dylib (61) <73166A13-A2AD-34FF-A658-844F1C1AB7CA> /usr/lib/libiconv.2.dylib
    0x7ff823208000 -     0x7ff823208fff  libsystem_product_info_filter.dylib (10) <27C0A669-AF41-38F3-AF68-B4DE8FFD5128> /usr/lib/system/libsystem_product_info_filter.dylib
Sample analysis of process 33710 written to file /dev/stdout

@blaumeise20 blaumeise20 added the C-bug Category: This is a bug. label Apr 12, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 12, 2024
@eggyal
Copy link
Contributor

eggyal commented Apr 12, 2024

Rust attempts to match macro rules in the order that they are defined. Because every invocation matches the first rule, you have infinite recursion. If you reorder the rules, the @@internal one would then be matched if possible only falling back to the other rule if not.

@blaumeise20
Copy link
Author

That makes sense, but shouldn't there be a macro recursion error then?

@Alexendoo
Copy link
Member

The double $($tt)* gives it the unfortunate property of having to expand 2128 times before it hits the default recursion limit. It seems like there could be some other limit that could be applied to get an error here rather than OOM

@fmease
Copy link
Member

fmease commented Apr 12, 2024

cc @rust-lang/wg-macros

@jieyouxu jieyouxu added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. I-hang Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 12, 2024
@Noratrieb
Copy link
Member

@vincenzopalazzo was working on fixing this somewhere

@vincenzopalazzo
Copy link
Member

Yes, sorry about that! I have a PR up but it needs a MCP most luckily

Assigning this to me for now, but I think we need a tracking issue too

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. I-hang Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

8 participants