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

Cannot call decode on bytes created from strip #1390

Closed
bbannier opened this issue Mar 6, 2023 · 0 comments · Fixed by #1391
Closed

Cannot call decode on bytes created from strip #1390

bbannier opened this issue Mar 6, 2023 · 0 comments · Fixed by #1391
Assignees
Labels
Bug Something isn't working

Comments

@bbannier
Copy link
Member

bbannier commented Mar 6, 2023

All of the following functions fail at runtime with

uncaught exception hilti::rt::InvalidIterator: bound object has expired (/private/tmp/decode.spicy:7:2)
module foo;
import spicy;

global CS = spicy::Charset::ASCII;  # Other charsets seem fine.

function k() {
	print b" a ".strip().decode(CS);
}

function l() {
	local xs = b" a ";
	print xs.strip().decode(CS);
}
function m() {
	local xs = b" a ";
	local ys : bytes = xs.strip();
	print ys.decode(CS);
}

k();
l();
m();
@bbannier bbannier added the Bug Something isn't working label Mar 6, 2023
@bbannier bbannier self-assigned this Mar 6, 2023
bbannier added a commit that referenced this issue Mar 7, 2023
`Bytes` inherits constructors from its base class. We previously would
not initialize the internal control block for these constructors so some
operations involving iterators on such `Bytes` instances would have
failed, even thought the controlled object was still valid.

With this patch we always set up the control block, no matter which
constructor is used.

Closes #1390.

(cherry picked from commit 71cff50)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant