Skip to content

Conversation

@bkase
Copy link
Member

@bkase bkase commented Jan 10, 2019

Before this change on macOS systems, libsnark would crash on
get_root_of_unity and exception handlers would not work. The
hypothesis is that using exceptions for control flow in
get_evaluation_domain triggers some sort of UB (probably because this
runs statically before the main function). On Linux, the UB happens to
work properly, but on OSX it doesn't. As such, I rewrote all the
control-flow related exception handling in get_evaluation_domain to use
an error bool pointer.

I'll open a PR against libsnark directly when the review for this PR
finishes.

On macOS the Coda build succeeds only after these changes are made (as
we use libsnark at compile time). CI will tell us that the build still
works on Linux.

#include <libff/common/double.hpp>
#include <libff/common/utils.hpp>

#include <execinfo.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

unneeded

@emberian
Copy link
Contributor

bool* should be bool&

bkase added 3 commits January 9, 2019 18:04
Before this change on macOS systems, libsnark would crash on
get_root_of_unity and exception handlers would not work. The
hypothesis is that using exceptions for control flow in
get_evaluation_domain triggers some sort of UB (probably because this
runs statically before the main function). On Linux, the UB happens to
work properly, but on OSX it doesn't. As such, I rewrote all the
control-flow related exception handling in get_evaluation_domain to use
an error bool pointer.

I'll open a PR against libsnark directly when the review for this PR
finishes.
@bkase bkase force-pushed the libsnark-macos-support branch from 52fc59f to 5b8b806 Compare January 10, 2019 05:47
@emberian
Copy link
Contributor

There are ways to avoid initializing those fields on exit paths, but the code is already there, and it's the FieldTs that are expensive anyway. I'm fine with it. Thank you for not letting uninitialized data escape.

@bkase bkase merged commit 750d8a3 into master Jan 10, 2019
@emberian emberian deleted the libsnark-macos-support branch January 10, 2019 23:51
@HarryR
Copy link

HarryR commented Jul 4, 2019

Dredging this back up as it's relevant again for me.

The hypothesis is that using exceptions for control flow in...

Yup, that's the problem.

It's preventing two things in a different project:

  1. Optimized builds on OSX (enabling -O3 triggers this, normal builds on OSX work fine)
  2. Cheerp WASM build, which are unable to catch exceptions so abort() instead.

It seems no pull requests are getting merged into libsnark, so will have to fork and apply this to my branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants