-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Found a runtime compiler bug #39177
Comments
Link to valgrind run: http://paste.ubuntu.com/23828037/ Seems it errors with signal 11/SIGSEV/General Protection fault. @J-F-Liu were you able to produce a more minimal example to reproduce the issue? This would be very helpful. |
At home now, will try tomorrow. |
When I replace the two deps that use unsafe by shims, I still can reproduce: https://github.com/est31/lopdf/commit/2d16d23a81205b16f937a852339e4e25498e458f This means only safe code is used, and means its a valid bug (of the compiler). One possible reason is the usage of some unstable and possibly buggy features in the pom crate, but that's only a guess. |
Potentially a duplicate of #33197. |
If you add these two lines to the code: fn stream(reader: &Reader) -> Parser<u8, Stream> {
println!("READER addr is (oside): {:p}, {:x}", reader, reader.v); // ADDED
dictionary() - space() - seq(b"stream") - eol() >>
|dict: Dictionary| {
println!("READER addr is (iside): {:p}, {:x}", reader, reader.v); //ADDED
reader.print_xref_size();
let length = dict.get("Length").and_then(|value| {
if let Some(id) = value.as_reference() {
return reader.get_object(id).and_then(|value|value.as_i64());
}
return value.as_i64();
}).expect("Stream Length should be an integer.");
let stream = take(length as usize) - eol().opt() - seq(b"endstream");
stream.map(move |data|Stream::new(dict.clone(), data))
}
} With reader.v being an u32 member and being set to
So its less likely to be a bug with hashmaps. All types used as keys in |
So this is the more minimal case I’ve constructed. Running this program will result in two different pointers being printed. Looking at the Moving the EDIT: this code warns about soundness issue and also that it will be phased out in the future, but there’s a |
even more minimized version: http://play.integer32.com/?gist=c5511ecaddb1b9866a6782132384860e&version=stable |
so this is a dupe of #18937 then? |
Yes, although this issue is interesting in a way that it has an actual code that is able to exploit the issue to cause unsoundness. Should still be closed. |
I am the author of pom, now I use pom to implement a PDF parser and get some surprising result:
The output is:
xref is the same BTreeMap variable captured in nested closures printing its len().
Notice these big random numbers, probably caused by wrong pointers.
Try another PDF file:
This time the parser actually accesses entry in xref, the program failed and exited without printing any panic message!
The download links of these example PDF files are:
You can play with the code, add more debug infos, please find out the root cause.
The text was updated successfully, but these errors were encountered: