Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(998)

Issue 121000045: code review 121000045: runtime: fix 32 bit build. (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 9 months ago by khr
Modified:
10 years, 9 months ago
Reviewers:
bradfitz
CC:
bradfitz, golang-codereviews
Visibility:
Public.

Description

runtime: fix 32 bit build. int(maxMem) is negative on 32 bits. Need to use unsigned arithmetic.

Patch Set 1 #

Patch Set 2 : diff -r c76aa2c18a0d https://khr%40golang.org@code.google.com/p/go/ #

Patch Set 3 : diff -r c76aa2c18a0d https://khr%40golang.org@code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+4 lines, -4 lines) Patch
M src/pkg/runtime/slice.go View 3 chunks +4 lines, -4 lines 0 comments Download

Messages

Total messages: 3
khr
Hello bradfitz (cc: golang-codereviews@googlegroups.com), I'd like you to review this change to https://khr%40golang.org@code.google.com/p/go/
10 years, 9 months ago (2014-07-31 20:07:14 UTC) #1
khr
*** Submitted as https://code.google.com/p/go/source/detail?r=b55df4e0da18 *** runtime: fix 32 bit build. int(maxMem) is negative on 32 ...
10 years, 9 months ago (2014-07-31 20:07:29 UTC) #2
bradfitz
10 years, 9 months ago (2014-07-31 20:18:04 UTC) #3
LGTM
 On Jul 31, 2014 1:07 PM, <khr@golang.org> wrote:

> Reviewers: bradfitz,
>
> Message:
> Hello bradfitz (cc: golang-codereviews@googlegroups.com),
>
> I'd like you to review this change to
> https://khr%40golang.org@code.google.com/p/go/
>
>
> Description:
> runtime: fix 32 bit build.
>
> int(maxMem) is negative on 32 bits.  Need to use
> unsigned arithmetic.
>
> Please review this at https://codereview.appspot.com/121000045/
>
> Affected files (+4, -4 lines):
>   M src/pkg/runtime/slice.go
>
>
> Index: src/pkg/runtime/slice.go
> ===================================================================
> --- a/src/pkg/runtime/slice.go
> +++ b/src/pkg/runtime/slice.go
> @@ -22,11 +22,11 @@
>         // but since the cap is only being supplied implicitly, saying len
> is clearer.
>         // See issue 4085.
>         len := int(len64)
> -       if len64 < 0 || int64(len) != len64 || t.elem.size > 0 && len >
> int(maxMem/uintptr(t.elem.size)) {
> +       if len64 < 0 || int64(len) != len64 || t.elem.size > 0 &&
> uintptr(len) > maxMem/uintptr(t.elem.size) {
>                 panic(errorString("makeslice: len out of range"))
>         }
>         cap := int(cap64)
> -       if cap < len || int64(cap) != cap64 || t.elem.size > 0 && cap >
> int(maxMem/uintptr(t.elem.size)) {
> +       if cap < len || int64(cap) != cap64 || t.elem.size > 0 &&
> uintptr(cap) > maxMem/uintptr(t.elem.size) {
>                 panic(errorString("makeslice: cap out of range"))
>         }
>         p := newarray(t.elem, uintptr(cap))
> @@ -42,7 +42,7 @@
>         cap64 := int64(old.cap) + n
>         cap := int(cap64)
>
> -       if int64(cap) != cap64 || cap < old.cap || t.elem.size > 0 && cap
> > int(maxMem/uintptr(t.elem.size)) {
> +       if int64(cap) != cap64 || cap < old.cap || t.elem.size > 0 &&
> uintptr(cap) > maxMem/uintptr(t.elem.size) {
>                 panic(errorString("growslice: cap out of range"))
>         }
>
> @@ -74,7 +74,7 @@
>                 }
>         }
>
> -       if newcap >= int(maxMem/uintptr(et.size)) {
> +       if uintptr(newcap) >= maxMem/uintptr(et.size) {
>                 panic(errorString("growslice: cap out of range"))
>         }
>         lenmem := uintptr(old.len) * uintptr(et.size)
>
>
>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b