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

Fix runtime crash when tracing class iso containing struct val #3993

Merged
merged 4 commits into from
Feb 5, 2022

Conversation

SeanTAllen
Copy link
Member

@SeanTAllen SeanTAllen commented Feb 4, 2022

Prior to this fix, you could crash the runtime if you sent a val struct wrapper in an iso class. For example:

use "collections"

struct val Foo

class Bar
  let f: Foo = Foo

actor Main
  new create(env: Env) =>
    for i in Range(0, 20000) do
      inspect(recover Bar end)
    end

  be inspect(wrap: Bar iso) =>
    None // Do something with wrap.f

Closes #3840

@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Feb 4, 2022
@SeanTAllen
Copy link
Member Author

@ponylang/committer I'm finding a 0.7% performance degradation from this fix as is on the performance test machine.

Here's the basic command being run in case it means anything to you:

sudo cset proc -s user -e numactl -- -C 1-14,15 ./baseline/3840 --pingers 320 --initial-pings 5 --report-count 1 --report-interval 600 --ponynoblock --ponynoscale --ponypinasio --ponypin --ponymaxthreads=14

Roughly:

  • cpu 0 is for kernel and other system processes
  • cpu's 1-15 are for the application
  • cpu's 1-14 are for scheduler threads
  • cpu 15 is for asio

The runs are about 5 minutes (give or take a few nanos) in length.

We are using the following runtime options:

--ponynoblock --ponynoscale --ponypinasio --ponypin --ponymaxthreads=14

I'm going to try some other configurations to see if the same small degradation holds. If pony committers agree this is an acceptable perf lose to fix the bug (I think it is), I'll play around with changing the layout of fields in:

typedef struct object_t
{
  void* address;
  size_t rc;
  uint32_t mark;
  bool immutable;
  pony_type_t* type;
} object_t;

to see if changing the location of type makes a perf difference. I doubt it will, but its worth a try.

Copy link
Member

@jemc jemc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good, and I agree with the small perf loss being acceptable to fix this crash-safety bug.

@SeanTAllen
Copy link
Member Author

I'll look into moving around where type additional field is in object map to see if it has a performance impact. I doubt it will but, it's worth checking and these perf tests are easy to do while watching TV or something.

@SeanTAllen SeanTAllen added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Feb 5, 2022
@ponylang-main
Copy link
Contributor

Hi @SeanTAllen,

The changelog - fixed label was added to this pull request; all PRs with a changelog label need to have release notes included as part of the PR. If you haven't added release notes already, please do.

Release notes are added by creating a uniquely named file in the .release-notes directory. We suggest you call the file 3993.md to match the number of this pull request.

The basic format of the release notes (using markdown) should be:

## Title

End user description of changes, why it's important,
problems it solves etc.

If a breaking change, make sure to include 1 or more
examples what code would look like prior to this change
and how to update it to work after this change.

Thanks.

@SeanTAllen SeanTAllen changed the title Fix for 3840 Fix runtime crash when tracing class iso containing struct val Feb 5, 2022
@SeanTAllen
Copy link
Member Author

There's no difference I can see when moving where in objectmap the type is located, so I'm leaving as-is at the end.

@SeanTAllen SeanTAllen marked this pull request as ready for review February 5, 2022 00:14
@SeanTAllen SeanTAllen mentioned this pull request Feb 5, 2022
@SeanTAllen SeanTAllen merged commit 76ec215 into main Feb 5, 2022
@SeanTAllen SeanTAllen deleted the issue-3840 branch February 5, 2022 00:43
@ponylang-main ponylang-main removed the discuss during sync Should be discussed during an upcoming sync label Feb 5, 2022
github-actions bot pushed a commit that referenced this pull request Feb 5, 2022
github-actions bot pushed a commit that referenced this pull request Feb 5, 2022
SeanTAllen added a commit that referenced this pull request Feb 5, 2022
With the merging of #3993, the changes from #3781 are no longer needed.
SeanTAllen added a commit that referenced this pull request Feb 5, 2022
…eters" (#3995)

The bug that [#3781](#3781) aka "prevent non-opaque structs from being used as behaviour parameters" was an attempt at preventing, as only partially solved by the change.

We've introduced a full fix in [#3993](#3993) that removes the need for [#3871](#3781).
SeanTAllen added a commit that referenced this pull request Feb 6, 2022
I was storing the type for the wrong object into the object map
in acquire_object. This led to ponyup going boom.

Other programs would as well, but ponyup exhibited.

I'm going to spend some time thinking about how to test this, but
at the moment I don't know the specific combo of Pony code that
got us here.
SeanTAllen added a commit that referenced this pull request Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Runtime crash when tracing class iso containing struct val.
3 participants