folly icon indicating copy to clipboard operation
folly copied to clipboard

off64_t undefined on alpine

Open benstadin opened this issue 11 months ago • 2 comments

https://github.com/facebook/folly/blob/faedbb468779075a022a9b97c70979a64bf13369/folly/portability/Unistd.h#L23

The missing macro definition results in a build failure on alpine (3.19) with the following error:

folly/system/MemoryMapping.h:102:5: error: 'off64_t' does not name a type; did you mean 'off_t'?
  102 |     off64_t pageSize = 0;
      |     ^~~~~~~
      |     off_t

Defining that macro fixes the issue. Though I do not have a generic solution as a proposal.

benstadin avatar Mar 22 '24 18:03 benstadin

Is this on a 32 or 64-bit platform? It's possible we've just failed to include <sys/types.h>.

Orvid avatar Mar 22 '24 22:03 Orvid

That's alpine 3.19 (docker) on arm64.

Alpine support is basically broken anyways on that platform. I get over a hundred of failed tests (mainly due to segfaults), even though stack size is set generously. From these tests probably the aligned malloc and thread tests are worth taking a look:


# The following tests FAILED:
# 	336 - atomic_shared_ptr_test.AtomicSharedPtr.DeterministicTest (SEGFAULT)
# 	354 - core_cached_shared_ptr_test.CoreCachedSharedPtr.AtomicCoreCachedSharedPtr (SEGFAULT)
# 	403 - dynamic_bounded_queue_test.DynamicBoundedQueue.enqDeq (SEGFAULT)
# 	420 - unbounded_queue_test.UnboundedQueue.enqDeq (SEGFAULT)
# 	474 - executor_test.ManualExecutor.getViaDoesNotDeadlock (SEGFAULT)
# 	484 - fiber_io_executor_test.FiberIOExecutorTest.event_base (SEGFAULT)
# 	487 - global_executor_test.GlobalExecutorTest.GlobalImmutableIOExecutor (SEGFAULT)
# 	489 - global_executor_test.GlobalExecutorTest.GlobalIOExecutor (SEGFAULT)
# 	501 - threaded_executor_test.ThreadedExecutorTest.exception (SEGFAULT)
# 	514 - priority_unbounded_blocking_queue_test.PriorityUnboundedBlockingQueueTest.concurrent_push_pop (SEGFAULT)
# 	520 - unbounded_blocking_queue_test.UnboundedBlockingQueue.concurrentPushPop (SEGFAULT)
# 	564 - lock_free_ring_buffer_test.LockFreeRingBuffer.writesNeverFail (SEGFAULT)
# 	616 - async_file_writer_test.AsyncFileWriter.flush (SEGFAULT)
# 	640 - glog_formatter_test.GlogFormatter.logThreadNameChanged (Failed)
# 	755 - callback_lifetime_test.CallbackLifetimeTest.thenReturnsValue (SEGFAULT)
# 	756 - callback_lifetime_test.CallbackLifetimeTest.thenReturnsValueThrows (SEGFAULT)
# 	757 - callback_lifetime_test.CallbackLifetimeTest.thenReturnsFuture (SEGFAULT)
# 	758 - callback_lifetime_test.CallbackLifetimeTest.thenReturnsFutureThrows (SEGFAULT)
# 	759 - callback_lifetime_test.CallbackLifetimeTest.thenErrorTakesExnReturnsValueMatch (SEGFAULT)
# 	760 - callback_lifetime_test.CallbackLifetimeTest.thenErrorTakesExnReturnsValueMatchThrows (SEGFAULT)
# 	761 - callback_lifetime_test.CallbackLifetimeTest.thenErrorTakesExnReturnsValueWrong (SEGFAULT)
# 	762 - callback_lifetime_test.CallbackLifetimeTest.thenErrorTakesExnReturnsValueWrongThrows (SEGFAULT)
# 	763 - callback_lifetime_test.CallbackLifetimeTest.thenErrorTakesExnReturnsFutureMatch (SEGFAULT)
# 	764 - callback_lifetime_test.CallbackLifetimeTest.thenErrorTakesExnReturnsFutureMatchThrows (SEGFAULT)
# 	765 - callback_lifetime_test.CallbackLifetimeTest.thenErrorTakesExnReturnsFutureWrong (SEGFAULT)
# 	766 - callback_lifetime_test.CallbackLifetimeTest.thenErrorTakesExnReturnsFutureWrongThrows (SEGFAULT)
# 	767 - callback_lifetime_test.CallbackLifetimeTest.thenErrorTakesWrapReturnsValue (SEGFAULT)
# 	768 - callback_lifetime_test.CallbackLifetimeTest.thenErrorTakesWrapReturnsValueThrows (SEGFAULT)
# 	769 - callback_lifetime_test.CallbackLifetimeTest.thenErrorTakesWrapReturnsFuture (SEGFAULT)
# 	770 - callback_lifetime_test.CallbackLifetimeTest.thenErrorTakesWrapReturnsFutureThrows (SEGFAULT)
# 	884 - interrupt_test.Interrupt.futureWithinTimedOut (SEGFAULT)
# 	885 - interrupt_test.Interrupt.semiFutureWithinTimedOut (SEGFAULT)
# 	947 - retrying_test.RetryingTest.policyCappedJitteredExponentialBackoff (SEGFAULT)
# 	948 - retrying_test.RetryingTest.policyCappedJitteredExponentialBackoffUnsafe (SEGFAULT)
# 	951 - retrying_test.RetryingTest.policySleepDefaults (SEGFAULT)
# 	952 - retrying_test.RetryingTest.largeRetries (SEGFAULT)
# 	1011 - via_test.ViaFixture.threadHops (SEGFAULT)
# 	1012 - via_test.ViaFixture.chainVias (SEGFAULT)
# 	1014 - via_test.ViaFixture.viaAssignment (SEGFAULT)
# 	1018 - via_test.Via.viaThenGetWasRacy (SEGFAULT)
# 	1019 - via_test.Via.callbackRace (SEGFAULT)
# 	1025 - via_test.Via.viaRaces (SEGFAULT)
# 	1043 - wait_test.Wait.waitWithDuration (SEGFAULT)
# 	1044 - wait_test.Wait.multipleWait (SEGFAULT)
# 	1045 - wait_test.Wait.WaitPlusThen (SEGFAULT)
# 	1046 - wait_test.Wait.cancelAfterWait (SEGFAULT)
# 	1060 - window_test.Window.parallel (SEGFAULT)
# 	1061 - window_test.Window.parallelWithError (SEGFAULT)
# 	1062 - window_test.Window.allParallelWithError (SEGFAULT)
# 	1263 - AsyncUDPSocketTest.AsyncSocketIntegrationTest.PingPong (SEGFAULT)
# 	1264 - AsyncUDPSocketTest.AsyncSocketIntegrationTest.PingPongNotify (SEGFAULT)
# 	1265 - AsyncUDPSocketTest.AsyncSocketIntegrationTest.PingPongNotifyMmsg (SEGFAULT)
# 	1266 - AsyncUDPSocketTest.AsyncSocketIntegrationTest.PingPongRecvTosDisabled (SEGFAULT)
# 	1267 - AsyncUDPSocketTest.AsyncSocketIntegrationTest.PingPongRecvTos (SEGFAULT)
# 	1268 - AsyncUDPSocketTest.*/ConnectedAsyncSocketIntegrationTest.ConnectedPingPong/* (SEGFAULT)
# 	1269 - AsyncUDPSocketTest.AsyncSocketIntegrationTest.PingPongPauseResumeListening (SEGFAULT)
# 	1280 - AsyncUDPSocketTest.AsyncUDPSocketTest.TestDetachAttach (SEGFAULT)
# 	1301 - EventBaseLocalTest.EventBaseLocalTest.DestructorStressTest (SEGFAULT)
# 	1308 - HHWheelTimerTest.HHWheelTimerTest.ReschedTest (Failed)
# 	1309 - HHWheelTimerTest.HHWheelTimerTest.DeleteWheelInTimeout (Failed)
# 	1317 - HHWheelTimerTest.HHWheelTimerTest.Level1 (Failed)
# 	1320 - NotificationQueueTest.NotificationQueueTest.ConsumeUntilDrained (SEGFAULT)
# 	1321 - NotificationQueueTest.NotificationQueueTest.ConsumeUntilDrainedStress (SEGFAULT)
# 	1322 - NotificationQueueTest.NotificationQueueTest.SendOneEventFD (SEGFAULT)
# 	1323 - NotificationQueueTest.NotificationQueueTest.PutMessagesEventFD (SEGFAULT)
# 	1324 - NotificationQueueTest.NotificationQueueTest.MultiConsumerEventFD (SEGFAULT)
# 	1328 - NotificationQueueTest.NotificationQueueTest.SendOnePipe (SEGFAULT)
# 	1329 - NotificationQueueTest.NotificationQueueTest.PutMessagesPipe (SEGFAULT)
# 	1330 - NotificationQueueTest.NotificationQueueTest.MultiConsumerPipe (SEGFAULT)
# 	1334 - NotificationQueueTest.NotificationQueueTest.UseAfterFork (SEGFAULT)
# 	1353 - RequestContextTest.RequestContextTest.AccessAllThreadsDestructionGuard (SEGFAULT)
# 	1355 - RequestContextTest.RequestContextTryGetTest.TryGetTest (SEGFAULT)
# 	1358 - ScopedEventBaseThreadTest.ScopedEventBaseThreadTest.example (SEGFAULT)
# 	1359 - ScopedEventBaseThreadTest.ScopedEventBaseThreadTest.named_example (SEGFAULT)
# 	1360 - ScopedEventBaseThreadTest.ScopedEventBaseThreadTest.default_manager (SEGFAULT)
# 	1361 - ScopedEventBaseThreadTest.ScopedEventBaseThreadTest.custom_manager (SEGFAULT)
# 	1362 - ScopedEventBaseThreadTest.ScopedEventBaseThreadTest.eb_dtor_in_io_thread (SEGFAULT)
# 	1363 - ScopedEventBaseThreadTest.ScopedEventBaseThreadTest.keepalive (SEGFAULT)
# 	1524 - arena_test.Arena.Clear (Failed)
# 	1675 - baton_test.Baton.pingpongBlocking (SEGFAULT)
# 	1676 - baton_test.Baton.pingpongNonblocking (SEGFAULT)
# 	1679 - baton_test.Baton.timedWaitTimeoutSystemClockBlocking (SEGFAULT)
# 	1680 - baton_test.Baton.timedWaitTimeoutSystemClockNonblocking (SEGFAULT)
# 	1681 - baton_test.Baton.timedWaitSystemClockBlocking (SEGFAULT)
# 	1682 - baton_test.Baton.timedWaitSystemClockNonblocking (SEGFAULT)
# 	1685 - baton_test.Baton.timedWaitTimeoutSteadyClockBlocking (SEGFAULT)
# 	1686 - baton_test.Baton.timedWaitTimeoutSteadyClockNonblocking (SEGFAULT)
# 	1687 - baton_test.Baton.timedWaitSteadyClockBlocking (SEGFAULT)
# 	1688 - baton_test.Baton.timedWaitSteadyClockNonblocking (SEGFAULT)
# 	1700 - lifo_sem_test.LifoSemTest.pingpong (SEGFAULT)
# 	1701 - lifo_sem_test.LifoSemTest.mutex (SEGFAULT)
# 	1705 - lifo_sem_test.LifoSemTest.shutdown_multi (SEGFAULT)
# 	1796 - thread_name_test.ThreadName.getCurrentThreadName (Subprocess aborted)
# 	1801 - small_locks_test.SmallLocks.SpinLockCorrectness (SEGFAULT)
# 	1987 - deterministic_schedule_test.DeterministicSchedule.buggyAdd (SEGFAULT)
# 	1988 - deterministic_schedule_test.DeterministicSchedule.globalInvariants (SEGFAULT)
# 	2108 - fbvector_test.fbvector.clause233613Ambiguity (Failed)
# 	2109 - fbvector_test.fbvector.clause2336111Ambiguity (Failed)
# 	2111 - fbvector_test.fbvector.clause23364Ambiguity (Failed)
# 	2112 - fbvector_test.fbvector.composition (SEGFAULT)
# 	2113 - fbvector_test.fbvector.worksWithStdString (SEGFAULT)
# 	2115 - fbvector_test.fbvector.moveConstruction (Failed)
# 	2116 - fbvector_test.fbvector.emplace (SEGFAULT)
# 	2118 - fbvector_test.fbvector.uniquePtr (SEGFAULT)
# 	2131 - fbvector_test.FBVector.zeroInit (Failed)
# 	2247 - futex_test.Futex.basicDeterministic (SEGFAULT)
# 	2280 - locks_test.SpinLock.Correctness (SEGFAULT)
# 	2333 - memory_test.alignedMalloc.examples (Failed)
# 	2423 - random_test.Random.MultiThreaded (SEGFAULT)
# 	2702 - synchronized_test.SynchronizedTimedTest/*.Timed (SEGFAULT)
# 	2703 - synchronized_test.SynchronizedTimedWithConstTest/*.TimedShared (SEGFAULT)
# Errors while running CTest

benstadin avatar Mar 22 '24 23:03 benstadin

@Orvid I am getting similar kind of compilation error when RCT-Folly is installed through Cocoapods in a React Native application. Folly version is 2024.01.01.00, React Native version is 0.74.2, Xcode 15.4, building for iOS 17.4 simulator.

I think these changes were introduced in this commit because this error was not present on older versions of Folly. Can you please look into this? The error is in Unistd.h -> https://github.com/facebook/folly/blob/faedbb468779075a022a9b97c70979a64bf13369/folly/portability/Unistd.h#L23

Screenshot 2024-06-27 at 4 58 14 PM

SagarSDagdu avatar Jun 27 '24 11:06 SagarSDagdu

Could you check if a newer version of folly fixes this issue?

For your local testing, off_t should be defined in sys/types.h, so adding an explicit #include for it should fix the error for you.

Orvid avatar Jun 27 '24 19:06 Orvid

Including <sys/types.h> explicitly doesn't help.

Screenshot 2024-06-28 at 11 46 29 AM

SagarSDagdu avatar Jun 28 '24 06:06 SagarSDagdu

@Orvid It works if I remove the using directive and change it to typedef, it works correctly on Xcode:

#if defined(__APPLE__) || defined(__EMSCRIPTEN__)

typedef off_t off64_t;  // Use typedef for C compatibility

off64_t lseek64(int fh, off64_t off, int orig);

ssize_t pread64(int fd, void* buf, size_t count, off64_t offset);

#endif

Is the using directive at the right place in the header?

SagarSDagdu avatar Jun 28 '24 06:06 SagarSDagdu

The using is in the right place, but there shouldn't be a difference as far as I know... Oh well, if it works, it works. Could you put up a PR with that fix?

What are the chances apple is defining off64_t via #define?

Orvid avatar Jul 01 '24 22:07 Orvid

@Orvid I have created a pull request: https://github.com/facebook/folly/pull/2248. Please approve whenever you check it, thanks for actively conversing about the issue here.

SagarSDagdu avatar Jul 02 '24 04:07 SagarSDagdu

If apple is defining off64_t via #define then the thing to do would be to #if !defined(off64_t) around that line. Does that happen to work?

yfeldblum avatar Jul 02 '24 23:07 yfeldblum

If apple is defining off64_t via #define then the thing to do would be to #if !defined(off64_t) around that line. Does that happen to work?

I'll check this today

SagarSDagdu avatar Jul 03 '24 02:07 SagarSDagdu

Hi @yfeldblum , the #if !defined(off64_t) approach does not work. I guess Apple is not already defining the off64_t type.

Screenshot 2024-07-03 at 8 35 03 AM

SagarSDagdu avatar Jul 03 '24 03:07 SagarSDagdu