From 2eed6826707ada6596451b76edfdc86f22cfe201 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Glondu?= Date: Fri, 28 Jun 2024 07:53:21 +0200 Subject: [PATCH] Avoid atomic 64-bit load on Debian armel Bug: https://github.com/ocaml/ocaml/issues/13234 Forwarded: https://github.com/ocaml/ocaml/pull/13267 Gbp-Pq: Name 0010-Avoid-atomic-64-bit-load-on-Debian-armel.patch --- otherlibs/runtime_events/runtime_events_consumer.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/otherlibs/runtime_events/runtime_events_consumer.c b/otherlibs/runtime_events/runtime_events_consumer.c index 9df4eb5a..1771df70 100644 --- a/otherlibs/runtime_events/runtime_events_consumer.c +++ b/otherlibs/runtime_events/runtime_events_consumer.c @@ -189,7 +189,16 @@ caml_runtime_events_create_cursor(const char_os* runtime_events_path, int pid, cursor->ring_file_size_bytes = GetFileSize(cursor->ring_file_handle, NULL); #else - ring_fd = open(runtime_events_loc, O_RDONLY, 0); +#if defined(__ARM_ARCH) && __ARM_ARCH <= 5 + /* Atomic 64-bit load requires RW memory on Debian armel. See: + https://github.com/ocaml/ocaml/issues/13234 */ + const int open_flags = O_RDWR; + const int mmap_prot = PROT_READ | PROT_WRITE; +#else + const int open_flags = O_RDONLY; + const int mmap_prot = PROT_READ; +#endif + ring_fd = open(runtime_events_loc, open_flags, 0); if( ring_fd == -1 ) { caml_stat_free(cursor); @@ -210,7 +219,7 @@ caml_runtime_events_create_cursor(const char_os* runtime_events_path, int pid, /* This cast is necessary for compatibility with Illumos' non-POSIX mmap/munmap */ cursor->metadata = (struct runtime_events_metadata_header *) - mmap(NULL, cursor->ring_file_size_bytes, PROT_READ, + mmap(NULL, cursor->ring_file_size_bytes, mmap_prot, MAP_SHARED, ring_fd, 0); if( cursor->metadata == MAP_FAILED ) { -- 2.30.2