diff options
author | Aaron Brodersen | 2016-08-16 13:16:25 -0500 |
---|---|---|
committer | Aaron Brodersen | 2016-08-16 13:16:25 -0500 |
commit | 36ce6b1e83443b7ebc4ac525e114e83ab491e547 (patch) | |
tree | 22bf8083d967129fecef5a00e8eacef8039ba4f2 | |
parent | a1909572960bb3c8ff9239a2cab5ac1abbb48bb2 (diff) | |
download | aur-36ce6b1e83443b7ebc4ac525e114e83ab491e547.tar.gz |
Fall back to original function when available
Switch to wobbol's patch series that uses the thread-safe code where available but falls back to the non thread-safe code otherwise.
-rw-r--r-- | .SRCINFO | 6 | ||||
-rw-r--r-- | PKGBUILD | 8 | ||||
-rw-r--r-- | glibc-readdir-corefx.patch | 247 | ||||
-rw-r--r-- | readdir-corefx.patch | 56 |
4 files changed, 254 insertions, 63 deletions
@@ -1,7 +1,7 @@ pkgbase = dotnet-cli pkgdesc = A command line utility for building, testing, packaging and running .NET Core applications and libraries pkgver = 1.0.0_preview2_003121 - pkgrel = 3 + pkgrel = 4 url = https://www.microsoft.com/net/core arch = x86_64 license = MIT @@ -25,14 +25,14 @@ pkgbase = dotnet-cli source = gcc6-github-pull-5304.patch source = unused-attr-coreclr.patch source = unused-attr-corefx.patch - source = readdir-corefx.patch + source = glibc-readdir-corefx.patch sha256sums = b49ba545fe632dfd5426669ca3300009a5ffd1ccf3c1cf82303dcf44044db33d sha256sums = 98f9475ea42e5d55ad9402424e342a6c0ea7351f3fb5805a602132969b44b774 sha256sums = dde9f8326583f351a89e57095dc523ba92560896cd1d4b8e0ca5ac7fd8499138 sha256sums = 0905f9f8e6e33a7a6e5f4acf9ec54ec3796400dce28f0d71c1d1d8bcd9b7e068 sha256sums = 8a33c449312f90660d431177f7ee0a36894b75749f79ecf8995c64d82197af90 sha256sums = 9ecdd0ca615b988b67cc4c6a9f5035fb3fb70b16d9281d07c17a28a784a6d4ab - sha256sums = dcd3b066f8efec6a4fc5cf6c927c2a352e06dddb7725c3037044271d773474ca + sha256sums = 210cc1c802f2fd284ebfa6bbf7f7997c616adb5959725b25028a2ca63a568f51 pkgname = dotnet-cli @@ -1,7 +1,7 @@ # Maintainer: Aaron Brodersen <aaron at abrodersen dot com> pkgname=dotnet-cli pkgver="1.0.0_preview2_003121" -pkgrel=3 +pkgrel=4 pkgdesc="A command line utility for building, testing, packaging and running .NET Core applications and libraries" arch=(x86_64) url="https://www.microsoft.com/net/core" @@ -29,7 +29,7 @@ source=( 'gcc6-github-pull-5304.patch' 'unused-attr-coreclr.patch' 'unused-attr-corefx.patch' - 'readdir-corefx.patch') + 'glibc-readdir-corefx.patch') noextract=("${pkgname}-${pkgver}.tar.gz") sha256sums=('b49ba545fe632dfd5426669ca3300009a5ffd1ccf3c1cf82303dcf44044db33d' '98f9475ea42e5d55ad9402424e342a6c0ea7351f3fb5805a602132969b44b774' @@ -37,7 +37,7 @@ sha256sums=('b49ba545fe632dfd5426669ca3300009a5ffd1ccf3c1cf82303dcf44044db33d' '0905f9f8e6e33a7a6e5f4acf9ec54ec3796400dce28f0d71c1d1d8bcd9b7e068' '8a33c449312f90660d431177f7ee0a36894b75749f79ecf8995c64d82197af90' '9ecdd0ca615b988b67cc4c6a9f5035fb3fb70b16d9281d07c17a28a784a6d4ab' - 'dcd3b066f8efec6a4fc5cf6c927c2a352e06dddb7725c3037044271d773474ca') + '210cc1c802f2fd284ebfa6bbf7f7997c616adb5959725b25028a2ca63a568f51') prepare() { cd "${srcdir}/${_coreclr}" @@ -46,7 +46,7 @@ prepare() { cd "${srcdir}/${_corefx}" patch -p1 < "${srcdir}/unused-attr-corefx.patch" - patch -p1 < "${srcdir}/readdir-corefx.patch" + patch -p1 < "${srcdir}/glibc-readdir-corefx.patch" } build() { diff --git a/glibc-readdir-corefx.patch b/glibc-readdir-corefx.patch new file mode 100644 index 000000000000..baabf4846525 --- /dev/null +++ b/glibc-readdir-corefx.patch @@ -0,0 +1,247 @@ +From 335b1f8553107a73077ae0a2dcf094911d390ece Mon Sep 17 00:00:00 2001 +From: "R. Fontenot" <nfontenot27@gmail.com> +Date: Sun, 14 Aug 2016 23:56:00 -0500 +Subject: [PATCH 1/5] Replace readdir_r() with readdir() + +readdir_r() is deprecated in glibc >= v2.24 +--- + src/Native/System.Native/pal_io.cpp | 19 ++++++++++--------- + 1 file changed, 10 insertions(+), 9 deletions(-) + +diff --git a/src/Native/System.Native/pal_io.cpp b/src/Native/System.Native/pal_io.cpp +index 7da1bff..9bd0ec8 100644 +--- a/src/Native/System.Native/pal_io.cpp ++++ b/src/Native/System.Native/pal_io.cpp +@@ -339,27 +339,28 @@ extern "C" int32_t SystemNative_ReadDirR(DIR* dir, void* buffer, int32_t bufferS + return ERANGE; + } + +- dirent* result = nullptr; +- dirent* entry = static_cast<dirent*>(buffer); +- int error = readdir_r(dir, entry, &result); ++ // readdir returns a pointer to memory that may be staticly allocated ++ // by glibc. Data returned by readdir may be overwritten by other readdir ++ // calls for the same directory stream. ++ errno = 0; ++ dirent* entry = readdir(dir); + + // positive error number returned -> failure +- if (error != 0) ++ if (errno != 0) + { +- assert(error > 0); ++ assert(error == EBADF); // Invalid directory stream discriptor dir. + *outputEntry = {}; // managed out param must be initialized +- return error; ++ return errno; + } + + // 0 returned with null result -> end-of-stream +- if (result == nullptr) ++ if (entry == nullptr) + { + *outputEntry = {}; // managed out param must be initialized + return -1; // shim convention for end-of-stream + } + +- // 0 returned with non-null result (guaranteed to be set to entry arg) -> success +- assert(result == entry); ++ memcpy(buffer,entry,static_cast<size_t>(bufferSize)); + ConvertDirent(*entry, outputEntry); + return 0; + } +-- +2.9.2 + +From a74fa9876a8479e206a3357c481ffbe574b9fa9c Mon Sep 17 00:00:00 2001 +From: "R. Fontenot" <nfontenot27@gmail.com> +Date: Mon, 15 Aug 2016 10:42:54 -0500 +Subject: [PATCH 2/5] Clean up discrepancies in the documentation. + +--- + src/Native/System.Native/pal_io.cpp | 17 ++++++++++------- + 1 file changed, 10 insertions(+), 7 deletions(-) + +diff --git a/src/Native/System.Native/pal_io.cpp b/src/Native/System.Native/pal_io.cpp +index 9bd0ec8..6977f0d 100644 +--- a/src/Native/System.Native/pal_io.cpp ++++ b/src/Native/System.Native/pal_io.cpp +@@ -321,12 +321,15 @@ extern "C" int32_t SystemNative_GetDirentSize() + // size of the dirent struct. + // 2) The managed code creates a byte[] buffer of the size of the native dirent + // and passes a pointer to this buffer to this function. +-// 3) This function passes input byte[] buffer to the OS to fill with dirent data +-// which makes the 1st strcpy. +-// 4) The ConvertDirent function will set a pointer to the start of the inode name +-// in the byte[] buffer so the managed code and find it and copy it out of the ++// 3) This function gets a pointer to the possibly staticly allocated directory entry. ++// 4) Then, byte[] entry is copied into the byte[] buffer for bufferSize bytes. ++// This makes the 1st strcpy. ++// 5) The ConvertDirent function will set a pointer to the start of the inode name ++// in the byte[] buffer so the managed code can find it and copy it out of the + // buffer into a managed string that the caller of the framework can use, making + // the 2nd and final strcpy. ++// ++// To make this function thread safe ensure calls on the same DIR* dir never happen concurrently. + extern "C" int32_t SystemNative_ReadDirR(DIR* dir, void* buffer, int32_t bufferSize, DirectoryEntry* outputEntry) + { + assert(buffer != nullptr); +@@ -339,10 +342,10 @@ extern "C" int32_t SystemNative_ReadDirR(DIR* dir, void* buffer, int32_t bufferS + return ERANGE; + } + +- // readdir returns a pointer to memory that may be staticly allocated +- // by glibc. Data returned by readdir may be overwritten by other readdir +- // calls for the same directory stream. + errno = 0; ++ // returns a pointer to memory that may be staticly allocated by glibc. ++ // Data returned by readdir may be overwritten by other readdir calls ++ // on the same directory stream. + dirent* entry = readdir(dir); + + // positive error number returned -> failure +-- +2.9.2 + +From 53f6a769d1a1269b4936cbd4dc7b359d48729ed7 Mon Sep 17 00:00:00 2001 +From: "R. Fontenot" <nfontenot27@gmail.com> +Date: Tue, 16 Aug 2016 09:36:08 -0500 +Subject: [PATCH 3/5] Add readdir_r cxx_check_source_compiles + +--- + src/Native/configure.cmake | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +diff --git a/src/Native/configure.cmake b/src/Native/configure.cmake +index 017d75f..abc0360 100644 +--- a/src/Native/configure.cmake ++++ b/src/Native/configure.cmake +@@ -174,6 +174,20 @@ check_cxx_source_compiles( + + check_cxx_source_compiles( + " ++ #include <dirent.h> ++ int main(void) ++ { ++ DIR* dir; ++ struct dirent* entry; ++ struct dirent* result; ++ readdir_r(dir,entry,&result); ++ return 0; ++ } ++ " ++ HAVE_GNU_READDIR_R) ++ ++check_cxx_source_compiles( ++ " + #include <sys/types.h> + #include <sys/event.h> + int main(void) +-- +2.9.2 + +From ed8510abf9cebb4d0d5d00c28bfb355768bb0c9b Mon Sep 17 00:00:00 2001 +From: "R. Fontenot" <nfontenot27@gmail.com> +Date: Tue, 16 Aug 2016 09:54:38 -0500 +Subject: [PATCH 4/5] Add copy of SystemNative_ReadDirR() from master + +--- + src/Native/System.Native/pal_io.cpp | 51 ++++++++++++++++++++++++++++++++ + 1 file changed, 51 insertions(+) + +diff --git a/src/Native/System.Native/pal_io.cpp b/src/Native/System.Native/pal_io.cpp +index 6977f0d..b7908b5 100644 +--- a/src/Native/System.Native/pal_io.cpp ++++ b/src/Native/System.Native/pal_io.cpp +@@ -316,6 +316,56 @@ extern "C" int32_t SystemNative_GetDirentSize() + return sizeof(dirent); + } + ++#if defined HAVE_GNU_READDIR_R ++// To reduce the number of string copies, this function calling pattern works as follows: ++// 1) The managed code calls GetDirentSize() to get the platform-specific ++// size of the dirent struct. ++// 2) The managed code creates a byte[] buffer of the size of the native dirent ++// and passes a pointer to this buffer to this function. ++// 3) This function passes input byte[] buffer to the OS to fill with dirent data ++// which makes the 1st strcpy. ++// 4) The ConvertDirent function will set a pointer to the start of the inode name ++// in the byte[] buffer so the managed code and find it and copy it out of the ++// buffer into a managed string that the caller of the framework can use, making ++// the 2nd and final strcpy. ++extern "C" int32_t SystemNative_ReadDirR(DIR* dir, void* buffer, int32_t bufferSize, DirectoryEntry* outputEntry) ++{ ++ assert(buffer != nullptr); ++ assert(dir != nullptr); ++ assert(outputEntry != nullptr); ++ ++ if (bufferSize < static_cast<int32_t>(sizeof(dirent))) ++ { ++ assert(false && "Buffer size too small; use GetDirentSize to get required buffer size"); ++ return ERANGE; ++ } ++ ++ dirent* result = nullptr; ++ dirent* entry = static_cast<dirent*>(buffer); ++ int error = readdir_r(dir, entry, &result); ++ ++ // positive error number returned -> failure ++ if (error != 0) ++ { ++ assert(error > 0); ++ *outputEntry = {}; // managed out param must be initialized ++ return error; ++ } ++ ++ // 0 returned with null result -> end-of-stream ++ if (result == nullptr) ++ { ++ *outputEntry = {}; // managed out param must be initialized ++ return -1; // shim convention for end-of-stream ++ } ++ ++ // 0 returned with non-null result (guaranteed to be set to entry arg) -> success ++ assert(result == entry); ++ ConvertDirent(*entry, outputEntry); ++ return 0; ++} ++ ++#else + // To reduce the number of string copies, this function calling pattern works as follows: + // 1) The managed code calls GetDirentSize() to get the platform-specific + // size of the dirent struct. +@@ -367,6 +417,7 @@ extern "C" int32_t SystemNative_ReadDirR(DIR* dir, void* buffer, int32_t bufferS + ConvertDirent(*entry, outputEntry); + return 0; + } ++#endif + + extern "C" DIR* SystemNative_OpenDir(const char* path) + { +-- +2.9.2 + +From 59bd06622e1d0894954ce7e625ccf019953831e8 Mon Sep 17 00:00:00 2001 +From: "R. Fontenot" <nfontenot27@gmail.com> +Date: Tue, 16 Aug 2016 09:56:47 -0500 +Subject: [PATCH 5/5] Fix assert + +--- + src/Native/System.Native/pal_io.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/Native/System.Native/pal_io.cpp b/src/Native/System.Native/pal_io.cpp +index b7908b5..e5e7a4f 100644 +--- a/src/Native/System.Native/pal_io.cpp ++++ b/src/Native/System.Native/pal_io.cpp +@@ -401,7 +401,7 @@ extern "C" int32_t SystemNative_ReadDirR(DIR* dir, void* buffer, int32_t bufferS + // positive error number returned -> failure + if (errno != 0) + { +- assert(error == EBADF); // Invalid directory stream discriptor dir. ++ assert(errno == EBADF); // Invalid directory stream discriptor dir. + *outputEntry = {}; // managed out param must be initialized + return errno; + } +-- +2.9.2 diff --git a/readdir-corefx.patch b/readdir-corefx.patch deleted file mode 100644 index 3d883607e1c5..000000000000 --- a/readdir-corefx.patch +++ /dev/null @@ -1,56 +0,0 @@ -From ff19a05146e100456b30accb774001ac12a76f6b Mon Sep 17 00:00:00 2001 -From: Aaron Brodersen <aaron@abrodersen.com> -Date: Mon, 15 Aug 2016 10:32:33 -0500 -Subject: [PATCH] Remove deprecated readdir_r invocation - -Credit to sixpindin for the patch. This patch resolves this Github -issue: https://github.com/dotnet/corefx/issues/10712 ---- - src/Native/System.Native/pal_io.cpp | 20 ++++++++++---------- - 1 file changed, 10 insertions(+), 10 deletions(-) - -diff --git a/src/Native/System.Native/pal_io.cpp b/src/Native/System.Native/pal_io.cpp -index 7da1bff..47d87d4 100644 ---- a/src/Native/System.Native/pal_io.cpp -+++ b/src/Native/System.Native/pal_io.cpp -@@ -339,27 +339,27 @@ extern "C" int32_t SystemNative_ReadDirR(DIR* dir, void* buffer, int32_t bufferS - return ERANGE; - } - -- dirent* result = nullptr; - dirent* entry = static_cast<dirent*>(buffer); -- int error = readdir_r(dir, entry, &result); - -- // positive error number returned -> failure -- if (error != 0) -+ errno = 0; -+ entry = readdir(dir); -+ -+ // When an error is encountered, a null pointer shall be returned and errno shall be set to indicate the error. -+ if (entry == nullptr && errno != 0) - { -- assert(error > 0); -+ assert(errno > 0); - *outputEntry = {}; // managed out param must be initialized -- return error; -+ return errno; - } - -- // 0 returned with null result -> end-of-stream -- if (result == nullptr) -+ // When the end of the directory is encountered, a null pointer shall be returned and errno is not changed. -+ if (entry == nullptr) - { - *outputEntry = {}; // managed out param must be initialized - return -1; // shim convention for end-of-stream - } - -- // 0 returned with non-null result (guaranteed to be set to entry arg) -> success -- assert(result == entry); -+ // Upon successful completion, readdir() shall return a pointer to an object of type struct dirent. - ConvertDirent(*entry, outputEntry); - return 0; - } --- -2.9.2 - |