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

metadata: Fix zero-normalization of the pos of a MultiByteChar #24932

Merged
merged 2 commits into from
Apr 29, 2015

Conversation

pnkfelix
Copy link
Member

metdata: Fix zero-normalization of the pos of a MultiByteChar

Fix #24687

The source byte/character mappings for every crate track the collection of multi-characters from its source files specially. When we import the source information for another file into the current compilation unit, we assign its byte-positions unique values by shifting them all by a fixed adjustment, tracked in the start_pos field. But when we pull out the source span information for one function from one crate and into our own crate, we need to re-normalize the byte positions: subtracting the old start_pos and adding the new start_pos. The new_imported_filemap(..) method handles adding the new start_pos, so all creader needs to do is re-normalize each pos to zero.

It seems like it was indeed trying to do this, but it mistakenly added the old start_pos instead of subtracting it.

@rust-highfive
Copy link
Collaborator

r? @pcwalton

(rust_highfive has picked a reviewer for you, use r? to override)

@pnkfelix
Copy link
Member Author

(actually on reflection, even though the original problem case was using non-breaking space, it would probably be a good idea if I used a non-whitespace character in that regression test. let me adjust that.)

Update: okay, that is fixed now.

use visible characters for the multibyte character filler.
@Manishearth
Copy link
Member

\o/

cc @larsbergstrom

@huonw
Copy link
Member

huonw commented Apr 29, 2015

@bors r+

@bors
Copy link
Contributor

bors commented Apr 29, 2015

📌 Commit 2ae82fc has been approved by huonw

@Manishearth
Copy link
Member

@bors: force

The diagnostic one is running now, that's a rather small PR and can wait (probably ought to be rollup)

@dotdash
Copy link
Contributor

dotdash commented Apr 29, 2015

@bors p=1

@dotdash
Copy link
Contributor

dotdash commented Apr 29, 2015

@bors force

bors added a commit that referenced this pull request Apr 29, 2015
metdata: Fix zero-normalization of the pos of a `MultiByteChar`

Fix #24687

The source byte/character mappings for every crate track the collection of multi-characters from its source files specially.  When we import the source information for another file into the current compilation unit, we assign its byte-positions unique values by shifting them all by a fixed adjustment, tracked in the `start_pos` field.  But when we pull out the source span information for one function from one crate and into our own crate, we need to re-normalize the byte positions: subtracting the old `start_pos` and adding the new `start_pos`. The `new_imported_filemap(..)` method handles adding the new `start_pos`, so all `creader` needs to do is re-normalize each `pos` to zero.

It seems like it was indeed trying to do this, but it mistakenly added the old `start_pos` instead of subtracting it.
@bors
Copy link
Contributor

bors commented Apr 29, 2015

⌛ Testing commit 2ae82fc with merge 551a74d...

@bors bors merged commit 2ae82fc into rust-lang:master Apr 29, 2015
@pnkfelix
Copy link
Member Author

triage: beta-nominated

Considering that:

  • this was important for servo,
  • it fixes an ICE
  • it is pretty low-risk

we probably should at least consider cherry-picking it to the beta channel.

@rust-highfive rust-highfive added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Apr 29, 2015
@SimonSapin
Copy link
Contributor

For what it’s worth, cherry-picking does not affect Servo as we don’t use the beta or stable channel.

@pnkfelix
Copy link
Member Author

@SimonSapin right, I just meant that if Servo was blocked by this, then it is reasonable to conclude that other clients, who we want to stay on beta/stable channels, will also be blocked by this.

@SimonSapin
Copy link
Contributor

Makes sense.

@pnkfelix
Copy link
Member Author

Also, a quick followup note:

  • The regression test on this really should have had "compiler-flags: -g" or whatever the directive is for embedded those options in the tests.
  • As it is written in this commit, it is actually I think unlikely to test much of anything, because we do not have any builders to my knowledge that do --enable-debug or a blanket -g on the test suite.
  • So why didn't I run it that way? Because of rustc fails if passed -g -g; make check breaks under --enable-debug. #24937

@tamird tamird mentioned this pull request Apr 29, 2015
pnkfelix added a commit to pnkfelix/rust that referenced this pull request Apr 29, 2015
Note it is safe, with respect to autobuilds, to land before rust-lang#24945.

(In other words, landing this sooner won't break things for anyone any
worse than they were already broken, since there are *other* tests
that also add `-g` to their flags via `compile-flags: -g`.)
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Apr 29, 2015
…24687-test

Add `-g` (to testcase) that I should have included in PR rust-lang#24932.

Note it is safe, with respect to autobuilds, to land before rust-lang#24945.

(In other words, landing this sooner won't break things for anyone any
worse than they were already broken, since there are *other* tests
that also add `-g` to their flags via `compile-flags: -g`.)
@pnkfelix
Copy link
Member Author

accepted for backport to beta channel.

(as a special case for 1.0; post 1.0 a change like this might need stronger motivation for backport...)

@pnkfelix pnkfelix added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Apr 30, 2015
@brson brson removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Apr 30, 2015
@brson
Copy link
Contributor

brson commented Apr 30, 2015

Backported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE in codemap::CodeMap::bytepos_to_file_charpos
9 participants