File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -1617,11 +1617,20 @@ public Object Rf_protect(Object x) {
16171617 public void Rf_unprotect (int x ) {
16181618 RFFIContext context = getContext ();
16191619 ArrayList <RObject > stack = context .rffiContextState .protectStack ;
1620- for (int i = 0 ; i < x ; i ++) {
1621- context .registerReferenceUsedInNative (stack .remove (stack .size () - 1 ));
1620+ try {
1621+ for (int i = 0 ; i < x ; i ++) {
1622+ context .registerReferenceUsedInNative (stack .remove (stack .size () - 1 ));
1623+ }
1624+ } catch (ArrayIndexOutOfBoundsException e ) {
1625+ debugWarning ("mismatched protect/unprotect (unprotect with empty protect stack)" );
16221626 }
16231627 }
16241628
1629+ private static boolean debugWarning (String message ) {
1630+ RError .warning (RError .SHOW_CALLER , RError .Message .GENERIC , message );
1631+ return true ;
1632+ }
1633+
16251634 @ Override
16261635 @ TruffleBoundary
16271636 public int R_ProtectWithIndex (Object x ) {
You can’t perform that action at this time.
0 commit comments