Skip to content

Commit c39d0f6

Browse files
committed
fix trafficserver segmentation fault on arm64
on arm64, compression and decompression of pointers are inconsistent add one bit for virtual address in head_p.data
1 parent 01f2b99 commit c39d0f6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

include/tscore/ink_queue.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,12 @@ union head_p {
136136
#define SET_FREELIST_POINTER_VERSION(_x, _p, _v) \
137137
(_x).s.pointer = _p; \
138138
(_x).s.version = _v
139-
#elif defined(__x86_64__) || defined(__ia64__) || defined(__powerpc64__) || defined(__aarch64__) || defined(__mips64)
139+
#elif defined(__aarch64__)
140+
#define FREELIST_POINTER(_x) \
141+
((void *)(((((intptr_t)(_x).data) << 15) >> 15) | (((~((((intptr_t)(_x).data) << 15 >> 63) - 1)) >> 49) << 49))) // sign extend
142+
#define FREELIST_VERSION(_x) (((intptr_t)(_x).data) >> 49)
143+
#define SET_FREELIST_POINTER_VERSION(_x, _p, _v) (_x).data = ((((intptr_t)(_p)) & 0x0001FFFFFFFFFFFFULL) | (((_v)&0xFFFEULL) << 49))
144+
#elif defined(__x86_64__) || defined(__ia64__) || defined(__powerpc64__) || defined(__mips64)
140145
#define FREELIST_POINTER(_x) \
141146
((void *)(((((intptr_t)(_x).data) << 16) >> 16) | (((~((((intptr_t)(_x).data) << 16 >> 63) - 1)) >> 48) << 48))) // sign extend
142147
#define FREELIST_VERSION(_x) (((intptr_t)(_x).data) >> 48)

0 commit comments

Comments
 (0)