Skip to content

Commit 05f97eb

Browse files
committed
Fix more MacOS crashes due to non-portable local labels (#8278)
Summary: Isolated repro of the problem: https://gist.github.com/fredemmott/e3b7f6f1b41be02e5980416677dd05a6 There's a few issues muddled together here: - the `.l%=` labels were never actually local labels, but were presumably meant to be (`.L`) - labels are case-sensitive, so fixing that made it so that we hit duplicates with other `.L%=` labels in some files, depending on how aggressive the compiler is at inlining (this is an issue with gcc5, but not apple clang) - the crashes on MacOS due to non-local labels weren't an issue on GCC5/Linux - despite them also being non-local labels there - because GCC5/Linux isn't inserting the incorrect `noexcept` frame metadata fixes #8276 Pull Request resolved: #8278 Reviewed By: alexeyt Differential Revision: D9226853 Pulled By: fredemmott
1 parent 4089ed8 commit 05f97eb

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

hphp/runtime/base/hash-table-inl.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
+----------------------------------------------------------------------+
1515
*/
1616

17+
#include "hphp/util/portability.h"
18+
1719
namespace HPHP {
1820

1921
namespace array {
@@ -44,10 +46,10 @@ void HashTableCommon::InitHash(int32_t* hash, uint32_t scale) {
4446
uint64_t offset = scale * 16;
4547
__asm__ __volatile__(
4648
"pcmpeqd %%xmm0, %%xmm0\n" // xmm0 <- 11111....
47-
".l%=:\n"
49+
ASM_LOCAL_LABEL("HTCIH%=") ":\n"
4850
"sub $0x10, %0\n"
4951
"movdqu %%xmm0, (%1, %0)\n"
50-
"ja .l%=\n"
52+
"ja " ASM_LOCAL_LABEL("HTCIH%=") "\n"
5153
: "+r"(offset) : "r"(hash) : "xmm0"
5254
);
5355
#elif defined(__aarch64__)
@@ -58,10 +60,10 @@ void HashTableCommon::InitHash(int32_t* hash, uint32_t scale) {
5860
uint64_t ones = -1;
5961
auto hash2 = hash;
6062
__asm__ __volatile__(
61-
".l%=:\n"
63+
ASM_LOCAL_LABEL("HTCIH%=") ":\n"
6264
"stp %x2, %x2, [%x1], #16\n"
6365
"subs %x0, %x0, #16\n"
64-
"bhi .l%=\n"
66+
"bhi " ASM_LOCAL_LABEL("HTCIH%=") "\n"
6567
: "+r"(offset), "+r"(hash2) : "r"(ones) : "cc"
6668
);
6769
#elif defined(__powerpc__)
@@ -71,10 +73,10 @@ void HashTableCommon::InitHash(int32_t* hash, uint32_t scale) {
7173
uint64_t offset = scale * 16;
7274
__asm__ __volatile__(
7375
"vspltisw 0, -1 \n"
74-
".l%=: \n"
76+
ASM_LOCAL_LABEL("HTCIH%=") ":\n"
7577
"subic. %0, %0, 0x10\n"
7678
"stxvd2x 32, %1, %0 \n"
77-
"bgt .l%= \n"
79+
"bgt " ASM_LOCAL_LABEL("HTCIH%=") "\n"
7880
: "+b"(offset) : "b"(hash) : "v0");
7981
#else
8082
static_assert(Empty == -1, "Cannot use wordfillones().");

hphp/util/etch-helpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#define ETCH_SECTION(x) .text
3737
#define ETCH_SIZE(x) /* not used on OSX */
3838
#define ETCH_NAME(x) _##x
39-
#define ETCH_LABEL(x) .L##_##x
39+
#define ETCH_LABEL(x) L##_##x /* not .L */
4040
#define ETCH_TYPE(x, y) /* not used on OSX */
4141
#define ETCH_NAME_REL(x) _##x@GOTPCREL(%rip)
4242
#define ETCH_ARG1 %rdi

hphp/util/portability.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,4 +268,10 @@
268268
# define MSVC_NO_STD_CHRONO_DURATION_DOUBLE_ADD 1
269269
#endif
270270

271+
#ifdef __APPLE__
272+
#define ASM_LOCAL_LABEL(x) "L" x
273+
#else
274+
#define ASM_LOCAL_LABEL(x) ".L" x
275+
#endif
276+
271277
#endif

hphp/util/word-mem.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,13 @@
2020
#include <folly/Portability.h>
2121

2222
#include "hphp/util/assertions.h"
23+
#include "hphp/util/portability.h"
2324

2425
extern "C" void* _memcpy8(void* dst, const void* src, size_t len);
2526
extern "C" void* _memcpy16(void* dst, const void* src, size_t len);
2627
extern "C" void _bcopy32(void* dst, const void* src, size_t len);
2728
extern "C" void _bcopy_in_64(void* dst, const void* src, size_t lenIn64);
2829

29-
#ifdef __APPLE__
30-
#define ASM_LOCAL_LABEL(x) "L" x
31-
#else
32-
#define ASM_LOCAL_LABEL(x) ".L" x
33-
#endif
34-
3530
namespace HPHP {
3631

3732
/*

0 commit comments

Comments
 (0)