simsi
simsi

Reputation: 533

Uncaught signal: 11 when using .net Core Cloud Firestore in Google Cloud

I have created two .net core 3.0 C# services with Cloud Run. When I try to insert a firestore document the application crashes in the cloud. Locally it works with the same firestore connection. One service worked well yesterday. What can I do to debug this problem?

The provided C# code shows

"Uncaught signal: 11, pid=1, tid=13, fault_addr=453942."

as error message in the log of Cloud Run. The crash happens at the line documentRef.SetAsync(plan);. Uncaught signal 11 sounds like a segfault.

The services uses the nuget package Google Cloud Firestore (1.0.0) and Grpc.Core (1.22.1).

[FirestoreData]
public class Plan
{
        [FirestoreProperty]
        public string PlanId{ get; set; }
}

[...]

using Google.Cloud.Firestore;

[...]

var plan = new Plan() { PlanId = "testId"};
Database = FirestoreDb.Create("testing-profile-crawler");
var documentRef = Database.Collection("crawler-plan").Document("test");
documentRef.SetAsync(plan);

Upvotes: 3

Views: 2245

Answers (2)

Jon Skeet
Jon Skeet

Reputation: 1502696

The answer from November 2019 works for Alpine 3.9, but not for 3.10 or 3.11.

There's a new gRPC issue covering that, but I've certainly had success by downgrading libc6-compat as shown in the issue:

RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.8/main' >> /etc/apk/repositories && \
    apk update --no-cache && \
    apk add --no-cache bash libc6-compat=1.1.19-r11

Obviously downgrading a library version is a pretty drastic thing to do - so it's worth testing thoroughly. But it at least works for a test app, so might be helpful to anyone experiencing the same issue.

Upvotes: 2

Jon Skeet
Jon Skeet

Reputation: 1502696

The problem isn't specific to .NET Core - it's really about running gRPC on Alpine. The gRPC native libraries (which are used by Grpc.Core) are built against glibc, which isn't present on Alpine by default.

The gRPC team have a workaround for this, included in their test builds, using a version of glibc built for Alpine. I can't vouch for this other than to say it worked in my testing. It's likely that this is as close to "supported" as gRPC on Alpine is likely to be for now.

The Dockerfile I used that worked starts like this:

FROM mcr.microsoft.com/dotnet/core/aspnet:3.0.0-alpine3.9

RUN apk update && apk --no-cache add ca-certificates wget
RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.30-r0/glibc-2.30-r0.apk
RUN apk add glibc-2.30-r0.apk

... with no installation of libc6-compat or symlinking step. After that you should be able to use the rest of your Dockerfile as before. Note that this uses Alpine 3.9 - the tag of just 3.0.0-alpine didn't work when I tried it.

With the support of gRPC in .NET Core 3.0, it's possible that when we've upgraded our libraries to Grpc.Core 2.x, you'd be able to use the Microsoft gRPC client library instead... but there are some aspects of Grpc.Core that aren't currently supported by that, and I don't expect we'll be able to make it massively easy to use the Microsoft version (although we do want to try).

Upvotes: 2

Related Questions