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

Codegen: don't incorrectly share metadata across llvm modules #4976

Merged
merged 1 commit into from Sep 15, 2017
Merged

Codegen: don't incorrectly share metadata across llvm modules #4976

merged 1 commit into from Sep 15, 2017

Conversation

asterite
Copy link
Member

Fixes #4973

(or so I think)

At least I tried to reproduce the invalid memory access with this code and it didn't happen anymore.

I'm 99% sure this was the cause: metadata nodes, which belong to an LLVM::Module, were also being used in other modules. I confirmed this by changing the code a bit and adding checks (leaving the checks would be very inefficient, so I left them out). So when a module was disposed its metadata was disposed, and then when a second module was disposed that same metadata would be disposed again, leading to a crash.

We'll know for sure if we don't see those awful crashes in CI anymore :-)

@asterite
Copy link
Member Author

Since CI is broken in master, and this passed (a good sign!), let's merge and see if it gets fixed :-D

@asterite asterite merged commit b5484e4 into crystal-lang:master Sep 15, 2017
@debug_types_per_module ||=
{} of LLVM::Module => Hash(Type, LibLLVMExt::Metadata?)

debug_types_per_module[llvm_module] ||= {} of Type => LibLLVMExt::Metadata?
Copy link
Member

Choose a reason for hiding this comment

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

There is no invocation to debug_type_cache with arguments.
Why not use @llvm_mod directly instead of llvm_module as the index to access debug_types_per_module?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea! Please send a PR (I'll be busy today, water leak under my apartment :/)

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

Successfully merging this pull request may close these issues.

None yet

4 participants