Skip to content

Function pointer comparisons are non-deterministic #91

@sebastianrasor

Description

@sebastianrasor

In trying to package River in Nix, I've come across the following issue where tests are failing:

       > failures:
       >
       > ---- config::toml::test::load_test stdout ----
       > thread 'config::toml::test::load_test' panicked at source/river/src/config/toml.rs:403:9:
       > assertion `left == right` failed
       >   left: "Config { validate_configs: false, threads_per_service: 8, daemonize: false, pid_file: None, upgrade_socket: None, upgrade: false, basic_proxies: [ProxyConfig { name: \"Example1\", listeners: [ListenerConfig { source: Tcp { addr: \"0.0.0.0:8080\", tls: None, offer_h2: false } }, ListenerConfig { source: Tcp { addr: \"0.0.0.0:4443\", tls: Some(TlsConfig { cert_path: \"./assets/test.crt\", key_path: \"./assets/test.key\" }), offer_h2: false } }], upstream_options: UpstreamOptions { selection: RoundRobin, selector: 0x555555674510, health_checks: None, discovery: Static }, upstreams: [HttpPeer { _address: Inet(91.107.223.4:443), scheme: HTTPS, sni: \"onevariable.com\", proxy: None, client_cert_key: None, group_key: 0, options: PeerOptions { bind_to: None, connection_timeout: None, total_connection_timeout: None, read_timeout: None, idle_timeout: None, write_timeout: None, verify_cert: true, verify_hostname: true, alternative_cn: None, alpn: H1, ca: None, tcp_keepalive: None, tcp_recv_buf: None, dscp: None, no_header_eos: false, h2_ping_interval: None, max_h2_streams: 1, extra_proxy_headers: {}, curves: None, second_keyshare: true, tcp_fast_open: false, tracer: None } }], path_control: PathControl { request_filters: [], upstream_request_filters: [{\"kind\": \"remove-header-key-regex\", \"pattern\": \".*(secret|SECRET).*\"}, {\"key\": \"x-proxy-friend\", \"kind\": \"upsert-header\", \"value\": \"river\"}], upstream_response_filters: [{\"kind\": \"remove-header-key-regex\", \"pattern\": \".*ETag.*\"}, {\"key\": \"x-with-love-from\", \"kind\": \"upsert-header\", \"value\": \"river\"}] }, rate_limiting: RateLimitingConfig { rules: [] } }, ProxyConfig { name: \"Example2\", listeners: [ListenerConfig { source: Tcp { addr: \"0.0.0.0:8000\", tls: None, offer_h2: false } }], upstream_options: UpstreamOptions { selection: RoundRobin, selector: 0x555555674510, health_checks: None, discovery: Static }, upstreams: [HttpPeer { _address: Inet(91.107.223.4:80), scheme: HTTP, sni: \"\", proxy: None, client_cert_key: None, group_key: 0, options: PeerOptions { bind_to: None, connection_timeout: None, total_connection_timeout: None, read_timeout: None, idle_timeout: None, write_timeout: None, verify_cert: true, verify_hostname: true, alternative_cn: None, alpn: H1, ca: None, tcp_keepalive: None, tcp_recv_buf: None, dscp: None, no_header_eos: false, h2_ping_interval: None, max_h2_streams: 1, extra_proxy_headers: {}, curves: None, second_keyshare: true, tcp_fast_open: false, tracer: None } }], path_control: PathControl { request_filters: [], upstream_request_filters: [], upstream_response_filters: [] }, rate_limiting: RateLimitingConfig { rules: [] } }], file_servers: [] }"
       >  right: "Config { validate_configs: false, threads_per_service: 8, daemonize: false, pid_file: None, upgrade_socket: None, upgrade: false, basic_proxies: [ProxyConfig { name: \"Example1\", listeners: [ListenerConfig { source: Tcp { addr: \"0.0.0.0:8080\", tls: None, offer_h2: false } }, ListenerConfig { source: Tcp { addr: \"0.0.0.0:4443\", tls: Some(TlsConfig { cert_path: \"./assets/test.crt\", key_path: \"./assets/test.key\" }), offer_h2: false } }], upstream_options: UpstreamOptions { selection: RoundRobin, selector: 0x55555566f4c0, health_checks: None, discovery: Static }, upstreams: [HttpPeer { _address: Inet(91.107.223.4:443), scheme: HTTPS, sni: \"onevariable.com\", proxy: None, client_cert_key: None, group_key: 0, options: PeerOptions { bind_to: None, connection_timeout: None, total_connection_timeout: None, read_timeout: None, idle_timeout: None, write_timeout: None, verify_cert: true, verify_hostname: true, alternative_cn: None, alpn: H1, ca: None, tcp_keepalive: None, tcp_recv_buf: None, dscp: None, no_header_eos: false, h2_ping_interval: None, max_h2_streams: 1, extra_proxy_headers: {}, curves: None, second_keyshare: true, tcp_fast_open: false, tracer: None } }], path_control: PathControl { request_filters: [], upstream_request_filters: [{\"kind\": \"remove-header-key-regex\", \"pattern\": \".*(secret|SECRET).*\"}, {\"key\": \"x-proxy-friend\", \"kind\": \"upsert-header\", \"value\": \"river\"}], upstream_response_filters: [{\"kind\": \"remove-header-key-regex\", \"pattern\": \".*ETag.*\"}, {\"key\": \"x-with-love-from\", \"kind\": \"upsert-header\", \"value\": \"river\"}] }, rate_limiting: RateLimitingConfig { rules: [] } }, ProxyConfig { name: \"Example2\", listeners: [ListenerConfig { source: Tcp { addr: \"0.0.0.0:8000\", tls: None, offer_h2: false } }], upstream_options: UpstreamOptions { selection: RoundRobin, selector: 0x55555566f4c0, health_checks: None, discovery: Static }, upstreams: [HttpPeer { _address: Inet(91.107.223.4:80), scheme: HTTP, sni: \"\", proxy: None, client_cert_key: None, group_key: 0, options: PeerOptions { bind_to: None, connection_timeout: None, total_connection_timeout: None, read_timeout: None, idle_timeout: None, write_timeout: None, verify_cert: true, verify_hostname: true, alternative_cn: None, alpn: H1, ca: None, tcp_keepalive: None, tcp_recv_buf: None, dscp: None, no_header_eos: false, h2_ping_interval: None, max_h2_streams: 1, extra_proxy_headers: {}, curves: None, second_keyshare: true, tcp_fast_open: false, tracer: None } }], path_control: PathControl { request_filters: [], upstream_request_filters: [], upstream_response_filters: [] }, rate_limiting: RateLimitingConfig { rules: [] } }], file_servers: [] }"
       > note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
       >
       > ---- config::kdl::test::load_test stdout ----
       > thread 'config::kdl::test::load_test' panicked at source/river/src/config/kdl/test.rs:194:9:
       > assertion `left == right` failed
       >   left: UpstreamOptions { selection: RoundRobin, selector: 0x55555567f1e0, health_checks: None, discovery: Static }
       >  right: UpstreamOptions { selection: RoundRobin, selector: 0x5555556602a0, health_checks: None, discovery: Static }
       >
       >
       > failures:
       >     config::kdl::test::load_test
       >     config::toml::test::load_test
       >
       > test result: FAILED. 5 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.60s

I believe the issue here is related to selector being a function pointer. The debug representation of a function pointer is its address, but I believe that function pointer comparisons are non-deterministic: rust-lang/rust#54685 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions