Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promote objects more eagerly #49644

Merged
merged 7 commits into from Jun 14, 2023
Merged

Promote objects more eagerly #49644

merged 7 commits into from Jun 14, 2023

Conversation

d-netto
Copy link
Member

@d-netto d-netto commented May 5, 2023

Before:

/*
 * The state transition looks like :
 *
 * ([(quick)sweep] means either a sweep or a quicksweep)
 *
 * <-[(quick)sweep]-
 *                 |
 *     ---->  GC_OLD  <--[(quick)sweep && age>promotion]--
 *     |     |                                           |
 *     |     |  GC_MARKED (in remset)                    |
 *     |     |     ^            |                        |
 *     |   [mark]  |          [mark]                     |
 *     |     |     |            |                        |
 *     |     |     |            |                        |
 *  [sweep]  | [write barrier]  |                        |
 *     |     v     |            v                        |
 *     ----- GC_OLD_MARKED <----                         |
 *              |               ^                        |
 *              |               |                        |
 *              --[quicksweep]---                        |
 *                                                       |
 *  ========= above this line objects are old =========  |
 *                                                       |
 *  ----[new]------> GC_CLEAN ------[mark]-----------> GC_MARKED
 *                    |    ^                                   |
 *  <-[(quick)sweep]---    |                                   |
 *                         --[(quick)sweep && age<=promotion]---
 */

After:

/*
 * The state transition looks like :
 *
 * ([(quick)sweep] means either a sweep or a quicksweep)
 *
 * <-[(quick)sweep]-
 *                 |
 *     ---->  GC_OLD  <--[(quick)sweep]-------------------
 *     |     |                                           |
 *     |     |  GC_MARKED (in remset)                    |
 *     |     |     ^            |                        |
 *     |   [mark]  |          [mark]                     |
 *     |     |     |            |                        |
 *     |     |     |            |                        |
 *  [sweep]  | [write barrier]  |                        |
 *     |     v     |            v                        |
 *     ----- GC_OLD_MARKED <----                         |
 *              |               ^                        |
 *              |               |                        |
 *              --[quicksweep]---                        |
 *                                                       |
 *  ========= above this line objects are old =========  |
 *                                                       |
 *  ----[new]------> GC_CLEAN ------[mark]-----------> GC_MARKED
 *                    |
 *  <-[(quick)sweep]---
 *
 */

@d-netto d-netto added the GC Garbage collector label May 5, 2023
@d-netto d-netto requested review from gbaraldi and vchuravy May 5, 2023 02:36
@gbaraldi
Copy link
Member

gbaraldi commented May 5, 2023

Did you measure the impact of this change?

@yuyichao
Copy link
Contributor

yuyichao commented May 5, 2023

I believe this was not done before since this will cause too many objects to be promoted to old.

@d-netto
Copy link
Member Author

d-netto commented May 5, 2023

On the serial benchmarks from GCBenchmarks:

  • master (commit ee95843):
category = "GCBench"
bench = "GCBench.jl"
┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │        236 │      54 │        25 │         29 │           45 │               124 │       81 │         22 │
│  median │        246 │      57 │        25 │         32 │           53 │               139 │       81 │         23 │
│ maximum │        263 │      60 │        28 │         34 │           60 │               160 │       81 │         24 │
│   stdev │          9 │       2 │         1 │          2 │            5 │                11 │        0 │          1 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘
category = "TimeZones"
bench = "TimeZones.jl"
┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │      17851 │   17257 │     16700 │        557 │         1736 │               100 │     5421 │         96 │
│  median │      19082 │   18466 │     17850 │        630 │         1910 │               113 │     5421 │         97 │
│ maximum │      20698 │   20118 │     19427 │        825 │         2145 │               128 │     5421 │         97 │
│   stdev │        903 │     907 │       849 │         78 │          128 │                 8 │        0 │          0 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘
category = "append"
bench = "append.jl"
┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │        776 │      62 │        11 │         51 │           48 │                95 │     1523 │          8 │
│  median │        829 │      69 │        11 │         57 │           54 │               118 │     1523 │          8 │
│ maximum │        885 │      74 │        13 │         62 │           64 │               134 │     1523 │          9 │
│   stdev │         33 │       4 │         1 │          3 │            5 │                11 │        0 │          0 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘
category = "bigint"
bench = "pollard.jl"
┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │        583 │     151 │       135 │         15 │           41 │                59 │      118 │         23 │
│  median │        619 │     157 │       141 │         15 │           51 │                64 │      118 │         26 │
│ maximum │        690 │     170 │       155 │         18 │           56 │                72 │      118 │         27 │
│   stdev │         39 │       6 │         5 │          1 │            5 │                 5 │        0 │          2 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘
category = "linked"
bench = "list.jl"
┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │       4634 │    3683 │      3290 │        277 │         1409 │                74 │     2459 │         79 │
│  median │       5013 │    4067 │      3651 │        408 │         1721 │                82 │     2459 │         81 │
│ maximum │       5132 │    4182 │      3734 │        458 │         1852 │               106 │     2459 │         82 │
│   stdev │        139 │     135 │       126 │         55 │          133 │                 9 │        0 │          1 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘
bench = "tree.jl"
┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │       3651 │     340 │       332 │          8 │          236 │                18 │      118 │          9 │
│  median │       3878 │     345 │       337 │          8 │          239 │                21 │      118 │          9 │
│ maximum │       4504 │     396 │       385 │         11 │          261 │                29 │      118 │          9 │
│   stdev │        273 │      20 │        19 │          1 │            9 │                 3 │        0 │          0 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘
category = "obj_arrays"
bench = "many_refs.jl"
┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │       1659 │    1450 │      1319 │        131 │          388 │                11 │      876 │         86 │
│  median │       1719 │    1496 │      1364 │        132 │          396 │                13 │      877 │         87 │
│ maximum │       1808 │    1588 │      1438 │        161 │          434 │                17 │      877 │         88 │
│   stdev │         50 │      47 │        39 │         10 │           18 │                 2 │        0 │          0 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘
bench = "single_ref.jl"
┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │        663 │     506 │       491 │         13 │          154 │                15 │      876 │         74 │
│  median │        695 │     524 │       511 │         14 │          161 │                18 │      876 │         76 │
│ maximum │        718 │     544 │       531 │         15 │          170 │                29 │      876 │         77 │
│   stdev │         16 │      12 │        12 │          1 │            6 │                 4 │        0 │          1 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘
category = "strings"
bench = "strings.jl"
┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │      18717 │    3101 │      2819 │        282 │           64 │               437 │      587 │         16 │
│  median │      19810 │    3281 │      2987 │        290 │           78 │               470 │      587 │         17 │
│ maximum │      20456 │    3440 │      3139 │        301 │           94 │               498 │      587 │         17 │
│   stdev │        654 │     117 │       111 │          7 │           10 │                20 │        0 │          0 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘
  • PR (commit ad6d040):
category = "GCBench"
bench = "GCBench.jl"
┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │        224 │      43 │        17 │         25 │           44 │               131 │       81 │         18 │
│  median │        232 │      45 │        18 │         27 │           58 │               148 │       81 │         20 │
│ maximum │        246 │      50 │        21 │         31 │           69 │               168 │       81 │         21 │
│   stdev │          7 │       2 │         1 │          2 │            8 │                13 │        0 │          1 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘
category = "TimeZones"
bench = "TimeZones.jl"
┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │      16554 │   15988 │     15484 │        489 │         1747 │               106 │     5420 │         96 │
│  median │      16992 │   16383 │     15855 │        521 │         1843 │               121 │     5420 │         97 │
│ maximum │      18237 │   17627 │     17058 │        605 │         2089 │               153 │     5420 │         97 │
│   stdev │        665 │     661 │       626 │         41 │          114 │                12 │        0 │          0 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘
category = "append"
bench = "append.jl"
┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │        735 │      57 │         5 │         52 │           46 │               156 │     1489 │          7 │
│  median │        814 │      63 │         6 │         58 │           54 │               173 │     1489 │          8 │
│ maximum │       1063 │      69 │         6 │         64 │           62 │               215 │     1490 │          8 │
│   stdev │         92 │       4 │         0 │          4 │            4 │                17 │        0 │          1 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘
category = "bigint"
bench = "pollard.jl"
┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │        561 │     136 │       127 │          9 │           52 │                56 │      125 │         21 │
│  median │        622 │     139 │       128 │         10 │           57 │                63 │      125 │         23 │
│ maximum │        655 │     147 │       136 │         11 │           62 │                88 │      125 │         25 │
│   stdev │         36 │       4 │         4 │          1 │            4 │                 9 │        0 │          2 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘
category = "linked"
bench = "list.jl"
┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │       3933 │    3015 │      2821 │        194 │         1210 │                81 │     2459 │         76 │
│  median │       4069 │    3141 │      2897 │        256 │         1362 │                89 │     2459 │         77 │
│ maximum │       4214 │    3304 │      3021 │        311 │         1508 │               107 │     2462 │         78 │
│   stdev │         80 │      89 │        58 │         36 │          111 │                 8 │        1 │          1 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘
bench = "tree.jl"
┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │       3630 │     333 │       328 │          4 │          236 │                20 │      119 │          9 │
│  median │       3996 │     356 │       351 │          5 │          251 │                21 │      120 │          9 │
│ maximum │       4090 │     395 │       391 │          5 │          290 │                23 │      120 │         10 │
│   stdev │        165 │      17 │        16 │          0 │           16 │                 1 │        0 │          0 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘
category = "obj_arrays"
bench = "many_refs.jl"
┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │       1287 │    1083 │      1025 │         55 │          356 │                11 │      876 │         82 │
│  median │       1348 │    1119 │      1058 │         58 │          371 │                14 │      877 │         84 │
│ maximum │       1372 │    1156 │      1094 │         90 │          386 │                18 │      877 │         85 │
│   stdev │         28 │      24 │        21 │         10 │            9 │                 2 │        0 │          1 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘
bench = "single_ref.jl"
┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │        550 │     387 │       374 │         13 │          128 │                15 │      876 │         70 │
│  median │        577 │     408 │       396 │         13 │          136 │                23 │      876 │         71 │
│ maximum │        613 │     454 │       439 │         15 │          173 │                27 │      876 │         74 │
│   stdev │         23 │      21 │        21 │          1 │           13 │                 4 │        0 │          1 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘
category = "strings"
bench = "strings.jl"
┌─────────┬────────────┬─────────┬───────────┬────────────┬──────────────┬───────────────────┬──────────┬────────────┐
│         │ total time │ gc time │ mark time │ sweep time │ max GC pause │ time to safepoint │ max heap │ percent gc │
│         │         ms │      ms │        ms │         ms │           ms │                us │       MB │          % │
├─────────┼────────────┼─────────┼───────────┼────────────┼──────────────┼───────────────────┼──────────┼────────────┤
│ minimum │      17553 │    1933 │      1737 │        197 │           49 │               428 │      587 │         11 │
│  median │      17985 │    2045 │      1845 │        202 │           59 │               474 │      587 │         11 │
│ maximum │      19404 │    2143 │      1930 │        212 │           71 │               523 │      587 │         12 │
│   stdev │        635 │      68 │        63 │          5 │            6 │                30 │        0 │          0 │
└─────────┴────────────┴─────────┴───────────┴────────────┴──────────────┴───────────────────┴──────────┴────────────┘

For reference:

julia> versioninfo()
Julia Version 1.10.0-DEV.1209
Commit ad6d040bdb (2023-05-05 02:47 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin22.2.0)
  CPU: 8 × Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, apple-m1)
  Threads: 1 on 4 virtual cores

@gbaraldi
Copy link
Member

gbaraldi commented May 5, 2023

At least from those benchmarks it does seem to be a pretty clean win.

@vchuravy
Copy link
Sponsor Member

vchuravy commented May 5, 2023

So I would like to understand the trade-off better (especially in light of #49545 (comment))

IIUC we are trading length of short pauses for increased memory usage (and maybe more frequent pauses)?
How does rbtree behave? Both in throughput and GC time?

@gbaraldi
Copy link
Member

gbaraldi commented May 5, 2023

The issue there is that it seems we should do a full collection every once in a while but don't.

@d-netto d-netto force-pushed the sweep branch 2 times, most recently from 428d249 to 2a6653d Compare May 6, 2023 14:51
@d-netto
Copy link
Member Author

d-netto commented May 6, 2023

So I would like to understand the trade-off better

One of the relevant metrics for our GC is our many times an object is scanned before reaching GC_OLD_MARKED. When it reaches this state, it's no longer scanned on an incremental mark pass.

This PR reduces the number of mark passes until GC_OLD_MARKED from 3 to 2.

3 passes seems overly conservative, and I think that we could keep our young generation smaller (e.g. shorter pauses in the incremental mark) by promoting objects more eagerly.

Ideally, we should be more quantitative about this by doing a demographic analysis of our heap, but I'm not sure how feasible this is.

@d-netto d-netto changed the title Simplify GC generational behavior by promoting objects more eagerly Promote objects more eagerly May 8, 2023
@d-netto d-netto requested a review from vtjnash May 17, 2023 22:50
src/gc.c Show resolved Hide resolved
@vtjnash
Copy link
Sponsor Member

vtjnash commented May 20, 2023

The reasoning seems to make sense to me. I didn't realize we had essentially 2 age bits, because of the GC_OLD bit state operating that way as well.

I think a broader question here still yet to be investigated is whether we can do even better if we keep this code, but split the older generation in 2, so that there is a young generation that promotes quickly (as this PR does), then a middle aged generation (using the age bits, or perhaps still without them), and finally an old generation (and then also system image / yoda generation too). With appropriate remset and other tracking metadata as relevant for each.

The way that this transitions now alternatively makes me think we should take a hard look at whether the sweep phase is needed anymore, or could be lazy, since all it seems to be doing is swapping GC_MARKED for GC_OLD, which it seems that we could alternatively do by inverting the color for them. With 00 meaning young (or remset), 01 and 10 being marked or old (depending on that page's current color), and 11 being marked and old.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Jun 12, 2023

Shall we merge this?

@gbaraldi
Copy link
Member

I would say yes

@d-netto
Copy link
Member Author

d-netto commented Jun 13, 2023

Will merge tomorrow if there are no objections.

@vchuravy vchuravy merged commit 03c4bc1 into JuliaLang:master Jun 14, 2023
6 checks passed
fingolfin added a commit to fingolfin/julia that referenced this pull request Jun 20, 2023
The function `jl_gc_internal_obj_base_ptr` takes a pointer and tries to
determine if it is a valid object pointer. As such it has to carefully
validate all data it reads, and abort whenever there are obvious
inconsistencies.

This patch adds a check which aborts when `meta->osize` is zero, just
before we perform a division-with-remainder by this value, thus avoiding
a potential division-by-zero exception. This fixes a crash we are seeing
in our code.

The crash did not happen before PR JuliaLang#49644 was merged because back then
there was a check for `meta->ages` not being zero, which apparently was
enough to detect invalid values for `meta` (e.g. when `meta` points into
a null page).
vtjnash pushed a commit that referenced this pull request Jun 22, 2023
The function `jl_gc_internal_obj_base_ptr` takes a pointer and tries to
determine if it is a valid object pointer. As such it has to carefully
validate all data it reads, and abort whenever there are obvious
inconsistencies.

This patch adds a check which aborts when `meta->osize` is zero, just
before we perform a division-with-remainder by this value, thus avoiding
a potential division-by-zero exception. This fixes a crash we are seeing
in our code.

The crash did not happen before PR #49644 was merged because back then
there was a check for `meta->ages` not being zero, which apparently was
enough to detect invalid values for `meta` (e.g. when `meta` points into
a null page).
d-netto added a commit to RelationalAI/julia that referenced this pull request Aug 6, 2023
d-netto added a commit to RelationalAI/julia that referenced this pull request Sep 27, 2023
d-netto added a commit to RelationalAI/julia that referenced this pull request Oct 2, 2023
kpamnany pushed a commit to RelationalAI/julia that referenced this pull request Oct 19, 2023
kpamnany pushed a commit to RelationalAI/julia that referenced this pull request Oct 19, 2023
DelveCI pushed a commit to RelationalAI/julia that referenced this pull request Oct 20, 2023
kpamnany pushed a commit to RelationalAI/julia that referenced this pull request Oct 21, 2023
DelveCI pushed a commit to RelationalAI/julia that referenced this pull request Oct 23, 2023
DelveCI pushed a commit to RelationalAI/julia that referenced this pull request Nov 1, 2023
DelveCI pushed a commit to RelationalAI/julia that referenced this pull request Nov 2, 2023
DelveCI pushed a commit to RelationalAI/julia that referenced this pull request Nov 7, 2023
DelveCI pushed a commit to RelationalAI/julia that referenced this pull request Nov 10, 2023
DelveCI pushed a commit to RelationalAI/julia that referenced this pull request Nov 14, 2023
DelveCI pushed a commit to RelationalAI/julia that referenced this pull request Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GC Garbage collector
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants