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

[AIX] Fix hangs during testing #137967

Merged
merged 1 commit into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions library/std/src/net/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,14 @@ pub fn tsa<A: ToSocketAddrs>(a: A) -> Result<Vec<SocketAddr>, String> {
Err(e) => Err(e.to_string()),
}
}

pub fn compare_ignore_zoneid(a: &SocketAddr, b: &SocketAddr) -> bool {
match (a, b) {
(SocketAddr::V6(a), SocketAddr::V6(b)) => {
a.ip().segments() == b.ip().segments()
&& a.flowinfo() == b.flowinfo()
&& a.port() == b.port()
}
_ => a == b,
}
}
12 changes: 8 additions & 4 deletions library/std/src/net/udp/tests.rs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, wait... what are the actual mismatches on the scope ID, exactly?

They have the same scope, but a different zone index? Because it's assigned the 0 ZoneID...? But we create the IP with a scope_id of 0...

Copy link
Contributor Author

@mustartt mustartt Mar 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think included the wrong scope id in the post. The peer we get back contains a scope id of 1 for the loopback.
(edited PR description to scope id to reflect it)

(gdb) list
41              });
42      
43              let server = t!(UdpSocket::bind(&server_ip));
44              tx1.send(()).unwrap();
45              let mut buf = [0];
46              let (nread, src) = t!(server.recv_from(&mut buf));
47              assert_eq!(nread, 1);
48              assert_eq!(buf[0], 99);
49              assert_eq!(compare_ignore_zoneid(&src, &client_ip), true);
50              rx2.recv().unwrap();
(gdb) p src
$2 = core::net::socket_addr::SocketAddr::V6(core::net::socket_addr::SocketAddrV6 {ip: core::net::ip_addr::Ipv6Addr {octets: [0 <repeats 15 times>, 1]}, port: 19603, flowinfo: 0, scope_id: 1})
(gdb) p client_ip
$3 = core::net::socket_addr::SocketAddr::V6(core::net::socket_addr::SocketAddrV6 {ip: core::net::ip_addr::Ipv6Addr {octets: [0 <repeats 15 times>, 1]}, port: 19603, flowinfo: 0, scope_id: 0})

bash-5.2$ cat /etc/hosts | grep ::1
::1                     loopback localhost      # IPv6 loopback (lo0) name/address
bash-5.2$ ibm-clang++_r test.cpp -o test
bash-5.2$ cat test.cpp
#include <net/if.h>
#include <iostream>
#include <sysexits.h>

int main(void)
{
        auto scope_id = if_nametoindex("lo0");
        std::cout << scope_id << std::endl;
        return EX_OK;
}
bash-5.2$ ./test 
1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha.

We probably should be creating these with a scope ID of 1 for the loopback.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now this change is fine though.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::net::test::{next_test_ip4, next_test_ip6};
use crate::net::test::{compare_ignore_zoneid, next_test_ip4, next_test_ip6};
use crate::net::*;
use crate::sync::mpsc::channel;
use crate::thread;
Expand Down Expand Up @@ -46,7 +46,7 @@ fn socket_smoke_test_ip4() {
let (nread, src) = t!(server.recv_from(&mut buf));
assert_eq!(nread, 1);
assert_eq!(buf[0], 99);
assert_eq!(src, client_ip);
assert_eq!(compare_ignore_zoneid(&src, &client_ip), true);
rx2.recv().unwrap();
})
}
Expand Down Expand Up @@ -78,7 +78,9 @@ fn udp_clone_smoke() {

let _t = thread::spawn(move || {
let mut buf = [0, 0];
assert_eq!(sock2.recv_from(&mut buf).unwrap(), (1, addr1));
let res = sock2.recv_from(&mut buf).unwrap();
assert_eq!(res.0, 1);
assert_eq!(compare_ignore_zoneid(&res.1, &addr1), true);
assert_eq!(buf[0], 1);
t!(sock2.send_to(&[2], &addr1));
});
Expand All @@ -94,7 +96,9 @@ fn udp_clone_smoke() {
});
tx1.send(()).unwrap();
let mut buf = [0, 0];
assert_eq!(sock1.recv_from(&mut buf).unwrap(), (1, addr2));
let res = sock1.recv_from(&mut buf).unwrap();
assert_eq!(res.0, 1);
assert_eq!(compare_ignore_zoneid(&res.1, &addr2), true);
rx2.recv().unwrap();
})
}
Expand Down
1 change: 1 addition & 0 deletions tests/debuginfo/pretty-huge-vec.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//@ ignore-windows-gnu: #128981
//@ ignore-android: FIXME(#10381)
//@ ignore-aix: FIXME(#137965)
//@ compile-flags:-g

// === GDB TESTS ===================================================================================
Expand Down
3 changes: 3 additions & 0 deletions tests/ui/consts/large_const_alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// on 32bit and 16bit platforms it is plausible that the maximum allocation size will succeed
// FIXME (#135952) In some cases on AArch64 Linux the diagnostic does not trigger
//@ ignore-aarch64-unknown-linux-gnu
// AIX will allow the allocation to go through, and get SIGKILL when zero initializing
// the overcommitted page.
//@ ignore-aix

const FOO: () = {
// 128 TiB, unlikely anyone has that much RAM
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/consts/large_const_alloc.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0080]: evaluation of constant value failed
--> $DIR/large_const_alloc.rs:8:13
--> $DIR/large_const_alloc.rs:11:13
|
LL | let x = [0_u8; (1 << 47) - 1];
| ^^^^^^^^^^^^^^^^^^^^^ tried to allocate more memory than available to compiler

error[E0080]: could not evaluate static initializer
--> $DIR/large_const_alloc.rs:13:13
--> $DIR/large_const_alloc.rs:16:13
|
LL | let x = [0_u8; (1 << 47) - 1];
| ^^^^^^^^^^^^^^^^^^^^^ tried to allocate more memory than available to compiler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
//@ only-64bit
// FIXME (#135952) In some cases on AArch64 Linux the diagnostic does not trigger
//@ ignore-aarch64-unknown-linux-gnu
// AIX will allow the allocation to go through, and get SIGKILL when zero initializing
// the overcommitted page.
//@ ignore-aix

pub struct Data([u8; (1 << 47) - 1]);
const _: &'static Data = &Data([0; (1 << 47) - 1]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0080]: evaluation of constant value failed
--> $DIR/promoted_running_out_of_memory_issue-130687.rs:10:32
--> $DIR/promoted_running_out_of_memory_issue-130687.rs:13:32
|
LL | const _: &'static Data = &Data([0; (1 << 47) - 1]);
| ^^^^^^^^^^^^^^^^^^ tried to allocate more memory than available to compiler
Expand Down
Loading