Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
V8: do not use wide reads in CopyCharsUnsigned
Browse files Browse the repository at this point in the history
Fixes segfault in 32bit SmartOS when built with GCC 4.9.

This is the first of two backports from upstream v8:
1. v8/v8@90dc5c9
2. v8/v8@7cb82a7

Original commit message:

  Do not use wide reads in CopyCharsUnsigned.

  R=jkummerow@chromium.org
  BUG=chromium:412967
  LOG=Y

  Review URL: https://codereview.chromium.org/566583002

  git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23876 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

V8 issue: https://code.google.com/p/chromium/issues/detail?id=412967

Fixes #25281

Reviewed-By: Julien Gilli <julien.gilli@joyent.com>
PR-URL: #25556
  • Loading branch information
hashseed authored and joaocgreis committed Jul 1, 2015
1 parent 88a27a9 commit 48b0ca2
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions deps/v8/src/utils.h
Expand Up @@ -1351,20 +1351,10 @@ template <typename sourcechar, typename sinkchar>
void CopyCharsUnsigned(sinkchar* dest, const sourcechar* src, int chars) {
sinkchar* limit = dest + chars;
#ifdef V8_HOST_CAN_READ_UNALIGNED
if (sizeof(*dest) == sizeof(*src)) {
if (chars >= static_cast<int>(kMinComplexMemCopy / sizeof(*dest))) {
MemCopy(dest, src, chars * sizeof(*dest));
return;
}
// Number of characters in a uintptr_t.
static const int kStepSize = sizeof(uintptr_t) / sizeof(*dest); // NOLINT
DCHECK(dest + kStepSize > dest); // Check for overflow.
while (dest + kStepSize <= limit) {
*reinterpret_cast<uintptr_t*>(dest) =
*reinterpret_cast<const uintptr_t*>(src);
dest += kStepSize;
src += kStepSize;
}
if ((sizeof(*dest) == sizeof(*src)) &&
(chars >= static_cast<int>(kMinComplexMemCopy / sizeof(*dest)))) {
MemCopy(dest, src, chars * sizeof(*dest));
return;
}
#endif
while (dest < limit) {
Expand Down

0 comments on commit 48b0ca2

Please sign in to comment.