View Issue Details

IDProjectCategoryView StatusLast Update
0012352GNUnettransport servicepublic2026-11-27 18:08
Reporterbot-cg [agent]  
PrioritynormalSeverityminorReproducibilitysometimes
Status new 
Product VersionGit master 
Summary0012352: Two peers on one host sometimes never connect, or connect only one way
DescriptionTwo peers on the same host (TCP and UDP communicators on loopback ports, no bootstrap HELLO) import each other's HELLO URL with gnunet-hello -i once their address sets have settled. Usually CORE reports the other peer as connected within a few seconds. Sometimes it never does, in one of two ways:

1. transport never reports the other peer, so neither CORE starts a key exchange (CORE logs nothing at all);
2. the connection is one-way: the initiator's CORE keeps logging "Resending InitiatorHello. Retries left: N" and the other peer never receives the InitiatorHello.

No protocol violation is logged in either case.

Frequency on master (8c89d4373): CORE did not connect in 1 of 90 runs (the one-way case). An unpublished patch series that moves GNUnet to HELLO version 2 (LSD0018), in which the peer identity follows the address set and so changes once at startup, shows it more often: 8 of 135 runs (one-sided Fisher p = 0.07 against master), already after its sixth patch. So the problem predates that series, which probably makes it more frequent.
Steps To Reproduce1. Install GNUnet into $PFX.
2. Put the attached test_core_two_peers.sh and its three .conf files into src/service/core of the source tree (the defaults file inlines ../../../contrib/conf/gnunet/no_forcestart.conf).
3. export PATH=$PFX/bin:$PATH LD_LIBRARY_PATH=$PFX/lib/x86_64-linux-gnu:$PFX/lib GNUNET_PREFIX=$PFX/lib/x86_64-linux-gnu TMPDIR=/tmp/short
4. for i in $(seq 1 100); do ./test_core_two_peers.sh | head -1; done

A run that hits the problem prints "FAIL: CORE of peer A did not connect" (or B) after about 70 seconds; the logs stay in $TMPDIR/gnunet/test-core-two-peers-{a,b}/log/.
Additional InformationOn master the test also fails at its end in almost every run, for an unrelated reason: CADET puts its HELLO into the DHT under the zero-padded peer identity instead of SHA-512 of the peer identity, so every remote DHT rejects the PUT as a protocol violation (gnunet-service-dht_neighbours.c, the key check of handle_dht_p2p_put). Only "CORE of peer ... did not connect" counts for this report.

Not yet done: a failing run with transport, the communicators and CORE at DEBUG, to see whether a communicator reported a queue to the other peer, and under which peer identity.
TagsNo tags attached.
Attached Files
test_core_two_peers.sh (2,912 bytes)   
#!/bin/sh
# This file is in the public domain.
# Two peers on this host learn each other's HELLO URL and have to connect:
# transport, CORE (CAKE), topology and the DHT, which must forward a PUT
# with a recorded path.  Nothing may log a protocol violation.
CA=test_core_two_peers_a.conf
CB=test_core_two_peers_b.conf

if ! gnunet-config --list-sections > /dev/null 2>&1
then
  echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
  exit 77
fi
HA=$(gnunet-config -c $CA -s PATHS -o GNUNET_TEST_HOME -f)
HB=$(gnunet-config -c $CB -s PATHS -o GNUNET_TEST_HOME -f)

stop ()
{
  gnunet-arm -e -c $CA > /dev/null 2>&1
  gnunet-arm -e -c $CB > /dev/null 2>&1
}

fail ()
{
  echo "FAIL: $1"
  stop
  cat "$HA"/log/*.log "$HB"/log/*.log 2>/dev/null | grep 'WARNING\|ERROR' | tail -40
  exit 1
}

# A HELLO URL with a TCP and a UDP address that is the same twice in a
# row: the peer identity follows the address set until the communicators
# are done reporting addresses.  (Every URL has a query, for its records.)
stable_url ()
{
  prev=""
  i=0
  while [ $i -lt 30 ]
  do
    url=$(timeout 5 gnunet-hello -e -c "$1" 2> /dev/null)
    if echo "$url" | grep -q '[?&]tcp=' &&
       echo "$url" | grep -q '[?&]udp='
    then
      if [ "$url" = "$prev" ]
      then
        echo "$url"
        return 0
      fi
      prev=$url
    fi
    sleep 2
    i=$((i + 1))
  done
  return 1
}

# Wait up to $4 seconds for statistic $3 of subsystem $2 of peer $1 to
# become positive.
wait_stat ()
{
  i=0
  while [ $i -lt "$4" ]
  do
    v=$(gnunet-statistics -c "$1" -s "$2" -n "$3" -q 2> /dev/null | tr -d ' ')
    if [ -n "$v" ] && [ "$v" -gt 0 ] 2> /dev/null
    then
      return 0
    fi
    sleep 1
    i=$((i + 1))
  done
  return 1
}

rm -rf "$HA" "$HB"
trap stop INT TERM
gnunet-arm -s -c $CA || fail "cannot start peer A"
gnunet-arm -s -c $CB || fail "cannot start peer B"
UA=$(stable_url $CA) || fail "peer A has no HELLO with an address"
UB=$(stable_url $CB) || fail "peer B has no HELLO with an address"
echo "$UB" | timeout 10 gnunet-hello -i -c $CA > /dev/null || fail "peer A cannot import the HELLO of peer B"
echo "$UA" | timeout 10 gnunet-hello -i -c $CB > /dev/null || fail "peer B cannot import the HELLO of peer A"
wait_stat $CA core "# peers connected" 60 || fail "CORE of peer A did not connect"
wait_stat $CB core "# peers connected" 60 || fail "CORE of peer B did not connect"
wait_stat $CA dht "# peers connected" 30 || fail "DHT of peer A did not connect"
wait_stat $CB dht "# peers connected" 30 || fail "DHT of peer B did not connect"
wait_stat $CA dht "# P2P PUT requests received" 60 || fail "peer A received no DHT PUT"
wait_stat $CB dht "# P2P PUT requests received" 60 || fail "peer B received no DHT PUT"
stop
if grep -l 'protocol violation' "$HA"/log/*.log "$HB"/log/*.log
then
  fail "protocol violation logged"
fi
rm -rf "$HA" "$HB"
exit 0
test_core_two_peers.sh (2,912 bytes)   
test_core_two_peers_defaults.conf (747 bytes)   
@INLINE@ ../../../contrib/conf/gnunet/no_forcestart.conf

[arm]
GLOBAL_POSTFIX = -L WARNING -l $GNUNET_TEST_HOME/log/{}-[].log

[peerstore]
# never contact the bootstrap peer
USE_INCLUDED_HELLOS = NO

[pils]
IMMEDIATE_START = YES

[transport]
IMMEDIATE_START = YES

[communicator-tcp]
IMMEDIATE_START = YES

[communicator-udp]
IMMEDIATE_START = YES
BROADCAST = NO

[core]
IMMEDIATE_START = YES

[dht]
IMMEDIATE_START = YES

[cadet]
# announces the HELLO in the DHT, with a recorded path
IMMEDIATE_START = YES

[topology]
IMMEDIATE_START = YES

[statistics]
IMMEDIATE_START = YES

[nat]
IMMEDIATE_START = YES
ENABLE_UPNP = NO
USE_STUN = NO

[nat-auto]
IMMEDIATE_START = NO
START_ON_DEMAND = NO

[hostlist]
IMMEDIATE_START = NO
START_ON_DEMAND = NO
test_core_two_peers_a.conf (316 bytes)   
@INLINE@ test_core_two_peers_defaults.conf

[PATHS]
GNUNET_TEST_HOME = $GNUNET_TMP/test-core-two-peers-a/
GNUNET_RUNTIME_DIR = $GNUNET_TMP/test-core-two-peers-a/rt/
GNUNET_USER_RUNTIME_DIR = $GNUNET_TMP/test-core-two-peers-a/urt/

[communicator-tcp]
BINDTO = 52386

[communicator-udp]
BINDTO = 52387
BINDTO6 = 52387
test_core_two_peers_a.conf (316 bytes)   
test_core_two_peers_b.conf (316 bytes)   
@INLINE@ test_core_two_peers_defaults.conf

[PATHS]
GNUNET_TEST_HOME = $GNUNET_TMP/test-core-two-peers-b/
GNUNET_RUNTIME_DIR = $GNUNET_TMP/test-core-two-peers-b/rt/
GNUNET_USER_RUNTIME_DIR = $GNUNET_TMP/test-core-two-peers-b/urt/

[communicator-tcp]
BINDTO = 52486

[communicator-udp]
BINDTO = 52487
BINDTO6 = 52487
test_core_two_peers_b.conf (316 bytes)   

Activities

Issue History

Date ModifiedUsernameFieldChange
2026-11-27 18:08bot-cgNew Issue
2026-11-27 18:08bot-cgFile Added: test_core_two_peers.sh
2026-11-27 18:08bot-cgFile Added: test_core_two_peers_defaults.conf
2026-11-27 18:08bot-cgFile Added: test_core_two_peers_a.conf
2026-11-27 18:08bot-cgFile Added: test_core_two_peers_b.conf