From 53244585f77f18207c057b9acf56e73b4faf8e06 Mon Sep 17 00:00:00 2001
From: stepan <stepan.sindelar@oracle.com>
Date: Thu, 5 Oct 2017 16:58:31 +0200
Subject: [PATCH] Do not crash when TRACE_MIRROR_ALLOCATION_SITES and calling
 fromNative

---
 .../truffle/r/runtime/data/NativeDataAccess.java       | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/NativeDataAccess.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/NativeDataAccess.java
index b6b0f9109e..1cc771dbdd 100644
--- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/NativeDataAccess.java
+++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/NativeDataAccess.java
@@ -231,7 +231,15 @@ public final class NativeDataAccess {
 
     @TruffleBoundary
     private static void registerAllocationSite(Object arg, NativeMirror mirror) {
-        nativeMirrorInfo.put(mirror.id, new RuntimeException(arg.getClass().getSimpleName() + " " + arg));
+        String argInfo;
+        if (arg instanceof RVector<?> && ((RVector) arg).hasNativeMemoryData()) {
+            // this must be vector created by fromNative factory method, it has data == null, but
+            // does not have its address assigned yet
+            argInfo = "[empty]";
+        } else {
+            argInfo = arg.toString();
+        }
+        nativeMirrorInfo.put(mirror.id, new RuntimeException(arg.getClass().getSimpleName() + " " + argInfo));
     }
 
     public static Object toNative(Object obj) {
-- 
GitLab