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

Attempt to fix potential compiler segfault in lookup.c #4191

Draft
wants to merge 54 commits into
base: main
Choose a base branch
from

Commits on Jul 27, 2022

  1. Fix for crash involving the use of private types used as default values

    This attempts to fix issues ponylang#4130 and ponylang#4153.
    
    The issue was when a private type in another package was used as a default value in a method call.
    
    Fix to ponylang#4130
    Since it has been decided to treat this as a bug instead of a missing error, this PR implements the fix suggested by @ergl, namely using `lookup_try()` instead of lookup() in call.c's `check_partial_function_call()` since it allows to permit private types.
    
    Fix to ponylang#4153
    This is also a simply fix to lookup.c that prevents a potential segfault by a dereferencing of `opt` (`typecheck_t* t = &opt->check;`) *before* `opt != NULL` was checked. As pointed out by @SeanTAllen, opt should not be NULL to begin with when lookup_nominal is called, and instead, an assert should be added and the NULL checks in that function removed.
    stefandd committed Jul 27, 2022
    Configuration menu
    Copy the full SHA
    527864d View commit details
    Browse the repository at this point in the history
  2. Revert "Fix for crash involving the use of private types used as defa…

    …ult values"
    
    This reverts commit 527864d.
    stefandd committed Jul 27, 2022
    Configuration menu
    Copy the full SHA
    0eae6ef View commit details
    Browse the repository at this point in the history
  3. Fix for crash involving the use of private types used as default values

    This attempts to fix ponylang#4130
    
    This crash stems from the use of a private type as defined in another package when it was used as a default value in a method call. Since it has been decided to treat this as a bug instead of a missing error, this PR implements the fix suggested by @ergl, namely using `lookup_try()` instead of lookup() in call.c's `check_partial_function_call()` since the former can be configured to permit private types.
    
    Fix to ponylang#4153
    This is a simply change to `lookup_nominal()` in lookup.c that prevents a potential segfault by a dereferencing of `opt` (`typecheck_t* t = &opt->check;`) *before* `opt != NULL` was checked. As pointed out by @SeanTAllen, opt should not be NULL to begin with when `lookup_nominal()` is called, and instead, an assert should be added and the NULL checks in that function removed.
    
    With this PR, the two examples below that crashed the compiler now both compile:
    
    Original example:
    ```pony
    // inside the "useful" package
    
    primitive _PrivateDefault
    
    actor Useful[A: Any val]
      fun tag config(value: (A | _PrivateDefault) = _PrivateDefault): Useful[A] => this
    
    // inside "main"
    
    use "useful"
    
    primitive This
    primitive That
    
    type Stuff is (This | That)
    
    actor Main
      new create(env: Env) =>
        let u = Useful[Stuff].config()
    ```
    
    Minimal example:
    ```pony
    // In the "lib" pacakge
    
    primitive _Private
    
    primitive Public
      fun apply[T](v: (T | _Private) = _Private): None => None
    
    // In main
    use lib = "lib"
    
    actor Main
      new create(env: Env) =>
        let p = lib.Public.apply[U8]()
        env.out.print(p.string())
    ```
    stefandd committed Jul 27, 2022
    Configuration menu
    Copy the full SHA
    7c18b7f View commit details
    Browse the repository at this point in the history
  4. Adding test runner

    stefandd committed Jul 27, 2022
    Configuration menu
    Copy the full SHA
    6391765 View commit details
    Browse the repository at this point in the history
  5. Create 4167.md

    Adding release notes
    stefandd committed Jul 27, 2022
    Configuration menu
    Copy the full SHA
    5fd6c26 View commit details
    Browse the repository at this point in the history

Commits on Jul 28, 2022

  1. Update test/libponyc-run/private-type-as-default-argument-in-public-f…

    …unction/main.pony
    
    Co-authored-by: Borja o'Cook <[email protected]>
    stefandd and ergl authored Jul 28, 2022
    Configuration menu
    Copy the full SHA
    cb3b960 View commit details
    Browse the repository at this point in the history

Commits on Jul 30, 2022

  1. Update 4167.md

    stefandd committed Jul 30, 2022
    Configuration menu
    Copy the full SHA
    323e371 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    08de6f7 View commit details
    Browse the repository at this point in the history

Commits on Aug 6, 2022

  1. Configuration menu
    Copy the full SHA
    a7c6399 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    262cdb8 View commit details
    Browse the repository at this point in the history
  3. Update array.pony

    stefandd authored Aug 6, 2022
    Configuration menu
    Copy the full SHA
    0f0afed View commit details
    Browse the repository at this point in the history
  4. Update array.pony

    stefandd committed Aug 6, 2022
    Configuration menu
    Copy the full SHA
    200baea View commit details
    Browse the repository at this point in the history
  5. Create 4173.md

    Add release notes for ponylang#4173
    stefandd committed Aug 6, 2022
    Configuration menu
    Copy the full SHA
    e4c5eae View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    43b1910 View commit details
    Browse the repository at this point in the history

Commits on Aug 7, 2022

  1. Update .release-notes/4173.md

    Co-authored-by: Sean T Allen <[email protected]>
    stefandd and SeanTAllen authored Aug 7, 2022
    Configuration menu
    Copy the full SHA
    dc2758e View commit details
    Browse the repository at this point in the history
  2. Update .release-notes/4173.md

    Co-authored-by: Sean T Allen <[email protected]>
    stefandd and SeanTAllen authored Aug 7, 2022
    Configuration menu
    Copy the full SHA
    6145521 View commit details
    Browse the repository at this point in the history
  3. Update .release-notes/4173.md

    Co-authored-by: Sean T Allen <[email protected]>
    stefandd and SeanTAllen authored Aug 7, 2022
    Configuration menu
    Copy the full SHA
    79cfe22 View commit details
    Browse the repository at this point in the history
  4. Update .release-notes/4173.md

    Co-authored-by: Sean T Allen <[email protected]>
    stefandd and SeanTAllen authored Aug 7, 2022
    Configuration menu
    Copy the full SHA
    5d54c0b View commit details
    Browse the repository at this point in the history
  5. Update .release-notes/4173.md

    Co-authored-by: Sean T Allen <[email protected]>
    stefandd and SeanTAllen authored Aug 7, 2022
    Configuration menu
    Copy the full SHA
    fca55f3 View commit details
    Browse the repository at this point in the history
  6. Update .release-notes/4173.md

    Co-authored-by: Sean T Allen <[email protected]>
    stefandd and SeanTAllen authored Aug 7, 2022
    Configuration menu
    Copy the full SHA
    20bd478 View commit details
    Browse the repository at this point in the history
  7. Update .release-notes/4173.md

    Co-authored-by: Sean T Allen <[email protected]>
    stefandd and SeanTAllen authored Aug 7, 2022
    Configuration menu
    Copy the full SHA
    9646618 View commit details
    Browse the repository at this point in the history
  8. Update .release-notes/4173.md

    Co-authored-by: Sean T Allen <[email protected]>
    stefandd and SeanTAllen authored Aug 7, 2022
    Configuration menu
    Copy the full SHA
    6d19d5a View commit details
    Browse the repository at this point in the history
  9. Update .release-notes/4173.md

    Co-authored-by: Sean T Allen <[email protected]>
    stefandd and SeanTAllen authored Aug 7, 2022
    Configuration menu
    Copy the full SHA
    d3a9a70 View commit details
    Browse the repository at this point in the history
  10. Update packages/builtin_test/_test.pony

    Co-authored-by: Sean T Allen <[email protected]>
    stefandd and SeanTAllen authored Aug 7, 2022
    Configuration menu
    Copy the full SHA
    3e80b98 View commit details
    Browse the repository at this point in the history
  11. Update packages/builtin_test/_test.pony

    Co-authored-by: Sean T Allen <[email protected]>
    stefandd and SeanTAllen authored Aug 7, 2022
    Configuration menu
    Copy the full SHA
    4a8b13a View commit details
    Browse the repository at this point in the history
  12. Update packages/builtin_test/_test.pony

    Co-authored-by: Sean T Allen <[email protected]>
    stefandd and SeanTAllen authored Aug 7, 2022
    Configuration menu
    Copy the full SHA
    1545c6e View commit details
    Browse the repository at this point in the history
  13. Update packages/builtin_test/_test.pony

    Co-authored-by: Sean T Allen <[email protected]>
    stefandd and SeanTAllen authored Aug 7, 2022
    Configuration menu
    Copy the full SHA
    882059c View commit details
    Browse the repository at this point in the history
  14. Update packages/builtin_test/_test.pony

    Co-authored-by: Sean T Allen <[email protected]>
    stefandd and SeanTAllen authored Aug 7, 2022
    Configuration menu
    Copy the full SHA
    533fb92 View commit details
    Browse the repository at this point in the history
  15. Update packages/builtin_test/_test.pony

    Co-authored-by: Sean T Allen <[email protected]>
    stefandd and SeanTAllen authored Aug 7, 2022
    Configuration menu
    Copy the full SHA
    65be1ce View commit details
    Browse the repository at this point in the history
  16. Update packages/builtin_test/_test.pony

    Co-authored-by: Sean T Allen <[email protected]>
    stefandd and SeanTAllen authored Aug 7, 2022
    Configuration menu
    Copy the full SHA
    136ff80 View commit details
    Browse the repository at this point in the history
  17. Update _test.pony

    stefandd committed Aug 7, 2022
    Configuration menu
    Copy the full SHA
    9ee68fa View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    12d54c9 View commit details
    Browse the repository at this point in the history
  19. Update array.pony

    Update fix to include ponylang#4174
    stefandd committed Aug 7, 2022
    Configuration menu
    Copy the full SHA
    b929676 View commit details
    Browse the repository at this point in the history
  20. Update packages/builtin_test/_test.pony

    Co-authored-by: Sean T Allen <[email protected]>
    stefandd and SeanTAllen authored Aug 7, 2022
    Configuration menu
    Copy the full SHA
    e473f72 View commit details
    Browse the repository at this point in the history
  21. Update packages/builtin_test/_test.pony

    Co-authored-by: Sean T Allen <[email protected]>
    stefandd and SeanTAllen authored Aug 7, 2022
    Configuration menu
    Copy the full SHA
    bed272f View commit details
    Browse the repository at this point in the history
  22. Update _test.pony

    stefandd committed Aug 7, 2022
    Configuration menu
    Copy the full SHA
    7daa238 View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    19bc608 View commit details
    Browse the repository at this point in the history
  24. Update array.pony

    stefandd committed Aug 7, 2022
    Configuration menu
    Copy the full SHA
    30e47db View commit details
    Browse the repository at this point in the history
  25. Update _test.pony

    Include tests for ponylang#4174
    stefandd committed Aug 7, 2022
    Configuration menu
    Copy the full SHA
    e2fa066 View commit details
    Browse the repository at this point in the history
  26. Delete 4167.md

    stefandd committed Aug 7, 2022
    Configuration menu
    Copy the full SHA
    0d9099d View commit details
    Browse the repository at this point in the history
  27. Update _test.pony

    Further small test improvement
    stefandd committed Aug 7, 2022
    Configuration menu
    Copy the full SHA
    e83ea4c View commit details
    Browse the repository at this point in the history
  28. Update array.pony

    Ouch -- USize overflow when `_size - src_index` < 0!
    stefandd committed Aug 7, 2022
    Configuration menu
    Copy the full SHA
    1e2448c View commit details
    Browse the repository at this point in the history

Commits on Aug 9, 2022

  1. Update _test.pony

    stefandd authored Aug 9, 2022
    Configuration menu
    Copy the full SHA
    6c9b5ee View commit details
    Browse the repository at this point in the history

Commits on Aug 11, 2022

  1. Update 4173.md

    stefandd authored Aug 11, 2022
    Configuration menu
    Copy the full SHA
    5f763f6 View commit details
    Browse the repository at this point in the history

Commits on Aug 17, 2022

  1. Configuration menu
    Copy the full SHA
    4ff03ba View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c3ca05b View commit details
    Browse the repository at this point in the history

Commits on Aug 22, 2022

  1. Update 4173.md

    stefandd authored Aug 22, 2022
    Configuration menu
    Copy the full SHA
    f70d7b9 View commit details
    Browse the repository at this point in the history
  2. Update array.pony

    It is actually Ok if the `dst_idx == dst._size` (no gap)
    stefandd committed Aug 22, 2022
    Configuration menu
    Copy the full SHA
    3c99979 View commit details
    Browse the repository at this point in the history

Commits on Aug 26, 2022

  1. Configuration menu
    Copy the full SHA
    111189d View commit details
    Browse the repository at this point in the history

Commits on Sep 18, 2022

  1. Attempt to fix ponylang#4153

    stefandd committed Sep 18, 2022
    Configuration menu
    Copy the full SHA
    5b1542d View commit details
    Browse the repository at this point in the history
  2. Update reach.c

    stefandd committed Sep 18, 2022
    Configuration menu
    Copy the full SHA
    9f4f271 View commit details
    Browse the repository at this point in the history

Commits on Sep 19, 2022

  1. Update reach.c

    stefandd committed Sep 19, 2022
    Configuration menu
    Copy the full SHA
    bb41b02 View commit details
    Browse the repository at this point in the history
  2. Update genmatch.c

    stefandd committed Sep 19, 2022
    Configuration menu
    Copy the full SHA
    24cf1ef View commit details
    Browse the repository at this point in the history

Commits on Sep 23, 2022

  1. Configuration menu
    Copy the full SHA
    759b525 View commit details
    Browse the repository at this point in the history