Opened 7 years ago

Closed 7 years ago

#7663 closed defect (fixed)

tor_pthread_helper_fn recv() infinite loop

Reported by: Safari Owned by:
Priority: Medium Milestone: Tor: 0.2.4.x-final
Component: Core Tor/Tor Version: Tor: 0.2.4.5-alpha
Severity: Keywords: tor-relay
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

with tor-0.2.4.6-81fcebcd054:

#0 0x00007f07f5b49577 in libc_recv (fd=fd@entry=36, buf=buf@entry=0x7f07f494aaa0, n=n@entry=1, flags=-1, flags@entry=0) at ../sysdeps/unix/sysv/linux/x86_64/recv.c:34
#1 0x00007f07f74ddbcb in recv (
flags=0, n=1, buf=0x7f07f494aaa0, fd=36) at /usr/include/bits/socket2.h:45
#2 cpuworker_main (data=0x0, data@entry=0x7f07f9e4e9d0) at src/or/cpuworker.c:255
#3 0x00007f07f7519428 in tor_pthread_helper_fn (_data=0x0) at src/common/compat.c:2232
#4 0x00007f07f5842d14 in start_thread (arg=0x7f07f494b700) at pthread_create.c:309
#5 0x00007f07f5b4867d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115
Thread 2 (Thread 0x7f07f474a700 (LWP 8761)):
#0 0x00007f07f5b49577 in
libc_recv (fd=fd@entry=38, buf=buf@entry=0x7f07f4749aa0, n=n@entry=1, flags=-1, flags@entry=0) at ../sysdeps/unix/sysv/linux/x86_64/recv.c:34
#1 0x00007f07f74ddbcb in recv (flags=0, n=1, buf=0x7f07f4749aa0, fd=38) at /usr/include/bits/socket2.h:45
#2 cpuworker_main (data=0x0, data@entry=0x7f07facd3330) at src/or/cpuworker.c:255
#3 0x00007f07f7519428 in tor_pthread_helper_fn (_data=0x0) at src/common/compat.c:2232
#4 0x00007f07f5842d14 in start_thread (arg=0x7f07f474a700) at pthread_create.c:309
#5 0x00007f07f5b4867d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115
Thread 1 (Thread 0x7f07f734b740 (LWP 8738)):
#0 0x00007f07f74a8e66 in circuit_expire_building () at src/or/circuituse.c:384
#1 0x00007f07f7414097 in run_scheduled_events (now=1354900004) at src/or/main.c:1480
#2 second_elapsed_callback (timer=<optimized out>, arg=<optimized out>) at src/or/main.c:1701
#3 0x00007f07f6a940c2 in event_base_loop () from /lib64/libevent-2.0.so.5
#4 0x00007f07f741574d in do_main_loop () at src/or/main.c:1997
#5 0x00007f07f7416c7e in tor_main (argc=3, argv=0x7fff2ecced88) at src/or/main.c:2783
#6 0x00007f07f5a78735 in libc_start_main (main=0x7f07f7410e00 <main>, argc=3, ubp_av=0x7fff2ecced88, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fff2ecced78) at libc-start.c:226
#7 0x00007f07f7410e5d in _start ()

tor-0.2.4.6-ea893a3c30 works ok.
I have Linux kernel 3.7.0-rc8-g18a2f371+

Child Tickets

Change History (5)

comment:1 Changed 7 years ago by nickm

Keywords: tor-relay added
Milestone: Tor: 0.2.4.x-final

Very strange. Can you use "git bisect" to track down which commit or commits might be responsible? I'm not seeing anything in there that would affect the behavior of these functions in any obvious way.

Also, are you able to try running under valgrind? There are instructions in doc/HACKING for how to do so usefully.

comment:2 Changed 7 years ago by Safari

Dec 07 20:39:08.000 [notice] Bootstrapped 90%: Establishing a Tor circuit.
hangs there.

Process 2077 attached with 3 threads
[pid 2080] 20:43:31.606782 recvfrom(15, <unfinished ...>
[pid 2079] 20:43:31.606851 recvfrom(13,

lrwx------ 1 root root 64 2012-12-07 20:43:25.248383201 +0200 /proc/2077/fd/13 -> socket:[184985]

# cat /proc/2077/fdinfo/13
pos: 0
flags: 02000002

42e3c04a7a5fb47a97766e54c72885c5c2bf23a9 is the first bad commit
commit 42e3c04a7a5fb47a97766e54c72885c5c2bf23a9
Author: Mike Perry <mikeperry-git@…>
Date: Thu Oct 25 17:43:10 2012 -0700

Bug 3443: Don't count ORconn setup in circuit build time.


Also, add a hack Roger suggested where we're more patient if no circuits are
opened yet.

:040000 040000 aff26ec7f144f9434e2d19bf10813325eac18333 f1f2c7576f1da20113a9c37f65fcfaaedfb84213 M changes
:040000 040000 45bdbd7389be2597b6846637a3363a285fe718dc 438f6fd7f1c6ff5e6b987ebf0a1e778220606445 M src

comment:3 Changed 7 years ago by nickm

Status: newneeds_information

Hm. I don't think this is actually an infinite loop on recv(). That wouldn't keep you from building circuits as a client, which is what's happening if you're getting nothing after "Bootstrapped 90%: Establishing a Tor circuit".

Ah, here we go. Does commit cd4f56a37c3513cdca3463c3638067380af29219 fix this for you?

comment:4 Changed 7 years ago by Safari

cd4f56a37c3 fixed the issue, thanks

comment:5 Changed 7 years ago by nickm

Resolution: fixed
Status: needs_informationclosed

Excellent! Thanks very much for reporting this and helping track it down so quickly.

Note: See TracTickets for help on using tickets.