Skip to content

Bear freezes and outputs an empty compile_commands.json ([]) when http_proxy is set #635

@wataash

Description

@wataash

When http_proxy is set, Bear always fails and generates an empty compile_commands.json ([]), and freezes for several seconds if there is a DNS/TCP timeout.

# on Linux

# DNS lookup failed (freezes until lookup failure!)
# I'm unsure if setting ftp_proxy and https_proxy has any effect, but they are set just in case
export http_proxy=http://nonexistent.example.com:8080; export ftp_proxy="$http_proxy"; export https_proxy="$http_proxy"
bear -- gcc a.c  # freezes for 10 seconds on my environment
#wrapper: failed with: gRPC call failed: errors resolving nonexistent.example.com:8080: [field:hostname lookup error:address lookup failed for nonexistent.example.com:8080: DNS server returned general failure]
cat compile_commands.json  # []

# TCP timeout
# RFC 5737 TEST-NET
export http_proxy=http://192.0.2.1:9999; export ftp_proxy="$http_proxy"; export https_proxy="$http_proxy"
bear -- gcc a.c  # freezes for 20 seconds on my environment
#wrapper: failed with: gRPC call failed: failed to connect to all addresses; last error: UNKNOWN: ipv4:192.0.2.1:9999: tcp handshaker shutdown
cat compile_commands.json  # []

# TCP RST
export http_proxy=http://localhost:9999; export ftp_proxy="$http_proxy"; export https_proxy="$http_proxy"
bear -- gcc a.c
#wrapper: failed with: gRPC call failed: failed to connect to all addresses; last error: UNKNOWN: ipv4:127.0.0.1:9999: Failed to connect to remote host: Connection refused
cat compile_commands.json  # []

# with a valid proxy server
docker run -it -p 8080:3128 --entrypoint bash ubuntu/squid:6.10-24.10_beta -c "
  echo -e 'http_port 3128 \n http_access allow all' >/etc/squid/squid.conf
  tail -F /var/log/squid/access.log /var/log/squid/cache.log &
  squid -N -d1
"
export http_proxy=http://localhost:8080; export ftp_proxy="$http_proxy"; export https_proxy="$http_proxy"
bear -- gcc a.c
#WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
#E0000 00:00:1745813214.700493  104296 http_connect_handshaker.cc:114] HTTP proxy handshake with ipv4:127.0.0.1:8080 failed: UNKNOWN: HTTP proxy returned response code 503 [type.googleapis.com/grpc.status.time.created_time='2025-04-28T04:06:54.700348928+00:00']
#wrapper: failed with: gRPC call failed: failed to connect to all addresses; last error: UNKNOWN: ipv4:127.0.0.1:8080: HTTP proxy returned response code 503
cat compile_commands.json  # []

This seems to be resolved in #631.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions