Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
ddd06f53
Commit
ddd06f53
authored
Sep 28, 2012
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runtime: Better detection of memory allocation request overflow.
From-SVN: r191841
parent
e78410bf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
2 deletions
+16
-2
libgo/runtime/chan.c
+3
-1
libgo/runtime/go-append.c
+3
-0
libgo/runtime/go-make-slice.c
+1
-1
libgo/runtime/malloc.h
+9
-0
No files found.
libgo/runtime/chan.c
View file @
ddd06f53
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
#include "runtime.h"
#include "runtime.h"
#include "arch.h"
#include "malloc.h"
#include "go-type.h"
#include "go-type.h"
#define NOSELGEN 1
#define NOSELGEN 1
...
@@ -88,7 +90,7 @@ runtime_makechan_c(ChanType *t, int64 hint)
...
@@ -88,7 +90,7 @@ runtime_makechan_c(ChanType *t, int64 hint)
elem
=
t
->
__element_type
;
elem
=
t
->
__element_type
;
if
(
hint
<
0
||
(
int32
)
hint
!=
hint
||
(
elem
->
__size
>
0
&&
(
uintptr
)
hint
>
((
uintptr
)
-
1
)
/
elem
->
__size
))
if
(
hint
<
0
||
(
int32
)
hint
!=
hint
||
(
elem
->
__size
>
0
&&
(
uintptr
)
hint
>
MaxMem
/
elem
->
__size
))
runtime_panicstring
(
"makechan: size out of range"
);
runtime_panicstring
(
"makechan: size out of range"
);
n
=
sizeof
(
*
c
);
n
=
sizeof
(
*
c
);
...
...
libgo/runtime/go-append.c
View file @
ddd06f53
...
@@ -54,6 +54,9 @@ __go_append (struct __go_open_array a, void *bvalues, uintptr_t bcount,
...
@@ -54,6 +54,9 @@ __go_append (struct __go_open_array a, void *bvalues, uintptr_t bcount,
while
(
m
<
count
);
while
(
m
<
count
);
}
}
if
((
uintptr
)
m
>
MaxMem
/
element_size
)
runtime_panicstring
(
"growslice: cap out of range"
);
n
=
__go_alloc
(
m
*
element_size
);
n
=
__go_alloc
(
m
*
element_size
);
__builtin_memcpy
(
n
,
a
.
__values
,
a
.
__count
*
element_size
);
__builtin_memcpy
(
n
,
a
.
__values
,
a
.
__count
*
element_size
);
...
...
libgo/runtime/go-make-slice.c
View file @
ddd06f53
...
@@ -37,7 +37,7 @@ __go_make_slice2 (const struct __go_type_descriptor *td, uintptr_t len,
...
@@ -37,7 +37,7 @@ __go_make_slice2 (const struct __go_type_descriptor *td, uintptr_t len,
if
(
cap
<
len
if
(
cap
<
len
||
(
uintptr_t
)
icap
!=
cap
||
(
uintptr_t
)
icap
!=
cap
||
(
std
->
__element_type
->
__size
>
0
||
(
std
->
__element_type
->
__size
>
0
&&
cap
>
(
uintptr_t
)
-
1U
/
std
->
__element_type
->
__size
))
&&
cap
>
MaxMem
/
std
->
__element_type
->
__size
))
runtime_panicstring
(
"makeslice: cap out of range"
);
runtime_panicstring
(
"makeslice: cap out of range"
);
ret
.
__count
=
ilen
;
ret
.
__count
=
ilen
;
...
...
libgo/runtime/malloc.h
View file @
ddd06f53
...
@@ -128,6 +128,15 @@ enum
...
@@ -128,6 +128,15 @@ enum
MaxGcproc
=
4
,
MaxGcproc
=
4
,
};
};
// Maximum memory allocation size, a hint for callers.
// This must be a #define instead of an enum because it
// is so large.
#if __SIZEOF_POINTER__ == 8
#define MaxMem (16ULL<<30)
/* 16 GB */
#else
#define MaxMem ((uintptr)-1)
#endif
// A generic linked list of blocks. (Typically the block is bigger than sizeof(MLink).)
// A generic linked list of blocks. (Typically the block is bigger than sizeof(MLink).)
struct
MLink
struct
MLink
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment