Skip to content

[Parse] 2nd attempt at multiline attribute messages (SE-200) #19219

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

Merged
merged 2 commits into from
Sep 14, 2018
Merged

[Parse] 2nd attempt at multiline attribute messages (SE-200) #19219

merged 2 commits into from
Sep 14, 2018

Conversation

johnno1962
Copy link
Contributor

This is a follow up on #19170 and the subsequent revert #19206 by @rintaro of some dubious code by me which attempted to support modified escaping and multiline literals for attribute messages and caused ASAN failures. Reworked to try to at least get multiline strings working which might be useful as messages for attributes (for example a detailed “unavailable” annotation) minus the code which read off the start of the StringRef buffer.

Please ASAN test before merging.

Resolves SR-8724.

@jrose-apple
Copy link
Contributor

I was looking at this too, because this isn't the only place getEncodedStringSegment is being called with something that's not a direct source literal. I decided I'd rather copy the string in those cases than try to figure out all the places where getEncodedStringSegment does a one-byte lookahead (there's a bunch more besides the one you fixed).

@jrose-apple
Copy link
Contributor

I'll have my PR up soon (rebuilding and running tests locally first) and I'll CC you both there.

@johnno1962
Copy link
Contributor Author

johnno1962 commented Sep 10, 2018

It’s a tricky one. At the moment multiline are allowed but processed incorrectly in attributes. getEncodedStringSegment() should respect its bounds now.

@johnno1962
Copy link
Contributor Author

So we can’t assume this?

  // Note that it is always safe to read one over the end of "Bytes" because
  // we know that there is a terminating " character.  Use BytesPtr to avoid a
  // range check subscripting on the StringRef.

@jrose-apple
Copy link
Contributor

On my end I considered removing that assumption vs. just making a copy when the function is used outside of a normal Lexer context, and I decided the latter was safer and didn't require me to go off and test performance.

@johnno1962
Copy link
Contributor Author

I’ve tidied up the code a little on this PR. Can somebody perform an ASAN check on it for me please?

@jrose-apple
Copy link
Contributor

ASan is currently failing on master anyway, so we'll have to wait (https://ci.swift.org/job/oss-swift-incremental-ASAN-RA-osx/).

@jrose-apple
Copy link
Contributor

@swift-ci Please asan test

@jrose-apple
Copy link
Contributor

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - f430e0189cd1c6379887826310191138a7b129d4

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - f430e0189cd1c6379887826310191138a7b129d4

@jrose-apple
Copy link
Contributor

@swift-ci Please asan test

@beccadax
Copy link
Contributor

@swift-ci please asan test

1 similar comment
@beccadax
Copy link
Contributor

@swift-ci please asan test

@johnno1962
Copy link
Contributor Author

johnno1962 commented Sep 12, 2018

Rebased and ready to merge. The Asan checks seem to abort today though there was one successful run yesterday https://ci.swift.org/job/swift-PR-osx-ASAN-test/51/ before the rebase which only contained a minor header fix due to #19230.

@jrose-apple
Copy link
Contributor

@swift-ci Please test

@swiftlang swiftlang deleted a comment from swift-ci Sep 12, 2018
@swiftlang swiftlang deleted a comment from swift-ci Sep 12, 2018
@rintaro
Copy link
Member

rintaro commented Sep 13, 2018

@swift-ci Please smoke test

@rintaro
Copy link
Member

rintaro commented Sep 13, 2018

@swift-ci Please ASAN test

Copy link
Member

@rintaro rintaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@rintaro rintaro merged commit e55d425 into swiftlang:master Sep 14, 2018
@johnno1962
Copy link
Contributor Author

Thanks everyone. All this trouble to get multiline attribute messages working!

dcci pushed a commit that referenced this pull request Sep 17, 2018
Multiline string literal at attribute message position was disallowed in
59778f8.

Reworked to try to at least get multiline strings working which might be
useful as messages for attributes (for example a detailed “unavailable”
annotation) minus the code which read off the start of the StringRef buffer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants