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

Issue 13413047: code review 13413047: cmd/cgo: replace C.malloc with our own wrapper (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 6 months ago by rsc
Modified:
10 years, 6 months ago
Reviewers:
iant
CC:
golang-dev, iant
Visibility:
Public.

Description

cmd/cgo: replace C.malloc with our own wrapper This allows us to make two changes: 1. Force the argument type to be size_t, even on broken systems that declare malloc to take a ulong. 2. Call runtime.throw if malloc fails. (That is, the program crashes; it does not panic.) Fixes issue 3403. Fixes issue 5926.

Patch Set 1 #

Patch Set 2 : diff -r 22365bd87858 https://code.google.com/p/go/ #

Patch Set 3 : diff -r 22365bd87858 https://code.google.com/p/go/ #

Total comments: 1

Patch Set 4 : diff -r e176e9d59540 https://code.google.com/p/go/ #

Patch Set 5 : diff -r 1b195d6fe342 https://code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+48 lines, -3 lines) Patch
M src/cmd/cgo/ast.go View 1 1 chunk +7 lines, -0 lines 0 comments Download
M src/cmd/cgo/main.go View 1 1 chunk +1 line, -1 line 0 comments Download
M src/cmd/cgo/out.go View 1 2 3 6 chunks +38 lines, -2 lines 0 comments Download
M src/pkg/runtime/cgocall.c View 1 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 6
rsc
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://code.google.com/p/go/
10 years, 6 months ago (2013-09-11 13:13:07 UTC) #1
iant
I don't see any test of this--nothing in misc/cgo/test seems to call malloc directly. https://codereview.appspot.com/13413047/diff/5001/src/cmd/cgo/out.go ...
10 years, 6 months ago (2013-09-11 14:07:37 UTC) #2
rsc
On Wed, Sep 11, 2013 at 10:07 AM, <iant@golang.org> wrote: > I don't see any ...
10 years, 6 months ago (2013-09-11 14:48:01 UTC) #3
rsc
Oh, and for what it's worth there are calls to C.malloc in os/user. Russ
10 years, 6 months ago (2013-09-11 14:48:28 UTC) #4
iant
LGTM I didn't expect a crash test, just something that called malloc to make sure ...
10 years, 6 months ago (2013-09-11 15:29:02 UTC) #5
rsc
10 years, 6 months ago (2013-09-11 15:30:12 UTC) #6
*** Submitted as https://code.google.com/p/go/source/detail?r=46fd4ef6c0de ***

cmd/cgo: replace C.malloc with our own wrapper

This allows us to make two changes:

1. Force the argument type to be size_t, even on broken
   systems that declare malloc to take a ulong.

2. Call runtime.throw if malloc fails.
   (That is, the program crashes; it does not panic.)

Fixes issue 3403.
Fixes issue 5926.

R=golang-dev, iant
CC=golang-dev
https://codereview.appspot.com/13413047
Sign in to reply to this message.

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