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

Fix bug when serializing bare lambdas #4486

Merged
merged 1 commit into from
Feb 6, 2024
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
7 changes: 7 additions & 0 deletions .release-notes/4479.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Fix esoteric bug with serializing bare lambdas

Almost no one uses bare lambdas. And even fewer folks end up passing them through the Pony serialization code. So, of course, Red Davies did just that. And of course, he found a bug.

When we switched to LLVM 15 in 0.54.1, we had to account for a rather large change with how LLVM handles pointer and types. In the process of doing that update, a mistake was made and serializing of bare lambdas was broken.

We've made the fix and introduced a regression test. Enjoy your fix Red!
2 changes: 1 addition & 1 deletion src/libponyc/codegen/genserialise.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ static void deserialise_bare_interface(compile_t* c, LLVMValueRef ptr)

LLVMValueRef desc = LLVMBuildInBoundsGEP2(c->builder,
LLVMArrayType(c->ptr, 0), c->desc_table, args, 2, "");
desc = LLVMBuildLoad2(c->builder, c->descriptor_type, desc, "");
desc = LLVMBuildLoad2(c->builder, c->ptr, desc, "");
LLVMValueRef func = gendesc_instance(c, desc);
LLVMBuildStore(c->builder, func, ptr);
}
Expand Down
9 changes: 9 additions & 0 deletions test/full-program-tests/regression-4479/main.pony
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
actor Main
new create(env: Env) => None
let cb: Callbacks = Callbacks

class Callbacks
var cbi: @{(): None}

new create() =>
cbi = @{() => None}
Loading