Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libutp] Member access within misaligned address for type 'UTPSocketKeyData', which requires 8 byte alignment #5631

Closed
Coeur opened this issue Jun 17, 2023 · 6 comments

Comments

@Coeur
Copy link
Collaborator

Coeur commented Jun 17, 2023

What is the issue?

Undefined Behavior Runtime error in libutp, on that line:
https://github.com/transmission/libutp/blob/c95738b1a6644b919e5b64d3ea9736cfc5894e0b/utp_internal.cpp#L2574

Thread 6: Misaligned pointer use
Member access within misaligned address 0x0001570734ec for type 'UTPSocketKeyData', which requires 8 byte alignment

It's not a crash, but as it says, it's undefined behavior.
The Xcode documentation to attempt to resolve that is at https://developer.apple.com/documentation/xcode/misaligned-pointer.

Historically, that piece of code is from 2013 (transmission/libutp@3652544). We kind of branched off libutp from a commit of July 2017 (https://github.com/transmission/libutp/tree/d7daf7f36f64da975fc1b42772f774cbd5ffbbf1), but the official bittorrent repo has been abandoned since then, so no one else is maintaining libutp officially.

Capture d’écran 2023-06-18 à 00 21 02
Thread 6#0	0x0000000104f08eb4 in __ubsan_on_report ()
#1	0x0000000104f08f68 in __ubsan::UndefinedBehaviorReport::UndefinedBehaviorReport(char const*, __ubsan::Location&, __sanitizer::InternalScopedString&) ()
#2	0x0000000104f048f8 in __ubsan::Diag::~Diag() ()
#3	0x0000000104f06234 in handleTypeMismatchImpl(__ubsan::TypeMismatchData*, unsigned long, __ubsan::ReportOptions) ()
#4	0x0000000104f05ebc in __ubsan_handle_type_mismatch_v1 ()
#5	0x00000001033a44d8 in utp_initialize_socket(UTPSocket*, sockaddr const*, unsigned int, bool, unsigned int, unsigned int, unsigned int) at /Users/User/Developer/transmission/third-party/libutp/utp_internal.cpp:2574
#6	0x00000001033a7cfc in ::utp_connect(utp_socket *, const sockaddr *, socklen_t) at /Users/User/Developer/transmission/third-party/libutp/utp_internal.cpp:2748
#7	0x0000000102bcbfe8 in tr_peerIo::new_outgoing(tr_session*, tr_bandwidth*, tr_address const&, tr_port, std::__1::array<std::byte, 20ul> const&, bool, bool) at /Users/User/Developer/transmission/libtransmission/peer-io.cc:142
#8	0x0000000102bf647c in (anonymous namespace)::connect_helpers::initiateConnection(tr_peerMgr*, tr_swarm*, peer_atom&) at /Users/User/Developer/transmission/libtransmission/peer-mgr.cc:2451
#9	0x0000000102bf3608 in tr_peerMgr::makeNewPeerConnections(unsigned long) at /Users/User/Developer/transmission/libtransmission/peer-mgr.cc:2490
#10	0x0000000102bf2598 in tr_peerMgr::reconnectPulse() at /Users/User/Developer/transmission/libtransmission/peer-mgr.cc:2156
#11	0x0000000102bf39b8 in tr_peerMgr::bandwidthPulse() at /Users/User/Developer/transmission/libtransmission/peer-mgr.cc:2221
#12	0x0000000102bfeac4 in tr_peerMgr::tr_peerMgr(tr_session*)::'lambda'()::operator()() const at /Users/User/Developer/transmission/libtransmission/peer-mgr.cc:689
#13	0x0000000102bfea6c in decltype(std::declval<tr_peerMgr::tr_peerMgr(tr_session*)::'lambda'()&>()()) std::__1::__invoke[abi:v160002]<tr_peerMgr::tr_peerMgr(tr_session*)::'lambda'()&>(tr_peerMgr::tr_peerMgr(tr_session*)::'lambda'()&) at /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/include/c++/v1/__functional/invoke.h:394
#14	0x0000000102bfe8dc in void std::__1::__invoke_void_return_wrapper<void, true>::__call<tr_peerMgr::tr_peerMgr(tr_session*)::'lambda'()&>(tr_peerMgr::tr_peerMgr(tr_session*)::'lambda'()&) at /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/include/c++/v1/__functional/invoke.h:487
#15	0x0000000102bfe870 in std::__1::__function::__alloc_func<tr_peerMgr::tr_peerMgr(tr_session*)::'lambda'(), std::__1::allocator<tr_peerMgr::tr_peerMgr(tr_session*)::'lambda'()>, void ()>::operator()[abi:v160002]() at /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/include/c++/v1/__functional/function.h:185
#16	0x0000000102bfa778 in std::__1::__function::__func<tr_peerMgr::tr_peerMgr(tr_session*)::'lambda'(), std::__1::allocator<tr_peerMgr::tr_peerMgr(tr_session*)::'lambda'()>, void ()>::operator()() at /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/include/c++/v1/__functional/function.h:356
#17	0x0000000102b81754 in std::__1::__function::__value_func<void ()>::operator()[abi:v160002]() const at /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/include/c++/v1/__functional/function.h:510
#18	0x0000000102b7ff90 in std::__1::function<void ()>::operator()() const at /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/include/c++/v1/__functional/function.h:1156
#19	0x00000001030e0ab0 in libtransmission::EvTimer::handleTimer() at /Users/User/Developer/transmission/libtransmission/timer-ev.cc:145
#20	0x00000001030dfd40 in libtransmission::EvTimer::onTimer(int, short, void*) at /Users/User/Developer/transmission/libtransmission/timer-ev.cc:137
#21	0x0000000103286868 in event_persist_closure at /Users/User/Developer/transmission/third-party/libevent/event.c:1623
#22	0x000000010328255c in event_process_active_single_queue at /Users/User/Developer/transmission/third-party/libevent/event.c:1682
#23	0x00000001032621d8 in event_process_active at /Users/User/Developer/transmission/third-party/libevent/event.c:1783
#24	0x000000010325b600 in event_base_loop at /Users/User/Developer/transmission/third-party/libevent/event.c:2006
#25	0x0000000102b7e790 in tr_session_thread_impl::sessionThreadFunc(event_base*) at /Users/User/Developer/transmission/libtransmission/session-thread.cc:245
#26	0x0000000102b83980 in decltype(*std::declval<tr_session_thread_impl*>().*std::declval<void (tr_session_thread_impl::*)(event_base*)>()(std::declval<event_base*>())) std::__1::__invoke[abi:v160002]<void (tr_session_thread_impl::*)(event_base*), tr_session_thread_impl*, event_base*, void>(void (tr_session_thread_impl::*&&)(event_base*), tr_session_thread_impl*&&, event_base*&&) at /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/include/c++/v1/__functional/invoke.h:359
#27	0x0000000102b838ac in void std::__1::__thread_execute[abi:v160002]<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, void (tr_session_thread_impl::*)(event_base*), tr_session_thread_impl*, event_base*, 2ul, 3ul>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, void (tr_session_thread_impl::*)(event_base*), tr_session_thread_impl*, event_base*>&, std::__1::__tuple_indices<2ul, 3ul>) at /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/include/c++/v1/thread:288
#28	0x0000000102b82770 in void* std::__1::__thread_proxy[abi:v160002]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, void (tr_session_thread_impl::*)(event_base*), tr_session_thread_impl*, event_base*>>(void*) at /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/include/c++/v1/thread:299
#29	0x0000000104b61628 in _pthread_start ()

Which application of Transmission?

macOS app

Which version of Transmission?

4.1.0-dev (76166d8)

@ckerr
Copy link
Member

ckerr commented Jun 18, 2023

This is not fixable in transmission/transmission; @Coeur could you close this ticket and open new ones at https://github.com/bittorrent/libutp (for posterity) and at https://github.com/transmission/libutp (since, as you pointed out, upstream is abandoned and so we'd need to fix this in our fork)

@tearfur
Copy link
Member

tearfur commented Jun 19, 2023

Might as well skip the issue at https://github.com/bittorrent/libutp and open a PR directly if this will be fixed in Transmission's fork.

@ckerr
Copy link
Member

ckerr commented Jun 19, 2023

bittorrent/utp still has a lot of forks & watchers and is still the canonical repo even though it's currently dormant.

So even though the issue will just sit there in that repo, it's probably good to have a tracking issue there anyway that links to the issue / PR in the Transmission fork. 🤷‍♂️

@Coeur
Copy link
Collaborator Author

Coeur commented Jun 19, 2023

lol, apparently I opened that issue there already last year, but had forgotten about it:
bittorrent/libutp#136

@tearfur I'm afraid I don't know how to fix that issue with confidence.

@ckerr there are no issue tracker at https://github.com/transmission/libutp

@ckerr
Copy link
Member

ckerr commented Jun 19, 2023

lol, apparently I opened that issue there already last year, but had forgotten about it:
bittorrent/libutp#136

LLOL

@ckerr there are no issue tracker at https://github.com/transmission/libutp

@Coeur I think this should be working now @ https://github.com/transmission/libutp/issues.

@tearfur I'm afraid I don't know how to fix that issue with confidence.

Feel free to assign to me; I at least can investigate it and try & figure it out

@Coeur
Copy link
Collaborator Author

Coeur commented Jun 19, 2023

Closing in favor of transmission/libutp#6

@Coeur Coeur closed this as completed Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants