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

debuginfo: LLDB segfaults for some archives containing padding bytes at the end. #15950

Closed
michaelwoerister opened this issue Jul 24, 2014 · 9 comments · Fixed by #16139
Closed
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.)

Comments

@michaelwoerister
Copy link
Member

There's another bug in LLDB that causes it to segfault when reading archive files. This one has already been fixed in May (llvm-mirror/lldb@e7e7a50) but it still exists in a lot of LLDB binaries out there.

As far as I can tell, the bug occurs when a number of object files are stored in an archive and the last one ends at an uneven byte offset. This often seems to be the case for compressed byte-code archives in rlibs (maybe regular object files are always padded to an even size?).

I'm currently compiling a possible workaround (pad the bytecode objects to an even size). It would be good if we could allow for rust code to be debugged with older LLDB versions too.

@michaelwoerister
Copy link
Member Author

Update: Padding all archives entries to an even size seems to prevent the crash in LLDB and I have not seen any detrimental side effects to this approach so far.
@brson @alexcrichton @luqmana Any idea if the additional padding byte at the end of the compressed LLVM IR object in an archive could potentially lead to a problem?

@alexcrichton
Copy link
Member

I'm not familiar enough with the format of object files or bytecode files to know whether an extra byte or two at the end would corrupt them, but if it's working ok currently then I'd just ship it!

@michaelwoerister
Copy link
Member Author

I doubt that the containing archive will care about the padding byte, but either the decompression algorithm or the LLVM bitcode reader could trip over it. The safe way to do this would probably be to prepend the actual size of the compressed data, so we always know how much data to pass to deflate. I guess, I'll implement this and make a pull request.

@michaelwoerister
Copy link
Member Author

Thinking about it, changing the format here is not as so trivial since the compiler must handle libs with the old format differently from libs with the new format.
I see two options:
(1) Just add the padding byte and hope for the best
(2) Introduce some kind of header (including a version byte) before the compressed bitcode, in order to future-proof this against other changes to the encoding.

I think I'd favor option (2).

@alexcrichton
Copy link
Member

Is this only a problem for the bytecode in archives, or is it also a problem for object files?

@michaelwoerister
Copy link
Member Author

So far it has only occurred for bytecode. All object files I came across had a size dividable by 2. I don't know if that's a coincidence...

@alexcrichton
Copy link
Member

Interesting! I'm all for putting the bytecode in whatever format we want (it's already just a huge deflated stream)

@michaelwoerister
Copy link
Member Author

I'll come up with something and then we can discuss the matter further when we have some code to look at in a PR, OK?

@alexcrichton
Copy link
Member

Sounds good to me!

bors added a commit that referenced this issue Aug 4, 2014
…excrichton

Before this commit, the LLVM IR of exported items was simply zip-compressed and stored as an object file inside rlib archives. This commit adds a header to this "object" containing a file identifier and a format version number so the compiler can deal with changes in the way bytecode objects are stored within rlibs.

While updating the format of bytecode objects, this commit also worksaround a problem in LLDB which could not handle odd-sized objects within archives before mid-2014.

Fixes #15950.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants