-
Notifications
You must be signed in to change notification settings - Fork 17
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
Current API for object loading is inadequate #230
Comments
I need to understand three things a bit better:
|
|
I would have thought this would be completely internal to ide-backend, and not affect the external API at all. What kind of API change would you picture coming from fixing this? And based on your answer to (2), I would like to move ahead with fixing this. |
Well |
I think I don't understand the problem well enough. From our side as the caller, we know nothing about object files. We will simply be providing source files ending in |
I see, fair enough. So what you would prefer to happen, ideal case, if a user adds a C file that refers to an as-yet undefined symbol? And then subsequently adds a further C file that defines that symbol? |
Ideally:
|
Haha, ok :) So I guess that means we need to try to resolve object files whenever they are added, when that fails unload them again, and then try again when we have more object files. Also, come to think of it, if one C file changes we probably have to unload all object files in case any of the other object files refers to that particular object file. We will need to keep a bit more state |
Yes, I think from a UI pov |
Although this all seems to work just fine, it _something_ does go wrong with relocation, because when I add one more printf statement in defined_in_B things break. I don't yet know why.
So I started looking at this in detail. I have a test which loads two C object files A and B, where B calls into A, and a Haskell file which calls into the second C file. What I'm testing is what happens when I load these in various orders. If I load first A by itself, then B, then the Haskelll file works. Of course, that's the easy case because at every step all dependencies are already available. But if I first load B, then A, then the Haskell file, it doesn't work. I thought it did initially; my test passed just fine. But when I modified B from "printf ; call A" to "printf ; call A ; another printf" it no longer works (the whole thing hangs, which probably points to a server crash), so it seems something is going wrong with relocation after all. Will continue investigating this. |
@snoyberg I have tracked this down to a bug in the
Let me know how you would like me to proceed. |
Actually, given that ghci does this anyway, it's probably best to unload object files every time. I will implement that workaround now. We should still keep an eye on that linker bug however. |
@edsko I agree with taking that as a first step here. |
@snoyberg Ok, I have changed the code so that we unload all objects and reload them all again whenever any C files is added or changed. I feel happier about this anyway, now we don't have to worry about symbols not being re-resolved when addresses change etc. Added some stress tests for this and it all seems fine. Also, the ghc linker bug appears to be OSX specific according to the ticket, so we don't have to worry about that either. I am closing this issue as resolved. |
@snoyberg FYI, have just pushed a fix where we now capture the output from ghc when object loading fails and report it to the client (not entirely trivial because this causes a hard server crash, not just an exception). |
Now that we have moved to dynamic-by-default, object files need to be resolved after loading -- this was the underlying cause for #228 (actually, that sentence is somewhat speculative). Currently we now call
resolveObjs
every time we load an object, but this is incorrect in the case that we want to load multiple object files which refer to each other. This may or may not matter (@snoyberg?).The text was updated successfully, but these errors were encountered: