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

LLVM rust nightly file too short #943

Closed
emanuele-em opened this issue May 11, 2024 · 2 comments
Closed

LLVM rust nightly file too short #943

emanuele-em opened this issue May 11, 2024 · 2 comments

Comments

@emanuele-em
Copy link

fn try_only_interception_egress(ctx: TcContext) -> Result<i32, i32> {
    info!(&ctx, "received an egress packet");
    let start = ctx.data();
    let end = ctx.data_end();
    let len = end - start;
    
    let mut tmp = Packet{
        buf: [0u8; BUF_SIZE],
    };
    for i in 0..len{
        if i >= BUF_SIZE {
            return Err(0);
        }
        tmp.buf[i] = ctx.load(i).map_err(|_| 0)?;
    }
    if let Some(mut buffer) = PACKETS.reserve::<Packet>(0) {
        buffer.write(tmp);
        buffer.submit(0);
    }
    Ok(TC_ACT_PIPE)
}

this is part of the code, with the last nightly if I comment this line:
tmp.buf[i] = ctx.load(i).map_err(|_| 0)?
or this line:
buffer.write(tmp);
it works correctly I read on discord that the "file too short" is a recent bug probably due to the last nightly.
Is there a way to solve this?

I'm on Ubuntu with x86-64
kernel: 6.8.0-31-generic
rustup 1.27.1 (54dd3d00f 2024-04-24)

@addisoncrump
Copy link
Contributor

I find that I get this issue when the amount of stack used is too great. I'm guessing the compiler optimises out your tmp in the stack if either of those lines are omitted (in one case it can be optimised out entirely, the other it can be transformed to static).

Your BUF_SIZE is probably too large for the stack. Drop it in a per-cpu array instead :)

@emanuele-em
Copy link
Author

thank you very much, the problem was exactly the stack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants