question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Running on Linux / docker with .NET Core: Function DATAPTR_OR_NULL not found in native library libR.so

See original GitHub issue

I’m using a Dockerfile which effectively does apt-get install r-base (I have libopenblas-base too but removing it makes no difference) then runs a .NET Core app with the latest R.NET.

As I understand it the base image is on Debian 9.

FROM microsoft/dotnet:2.1-aspnetcore-runtime AS runner
WORKDIR /app

# install R
RUN apt-get update \
	&& apt-get -y install libopenblas-base r-base \
	&& apt-get clean
ENV R_HOME /usr/lib/R

The library loads fine - if I remove /usr/lib/R/lib/libR.so, it fails much sooner. I see the comment in the getting starting guide, about LD_LIBRARY_PATH, but the error is the same if I set that to /usr/lib/R/lib (init works, but the call fails).

Not sure if relevant - I’m new to this - but nm -D /usr/lib/R/lib/libR.so | grep -i data doesn’t show a function exported from libR.so called DATAPTR_OR_NULL. So maybe the error is telling the truth?

The code is based on the sample repo:

var r = REngine.GetInstance();
var charVec = r.CreateCharacterVector(new[] {"Hello, R world!, .NET speaking"});
r.SetSymbol("greetings", charVec);
r.Evaluate("str(greetings)");
var a = r.Evaluate("'Hi there .NET, from the R engine'").AsCharacter().ToArray();

The error:

Function DATAPTR_OR_NULL not found in native library libR.so

   at DynamicInterop.UnmanagedDll.throwEntryPointNotFound(String entryPoint)
      at DynamicInterop.UnmanagedDll.GetFunction[TDelegate](String entryPoint)
      at RDotNet.Vector`1.get_DataPointer()
      at RDotNet.CharacterVector.SetValue(Int32 index, String value)
      at RDotNet.CharacterVector.SetVectorDirect(String[] values)
      at RDotNet.Vector`1.SetVector(T[] values)
      at RDotNet.REngineExtension.CreateCharacterVector(REngine engine, IEnumerable`1 vector)
      at Ambilytics.Endpoints.System.RTestEndpoint.<>c.<Handle>b__0_0() in /app/Endpoints/System/RTestEndpoint.cs:line 26
      at System.Threading.Tasks.Task`1.InnerInvoke()
      at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   --- End of stack trace from previous location where exception was thrown ---
      at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
   --- End of stack trace from previous location where exception was thrown ---
      at Ambilytics.Endpoints.System.RTestEndpoint.Handle() in /app/Endpoints/System/RTestEndpoint.cs:line 23

Note, the code runs fine on Windows.

I see here a list of functions: https://github.com/rdotnet/rdotnet/blob/ff006e13c167a4a7d1dfa5e0c25059b2b8fb4260/R.NET/Internals/Delegates.cs - looking at the last few (ALL CAPS) ones, they don’t seem to be present in libR.so ? Looking at the other functions listed there, they do seem to exist in the .so… And I can see DATAPTR_OR_NULL export does exist on R.dll on Windows.

I also see that these functions came in here - https://github.com/rdotnet/rdotnet/commit/d935049274d712ae3caa7aadf2689feeecfe0d8b (“Fixed indexing ALTREP integer vectors”)

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
kierenjcommented, Aug 7, 2019

In case anyone else finds it useful, there’s an .NET Core runtime-with-latest-R docker image:

https://github.com/RedRiverSoftware/dockerhub/tree/master/aspnet-runtime-with-r https://hub.docker.com/r/redriversoftware/aspnet-runtime-with-r

1reaction
lrasmuscommented, Jul 7, 2019

@kierenj sorry again about this issue. “Root cause” was lack of testing on Linux on my part - I can see now that it’s not able to complete the check to see if it should use the ALTREP, and defaults to assuming it should use ALTREP (https://github.com/rdotnet/rdotnet/blob/master/R.NET/REngine.cs#L278-L281). I need to get this set up to properly determine version on Linux. I have a test environment set up to verify once a fix is in place.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Net Core web API Docker (Linux) - unable to load ...
NetCore web API and and need to connect with a C++ shared library (libCppAppOutput.so). For this I am using DllImport inside the controller ......
Read more >
Why isn't my ASP.NET Core app in Docker working?
In this post I describe a problem where my ASP.NET Core app in Docker wasn't responding to requests. This post debugs and diagnoses...
Read more >
Running ASP.NET Core in an Alpine Linux Docker Container
The error here is that the debian docker image we are using doesn't have the nightly version of the 2.1 runtime installed and...
Read more >
After upgrading .net core from 3.1 to 5 I'm getting error in ...
I have a native application written in c++ and complied into the .so library through docker which I'm using in the .net core...
Read more >
Building a Native Executable
Mandrel's main goal is to provide a way to build native executables specifically designed to support Quarkus. Mandrel releases are built from a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found