Skip to content

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

Merged
bors merged 2 commits into
rust-lang:masterfrom
pnkfelix:fix-issue-24687
Apr 29, 2015
Merged

metadata: Fix zero-normalization of the pos of a MultiByteChar#24932
bors merged 2 commits into
rust-lang:masterfrom
pnkfelix:fix-issue-24687

Conversation

@pnkfelix

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

r? @pcwalton

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

@pnkfelix

Copy link
Copy Markdown
ContributorAuthor

(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
Copy Markdown
Member

\o/

cc @larsbergstrom

@huonw

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Apr 29, 2015

Copy link
Copy Markdown
Collaborator

📌 Commit 2ae82fc has been approved by huonw

@Manishearth

Copy link
Copy Markdown
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
Copy Markdown
Contributor

@bors p=1

@dotdash

Copy link
Copy Markdown
Contributor

@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

bors commented Apr 29, 2015

Copy link
Copy Markdown
Collaborator

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

@bors

bors commented Apr 29, 2015

Copy link
Copy Markdown
Collaborator

@bors
bors merged commit 2ae82fc into rust-lang:masterApr 29, 2015
@pnkfelix

Copy link
Copy Markdown
ContributorAuthor

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-highfiverust-highfive added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Apr 29, 2015
@SimonSapin

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

@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
Copy Markdown
Contributor

Makes sense.

@pnkfelix

Copy link
Copy Markdown
ContributorAuthor

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

@tamirdtamird 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
Copy Markdown
ContributorAuthor

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...)

@pnkfelixpnkfelix added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Apr 30, 2015
@alexcrichtonalexcrichton mentioned this pull request Apr 30, 2015
@brsonbrson removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Apr 30, 2015
@brson

Copy link
Copy Markdown
Contributor

Backported.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beta-acceptedAccepted 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

@pnkfelix@rust-highfive@Manishearth@huonw@bors@dotdash@SimonSapin@brson@pcwalton