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

Field of type with filter consumes more data than expected #1652

Closed
bbannier opened this issue Jan 17, 2024 · 1 comment · Fixed by #1670
Closed

Field of type with filter consumes more data than expected #1652

bbannier opened this issue Jan 17, 2024 · 1 comment · Fixed by #1670
Assignees
Labels
Bug Something isn't working Priority High

Comments

@bbannier
Copy link
Member

Given the following code

module foo;

const N: uint64 = 1;

public type X = unit {
    y: Y &max-size=N;
    z: bytes &eod &requires=|$$|!=0;
};

type Y = unit {
    on %init {
        self.connect_filter(new F);
    }

    data: bytes &size=N;
};

type F = unit {
    %filter;

    filter_input: bytes &size=N {
        print $$;
        self.forward($$);
    }
};

For an input \x01\x02\x03 I would expect y to consume exactly one (N) byte since the filter connected to Y consumes one byte. It looks however as if that is not the case and the &max-size check fails; if I remove the check I still see no data in z so it looks to me as if the filter consumes all input.

Printing filter_input shows a single byte so I suspect this is happening outside of the parsing of F in how we update the view it operates on.

This seems to be broken from at least 1.4.0 on (before d15281b we rejected above reproducer).

@bbannier
Copy link
Member Author

The issue here is that we seem to trim too much, at least once in the filter and again for the field. One of these seems to see the wrong cur. Currently we do not set up new parser state for parsing in filters which might be required for some functionality, but I suspect contributes to the issue here.

builder()->addExpression(builder::memberCall(state().self, id_stage2, args2));

@bbannier bbannier self-assigned this Feb 7, 2024
bbannier added a commit that referenced this issue Feb 7, 2024
We would previously assume that a filter would consume all available
data. This only holds if the filter is attached to a top-level unit, but
in general not if some sub-unit uses a filter. With this patch we
explicitly compute how much data is consumed.

Closes #1652.
bbannier added a commit that referenced this issue Feb 7, 2024
We would previously assume that a filter would consume all available
data. This only holds if the filter is attached to a top-level unit, but
in general not if some sub-unit uses a filter. With this patch we
explicitly compute how much data is consumed.

Closes #1652.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Priority High
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant