dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.36k stars 4.74k forks source link

crashinfounix.cpp: unknown type name 'off64_t' on Alpine Linux #84665

Closed ayakael closed 10 months ago

ayakael commented 1 year ago

Description

Building runtime v6.0.116 and v7.0.105 and v8.0.0-preview.3.23174.8 on Alpine Linux with clang-16 fails due to following error:

                     [ 68%] Building CXX object vm/wks/CMakeFiles/cee_wks_core.dir/__/assemblyspec.cpp.o
                     [ 68%] Building CXX object tools/superpmi/superpmi-shim-counter/CMakeFiles/superpmi-shim-counter.dir/__/superpmi-shared/errorhandling.cpp.o
                     /var/lib/gitlab-runner/builds/ayakael/dotnet-stage0/src/dotnet-v8.0.100-preview.3.23178.7/src/runtime/src/coreclr/debug/createdump/crashinfounix.cpp:472:49: error: unknown type name 'off64_t'; did you mean 'off_t'?
                             *read = pread64(m_fdMem, buffer, size, (off64_t)address);
                                                                     ^~~~~~~
                                                                     off_t
                     /usr/include/bits/alltypes.h:162:16: note: 'off_t' declared here
                     typedef _Int64 off_t;
                                    ^
                     /var/lib/gitlab-runner/builds/ayakael/dotnet-stage0/src/dotnet-v8.0.100-preview.3.23178.7/src/runtime/src/coreclr/debug/createdump/crashinfounix.cpp:472:17: error: use of undeclared identifier 'pread64'
                             *read = pread64(m_fdMem, buffer, size, (off64_t)address);
                                     ^
                     [ 68%] Building CXX object jit/CMakeFiles/clrjit.dir/fgbasic.cpp.o

Full log: https://lab.ilot.io/ayakael/dotnet-stage0/-/jobs/2058/raw

Reproduction Steps

On Alpine Linux, build any recent tag.

Expected behavior

Build should work

Actual behavior

Build fails

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

ayakael commented 1 year ago

Turns out this is caused by today's update to latest musl.

lttng has similar bug: https://review.lttng.org/c/lttng-tools/+/9268

ayakael commented 1 year ago

The following diff is a workaround:

diff --git a/src/runtime/src/coreclr/debug/createdump/crashinfounix.cpp b/src/runtime/src/coreclr/debug/createdump/crashinfounix.cpp
index 03712c3b684..99d8a457957 100644
--- a/src/runtimr/src/coreclr/debug/createdump/crashinfounix.cpp
+++ b/src/runtime/src/coreclr/debug/createdump/crashinfounix.cpp
@@ -395,7 +395,7 @@ CrashInfo::ReadProcessMemory(void* address, void* buffer, size_t size, size_t* r
         // performance optimization.
         m_canUseProcVmReadSyscall = false;
         assert(m_fd != -1);
-        *read = pread64(m_fd, buffer, size, (off64_t)address);
+        *read = pread(m_fd, buffer, size, (off_t)address);
     }

     if (*read == (size_t)-1)

We'd have to implement something else to maintain libc support.

edit On main:

diff --git a/src/runtime/src/coreclr/debug/createdump/crashinfounix.cpp.orig b/src/runtime/src/coreclr/debug/createdump/crashinfounix.cpp
index 20b2494..165b190 100644
--- a/src/runtime/src/coreclr/debug/createdump/crashinfounix.cpp.orig
+++ b/src/runtime/src/coreclr/debug/createdump/crashinfounix.cpp
@@ -469,7 +469,7 @@ CrashInfo::ReadProcessMemory(void* address, void* buffer, size_t size, size_t* r
         // performance optimization.
         m_canUseProcVmReadSyscall = false;
         assert(m_fdMem != -1);
-        *read = pread64(m_fdMem, buffer, size, (off64_t)address);
+        *read = pread(m_fdMem, buffer, size, (off_t)address);
     }

     if (*read == (size_t)-1)
diff --git a/src/runtime/src/coreclr/debug/createdump/crashinfo.cpp.orig b/src/runtime/src/coreclr/debug/createdump/crashinfo.cpp
index 5addb79..79655d1 100644
--- a/src/runtime/src/coreclr/debug/createdump/crashinfo.cpp.orig
+++ b/src/runtime/src/coreclr/debug/createdump/crashinfo.cpp
@@ -760,7 +760,7 @@ CrashInfo::PageMappedToPhysicalMemory(uint64_t start)
         }

         uint64_t pagemapOffset = (start / PAGE_SIZE) * sizeof(uint64_t);
-        uint64_t seekResult = lseek64(m_fdPagemap, (off64_t) pagemapOffset, SEEK_SET);
+        uint64_t seekResult = lseek(m_fdPagemap, (off_t) pagemapOffset, SEEK_SET);
         if (seekResult != pagemapOffset)
         {
             int seekErrno = errno;
ghost commented 1 year ago

Tagging subscribers to this area: @tommcdon See info in area-owners.md if you want to be subscribed.

Issue Details
### Description Building runtime `v6.0.116` and `v7.0.105` and `v8.0.0-preview.3.23174.8` on Alpine Linux with clang-16 fails due to following error: ``` [ 68%] Building CXX object vm/wks/CMakeFiles/cee_wks_core.dir/__/assemblyspec.cpp.o [ 68%] Building CXX object tools/superpmi/superpmi-shim-counter/CMakeFiles/superpmi-shim-counter.dir/__/superpmi-shared/errorhandling.cpp.o /var/lib/gitlab-runner/builds/ayakael/dotnet-stage0/src/dotnet-v8.0.100-preview.3.23178.7/src/runtime/src/coreclr/debug/createdump/crashinfounix.cpp:472:49: error: unknown type name 'off64_t'; did you mean 'off_t'? *read = pread64(m_fdMem, buffer, size, (off64_t)address); ^~~~~~~ off_t /usr/include/bits/alltypes.h:162:16: note: 'off_t' declared here typedef _Int64 off_t; ^ /var/lib/gitlab-runner/builds/ayakael/dotnet-stage0/src/dotnet-v8.0.100-preview.3.23178.7/src/runtime/src/coreclr/debug/createdump/crashinfounix.cpp:472:17: error: use of undeclared identifier 'pread64' *read = pread64(m_fdMem, buffer, size, (off64_t)address); ^ [ 68%] Building CXX object jit/CMakeFiles/clrjit.dir/fgbasic.cpp.o ``` Full log: https://lab.ilot.io/ayakael/dotnet-stage0/-/jobs/2058/raw ### Reproduction Steps On Alpine Linux, build any recent tag. ### Expected behavior Build should work ### Actual behavior Build fails ### Regression? _No response_ ### Known Workarounds _No response_ ### Configuration _No response_ ### Other information _No response_
Author: ayakael
Assignees: -
Labels: `area-Diagnostics-coreclr`, `untriaged`, `needs-area-label`
Milestone: -
tommcdon commented 1 year ago

Hello @ayakael! Please feel free to submit a PR to main to address this issue.

mikem8361 commented 10 months ago

This has been fixed.