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 incorrect exception handling on aarch64 #4084

Closed
wants to merge 9 commits into from
Closed

Conversation

SeanTAllen
Copy link
Member

@SeanTAllen SeanTAllen commented Apr 2, 2022

Our exception handling on aarch64 was incorrect and could lead to valid Pony
programs segfaulting at runtime. This was the result of us never having done an
aarch64 port. A Pony user got us compiling on aarch64 and tests passed, but
there were situations where the incorrect exception handling would cause us to
crash.

In general, the crash was being hidden because the inliner would remove one of
the conditions needed to trigger the problem.

This commit was manually validated on a Raspbian 64-bit installation to verify
the fix.

Fixes #3874

@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Apr 2, 2022
@@ -216,7 +216,9 @@ static bool lsda_init(lsda_t* lsda, exception_context_t* context)
return true;
}

bool ponyint_lsda_scan(exception_context_t* context, uintptr_t* lp)
bool ponyint_lsda_scan(uintptr_t* ttype_index __attribute__ ((unused)),
Copy link
Member Author

Choose a reason for hiding this comment

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

the unused is required to keep gcc from complaining.

gcc has a warning for parameters that aren't used but are set. ttype_index is an output parameter so it needs to be set.

@SeanTAllen
Copy link
Member Author

This first comment on this issue should be used as the commit comment when squashing.

@SeanTAllen SeanTAllen marked this pull request as ready for review April 2, 2022 20:26
@SeanTAllen SeanTAllen added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Apr 2, 2022
@SeanTAllen SeanTAllen requested review from a team and removed request for a team April 2, 2022 20:26
@SeanTAllen SeanTAllen marked this pull request as draft April 2, 2022 20:27
CodeGenOpt::Level opt_level =
opt->release ? CodeGenOpt::Aggressive :
target_is_arm(opt->triple) ? CodeGenOpt::Default : CodeGenOpt::None;
opt->release ? CodeGenOpt::Aggressive : CodeGenOpt::None;
Copy link
Member Author

Choose a reason for hiding this comment

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

This was our workaround.

@@ -0,0 +1,14 @@
actor Main
Copy link
Member Author

@SeanTAllen SeanTAllen Apr 2, 2022

Choose a reason for hiding this comment

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

Neither regression really does anything in CI at the moment because there's only a single runner run and it's in release mode, not debug mode, so these would get inlined away. I've opened a conversation in the ci stream on zulip to discuss how to change.

@SeanTAllen
Copy link
Member Author

So, I've flipped the problem here now on aarch64, so more work needs to be done.

In...

actor Main
  let _out: OutStream

  new create(env: Env) =>
    _out = env.out
    foo("hello")

  fun foo(s: String) =>
    try
      one("h")
      error
    else
      one("e")
    end

  fun one(s: String) =>
    _out.print(s)

it used to be in one that s was null. now it has a correct value and _out is null. So back looking at the c++ personality and making ours still more like it.

@jemc jemc removed the discuss during sync Should be discussed during an upcoming sync label Apr 12, 2022
@SeanTAllen SeanTAllen closed this Apr 30, 2022
@SeanTAllen SeanTAllen deleted the issue-3874 branch April 30, 2022 11:30
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.

Segmentation fault caused by likely LLVM bug that results in incorrect exception handling on aarch64
3 participants