Skip to content

build: minor fix for 32-bit archs#11726

Merged
ggreenway merged 9 commits intoenvoyproxy:masterfrom
goaway:ms/fix32
Jul 9, 2020
Merged

build: minor fix for 32-bit archs#11726
ggreenway merged 9 commits intoenvoyproxy:masterfrom
goaway:ms/fix32

Conversation

@goaway
Copy link
Copy Markdown
Contributor

@goaway goaway commented Jun 24, 2020

Commit Message: build: minor fix for 32-bit archs
Additional Description: Fixes an implicit cast error building for 32-bit Android here.
Risk Level: Low
Testing: Builds locally

Signed-off-by: Mike Schore [email protected]

absl::string_view dataAsStringView() const {
return {reinterpret_cast<const char*>(data()), dataSize()};
return {reinterpret_cast<const char*>(data()),
static_cast<absl::string_view::size_type>(dataSize())};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isn't the underlying problem the abuse of uint64_t in line 409 above for dataSize()?

There's a significant penalty for using a 64 bit int in 32 bit contexts.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't mind changing the underlying type of dataSize, but I don't really have any context on the original choice.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Personally I'd prefer size_t for this; IIUC Envoy style has veered toward using uint64_t. @mattklein123 may have more context.

I'm fine with either:

  • this change, which makes sense in the context of returning a string_view
  • changing dataSize() et al to return size_t, which makes sense generally IMO

I slightly prefer the latter but I'm OK with this. @mattklein123 what do you prefer?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sure we can use size_t. Typically we have used explicit types for things that can wrap, but for something like this size_t seems fine.

/wait

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

uint64_t seems to be used extensively here to represent a number of bytes. dataSize() is also called in a number of locations. Just to clarify, is the proposal to switch size_t for all of these cases?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes size_t seems appropriate for number of bytes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Despite updating the type used for representing byte counts throughout the file, I left this cast in; I don't know what sort of contract absl::string_view::size_type has with respect to size_t.

If folks feel it's redundant though now, I can remove it.

@asraa asraa assigned jmarantz and unassigned junr03 Jun 26, 2020
jmarantz
jmarantz previously approved these changes Jun 27, 2020
Copy link
Copy Markdown
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

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

this is OK with me but I'd like @mattklein123 to be the final approver.

absl::string_view dataAsStringView() const {
return {reinterpret_cast<const char*>(data()), dataSize()};
return {reinterpret_cast<const char*>(data()),
static_cast<absl::string_view::size_type>(dataSize())};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Personally I'd prefer size_t for this; IIUC Envoy style has veered toward using uint64_t. @mattklein123 may have more context.

I'm fine with either:

  • this change, which makes sense in the context of returning a string_view
  • changing dataSize() et al to return size_t, which makes sense generally IMO

I slightly prefer the latter but I'm OK with this. @mattklein123 what do you prefer?

const uint64_t size = src.size();
MemBlockBuilder<uint8_t> storage(size);
const size_t size = src.size();
MemBlockBuilder<uint8_t> storage(size); // Note: MemBlockBuilder takes uint64_t.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In theory MemBlockBuilder could be updated to use size_t, too, and I suspect there may be other places we could switch over as well. My feeling is that that's a bit outside the scope of this change, however.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

agreed; outside the scope for now.

goaway added 2 commits July 1, 2020 06:05
Signed-off-by: Mike Schore <[email protected]>
Signed-off-by: Mike Schore <[email protected]>
jmarantz
jmarantz previously approved these changes Jul 2, 2020
Copy link
Copy Markdown
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

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

basically looks good, modulo a naming issue you need to fix to pass CI. Also merge master.

const uint64_t size = src.size();
MemBlockBuilder<uint8_t> storage(size);
const size_t size = src.size();
MemBlockBuilder<uint8_t> storage(size); // Note: MemBlockBuilder takes uint64_t.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

agreed; outside the scope for now.

void SymbolTableImpl::Encoding::decodeTokens(
const SymbolTable::Storage array, uint64_t size,
const std::function<void(Symbol)>& symbolTokenFn,
const SymbolTable::Storage array, size_t size, const std::function<void(Symbol)>& symbolTokenFn,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not your fault, but clang-tidy is dinging you for a pre-existing naming mistake here.

s/symbolTokenFn/symbol_token_fn/ here and in the header. Sorry about that.

That will help you pass CI.

@jmarantz
Copy link
Copy Markdown
Contributor

jmarantz commented Jul 2, 2020

/wait

Signed-off-by: Mike Schore <[email protected]>
goaway added 4 commits July 6, 2020 16:15
Signed-off-by: Mike Schore <[email protected]>
Signed-off-by: Mike Schore <[email protected]>
Signed-off-by: Mike Schore <[email protected]>
Copy link
Copy Markdown
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

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

@envoyproxy/senior-maintainers

@junr03
Copy link
Copy Markdown
Member

junr03 commented Jul 8, 2020

@ggreenway do you mind doing a last pass here?

Copy link
Copy Markdown
Member

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

LGTM

@ggreenway ggreenway merged commit ec431a0 into envoyproxy:master Jul 9, 2020
goaway added a commit to envoyproxy/envoy-mobile that referenced this pull request Jul 15, 2020
Description: Pulls in multiple fixes committed to upstream Envoy.

- Update for resolution to TLSContext crash: envoyproxy/envoy#10030
- Fixes for 32 bit archs: envoyproxy/envoy#11726
- Fix for missing posix call on Android: envoyproxy/envoy#12081
- Additional zlib stats: envoyproxy/envoy#11782

Signed-off-by: Mike Schore <[email protected]>
scheler pushed a commit to scheler/envoy that referenced this pull request Aug 4, 2020
Fixes an implicit cast error building for 32-bit Android here.

Signed-off-by: Mike Schore <[email protected]>
Signed-off-by: scheler <[email protected]>
jpsim pushed a commit that referenced this pull request Nov 28, 2022
Description: Pulls in multiple fixes committed to upstream Envoy.

- Update for resolution to TLSContext crash: #10030
- Fixes for 32 bit archs: #11726
- Fix for missing posix call on Android: #12081
- Additional zlib stats: #11782

Signed-off-by: Mike Schore <[email protected]>
Signed-off-by: JP Simard <[email protected]>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
Description: Pulls in multiple fixes committed to upstream Envoy.

- Update for resolution to TLSContext crash: #10030
- Fixes for 32 bit archs: #11726
- Fix for missing posix call on Android: #12081
- Additional zlib stats: #11782

Signed-off-by: Mike Schore <[email protected]>
Signed-off-by: JP Simard <[email protected]>
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.

7 participants