File tree Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -365,16 +365,6 @@ impl RMain {
365365 let libraries = RLibraries :: from_r_home_path ( & r_home) ;
366366 libraries. initialize_pre_setup_r ( ) ;
367367
368- // In tests R may be run from various threads. This confuses R's stack
369- // overflow checks so we disable those. This should not make it in
370- // production builds as it causes stack overflows to crash R instead of
371- // throwing an R error.
372- if harp:: test:: IS_TESTING {
373- unsafe {
374- libr:: set ( libr:: R_CStackLimit , usize:: MAX ) ;
375- }
376- }
377-
378368 crate :: sys:: interface:: setup_r ( args) ;
379369
380370 libraries. initialize_post_setup_r ( ) ;
Original file line number Diff line number Diff line change @@ -68,6 +68,17 @@ pub fn setup_r(mut args: Vec<*mut c_char>) {
6868 libr:: set ( ptr_R_Busy, Some ( r_busy) ) ;
6969 libr:: set ( ptr_R_Suicide, Some ( r_suicide) ) ;
7070
71+ // In tests R may be run from various threads. This confuses R's stack
72+ // overflow checks so we disable those. This should not make it in
73+ // production builds as it causes stack overflows to crash R instead of
74+ // throwing an R error.
75+ //
76+ // This must be called _after_ `Rf_initialize_R()`, since that's where R
77+ // detects the stack size and sets the default limit.
78+ if harp:: test:: IS_TESTING {
79+ libr:: set ( libr:: R_CStackLimit , usize:: MAX ) ;
80+ }
81+
7182 // Set up main loop
7283 setup_Rmainloop ( ) ;
7384 }
You can’t perform that action at this time.
0 commit comments