Commit 046379e
committed
Tighten GCC 2-region _sbrk
When moving to the second heap region due to overflowing the first
region, the `_sbrk` implementation assumed the allocation would fit in
the second region, and didn't check for that overflowing too.
Problem revealed in `stats_heap` test with GCC 8 on K64F - the allocation
attempt for 1GiB crashed, as `_sbrk` indicated 1GiB was available at the
start of the second region.
second region.
Presumably older versions of newlib fault that allocation attempt before
passing to `_sbrk`.
While there, adjust the code to not use a separate static `bool`, saving
RAM. We can track with just one pointer, as order of the two regions is
fixed, and already relied on by newlib.1 parent ab857c4 commit 046379e
1 file changed
+6
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1268 | 1268 | | |
1269 | 1269 | | |
1270 | 1270 | | |
1271 | | - | |
| 1271 | + | |
1272 | 1272 | | |
1273 | 1273 | | |
1274 | 1274 | | |
1275 | 1275 | | |
1276 | 1276 | | |
1277 | 1277 | | |
1278 | 1278 | | |
1279 | | - | |
1280 | 1279 | | |
1281 | 1280 | | |
1282 | 1281 | | |
1283 | 1282 | | |
1284 | | - | |
1285 | | - | |
| 1283 | + | |
1286 | 1284 | | |
1287 | | - | |
1288 | | - | |
| 1285 | + | |
1289 | 1286 | | |
1290 | 1287 | | |
1291 | | - | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
1292 | 1291 | | |
1293 | 1292 | | |
1294 | 1293 | | |
| |||
0 commit comments