Closed szadev closed 1 week ago
the "file" here is a stream with .mpp file. Also, I added the test console log before var result = ..
line and it did not appear int log before crush, so the problem is in the Read(file)
method.
the problem is actual only with the .mpp file, the .xml format works well.
Hi, thanks for raising this issue. Unfortunately there isn't much I can do to diagnose what's happening here, we'd need more detailed information from .Net itself. The log file suggests a segmentation fault (SEGV). Typically I'd expect .Net to be handling this at a much higher level, and for a .Net exception to be raised and reported. SEGV suggests a much lower level problem.
Are you able to run the code successfully under Linux as a user rather than as a daemon/service?
Can you add some code to the catch
block (as shown in your code sample) to report any exceptions being raised in .Net?
Thank you, I will try everything you suggest and get back to you in a few days with the results.
I have tried to run the app as a user, not with a deamon, but have got the same problem. (but log in pict is from deamon) Also, added log for catch block and got nothing in log (pictures below).
Which version of the MPXJ.Net package are you using?
Can you create a simple test project which shows the same behaviour to allow me to test this locally?
I am using 13.3.1 (13.4 the same problem).
Sorry, I didn`t see your reply. I will make the simple project with docker file to show you the problem. Thank you
Hello! Here is a test project with a dockerfile and a simple .mpp file.
small addition. if you want to try another .mpp file with a size greater than 512 000 bytes, then there is a change to provide this:
var fileSize = file.Size;
await using var ms = new MemoryStream();
await file.OpenReadStream(fileSize).CopyToAsync(ms);
Thanks for providing the Dockerfile. I'm trying to get this set up on my machine, in the directory containing Dockerfile
I'm running this:
docker build .
But I found I had to edit this line:
COPY ["MPXJTest/MPXJTest.csproj", "MPXJTest/"]
to remove the MPXJTest/
prefix. After this the build seems to proceed until I get these errors:
87.35 CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [/src/MPXJTest/MPXJTest.csproj]
87.35 931 Warning(s)
87.35 1 Error(s)
87.35
87.35 Time Elapsed 00:01:26.62
------
Dockerfile:14
--------------------
12 | COPY . .
13 | WORKDIR "/src/MPXJTest"
14 | >>> RUN dotnet build "MPXJTest.csproj" -c $BUILD_CONFIGURATION -o /app/build
15 |
16 | FROM build AS publish
--------------------
ERROR: failed to solve: process "/bin/sh -c dotnet build \"MPXJTest.csproj\" -c $BUILD_CONFIGURATION -o /app/build" did not complete successfully: exit code: 1
Can you advise me on where I'm going wrong, and what steps I should be taking to get your code running?
Thanks!
Actually, this dockerfile was automatically generated by JetBrains Raider when I just created a file and ran it from this IDE. I will now check how to run it manually
Sorry, I don't have enough experience with Windows + Docker + .net. So I need a few days to find an answer.
But, if you have a linux virtual machine, you can just install dotnet runtime there (sudo apt-get install -y aspnetcore-runtime-8.0
) and run the builded project with command dotnet MPXJTest.dll
By the way, I will try to write Dockerfiile, i think there is no reason to use all of that autogenerated code in Dockerfile
Hello! I ran this code as docker build .
and it worked. I think it will work on your machine too.
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 8080
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["MPXJTest.csproj", "MPXJTest.csproj"]
RUN dotnet restore "MPXJTest.csproj"
COPY . .
WORKDIR "/src"
RUN dotnet build "MPXJTest.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "MPXJTest.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MPXJTest.dll"]
And then run it docker run -d -p 8080:8080 --name mpxjtest IMAGE_ID
The issue is a missing library. Add the following to your Dockerfile
in the FROM base AS final
section.
RUN apt-get update && apt-get install -y libfontconfig
Some notes for our future selves so we remember how to do this!
The core dump, and running the code in gdb
both showed the segmentation fault was coming from a call to dlclose
, so something related to loading a dynamic library was causing the problem.
I started a container in a bash shell using the built image:
docker run -it -p 8080:8080 --entrypoint bash --name mpxjtest <image id>
Then installed strace
:
apt-get update
apt-get install -y strace
I could then run the application using strace
:
strace -f -e trace=\!futex,sched_yield,madvise,mmap,munmap,mprotect,getrusage dotnet MPXJTest.dll
The -f
argument is important as it allows us to see what child processes and threads are doing. The -e
argument just excludes a lot of repetitive syscalls which would otherwise obscure what's happening.
Here's the relevant bit of the output:
[pid 289] openat(AT_FDCWD, "/app/ikvm/linux-x64/bin/libfontconfig.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 289] openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 675
[pid 289] newfstatat(675, "", {st_mode=S_IFREG|0644, st_size=5278, ...}, AT_EMPTY_PATH) = 0
[pid 289] close(675) = 0
[pid 289] openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libfontconfig.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 289] openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libfontconfig.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 289] openat(AT_FDCWD, "/lib/libfontconfig.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 289] openat(AT_FDCWD, "/usr/lib/libfontconfig.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 289] --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x337} ---
I would have hoped for a more graceful failure and a suitable error message when libfontconfig
wasn't available, but now we can see what the code is trying to do at this point we can ensure libfontconfig
is installed, and everything works!
Thank you so much for your prompt support. I tested it in staging and everything works now!
Hello! After publishing the app for linux-x64 (Ubuntu 22.04.4 LTS), calling read method kills the running app.
Log: