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

Add segfault catcher. #1053

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Add segfault catcher. #1053

wants to merge 3 commits into from

Conversation

azteca1998
Copy link
Collaborator

Simplified version of #959. Does not attempt to grow the stack, just catches segfaults and returns an error.

Checklist

  • Linked to Github Issue
  • Unit tests added
  • Integration tests added.
  • This change requires new documentation.
    • Documentation has been added/updated.

@azteca1998 azteca1998 marked this pull request as ready for review January 15, 2025 23:52
Copy link

github-actions bot commented Jan 16, 2025

Benchmark results Main vs HEAD.

Command Mean [s] Min [s] Max [s] Relative
base dict_insert.cairo (JIT) 3.834 ± 0.021 3.805 3.876 1.00
base dict_insert.cairo (AOT) 3.970 ± 0.019 3.944 3.996 1.04 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
:--- ---: ---: ---: ---:
head dict_insert.cairo (JIT) 3.888 ± 0.035 3.850 3.967 1.00
head dict_insert.cairo (AOT) 4.020 ± 0.038 3.974 4.090 1.03 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base dict_snapshot.cairo (JIT) 3.726 ± 0.026 3.701 3.791 1.00
base dict_snapshot.cairo (AOT) 3.872 ± 0.019 3.850 3.910 1.04 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
:--- ---: ---: ---: ---:
head dict_snapshot.cairo (JIT) 3.745 ± 0.043 3.696 3.856 1.00
head dict_snapshot.cairo (AOT) 3.870 ± 0.013 3.850 3.895 1.03 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base factorial_2M.cairo (JIT) 4.111 ± 0.037 4.060 4.179 1.00
base factorial_2M.cairo (AOT) 4.274 ± 0.025 4.235 4.303 1.04 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
:--- ---: ---: ---: ---:
head factorial_2M.cairo (JIT) 4.096 ± 0.029 4.073 4.161 1.00
head factorial_2M.cairo (AOT) 4.406 ± 0.040 4.345 4.448 1.08 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base fib_2M.cairo (JIT) 3.604 ± 0.020 3.567 3.629 1.00
base fib_2M.cairo (AOT) 3.828 ± 0.015 3.805 3.848 1.06 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
:--- ---: ---: ---: ---:
head fib_2M.cairo (JIT) 3.750 ± 0.074 3.673 3.900 1.00
head fib_2M.cairo (AOT) 3.865 ± 0.033 3.824 3.923 1.03 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base linear_search.cairo (JIT) 3.832 ± 0.029 3.785 3.877 1.00
base linear_search.cairo (AOT) 3.968 ± 0.028 3.915 4.003 1.04 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
:--- ---: ---: ---: ---:
head linear_search.cairo (JIT) 3.901 ± 0.044 3.838 3.969 1.00
head linear_search.cairo (AOT) 4.036 ± 0.038 3.986 4.099 1.03 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base logistic_map.cairo (JIT) 3.904 ± 0.037 3.863 3.977 1.00
base logistic_map.cairo (AOT) 4.005 ± 0.032 3.946 4.049 1.03 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
:--- ---: ---: ---: ---:
head logistic_map.cairo (JIT) 4.039 ± 0.060 3.927 4.119 1.00
head logistic_map.cairo (AOT) 4.203 ± 0.042 4.141 4.282 1.04 ± 0.02

Copy link

github-actions bot commented Jan 16, 2025

Benchmarking results

Benchmark for program dict_insert

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 20.890 ± 0.107 20.754 21.079 95.07 ± 1.70
cairo-native (embedded AOT) 4.177 ± 0.041 4.100 4.240 19.01 ± 0.37
cairo-native (embedded JIT using LLVM's ORC Engine) 3.979 ± 0.022 3.946 4.017 18.11 ± 0.33
cairo-native (standalone AOT with -march=native) 0.220 ± 0.004 0.215 0.227 1.00

Benchmark for program dict_snapshot

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 5.890 ± 0.035 5.847 5.954 2909.00 ± 144.23
cairo-native (embedded AOT) 3.989 ± 0.035 3.932 4.043 1970.47 ± 98.52
cairo-native (embedded JIT using LLVM's ORC Engine) 4.018 ± 0.036 3.955 4.060 1984.39 ± 99.25
cairo-native (standalone AOT with -march=native) 0.002 ± 0.000 0.002 0.003 1.00

Benchmark for program factorial_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 14.614 ± 0.094 14.507 14.779 10.73 ± 0.10
cairo-native (embedded AOT) 4.261 ± 0.026 4.228 4.303 3.13 ± 0.03
cairo-native (embedded JIT using LLVM's ORC Engine) 4.097 ± 0.033 4.063 4.153 3.01 ± 0.03
cairo-native (standalone AOT with -march=native) 1.363 ± 0.010 1.355 1.387 1.00

Benchmark for program fib_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 14.516 ± 0.066 14.403 14.602 180.17 ± 2.79
cairo-native (embedded AOT) 3.785 ± 0.018 3.754 3.803 46.98 ± 0.73
cairo-native (embedded JIT using LLVM's ORC Engine) 3.578 ± 0.045 3.536 3.667 44.41 ± 0.86
cairo-native (standalone AOT with -march=native) 0.081 ± 0.001 0.080 0.088 1.00

Benchmark for program linear_search

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 6.147 ± 0.055 6.051 6.227 3031.73 ± 77.49
cairo-native (embedded AOT) 4.210 ± 0.063 4.128 4.320 2076.27 ± 58.68
cairo-native (embedded JIT using LLVM's ORC Engine) 3.947 ± 0.063 3.873 4.055 1946.54 ± 55.93
cairo-native (standalone AOT with -march=native) 0.002 ± 0.000 0.002 0.002 1.00

Benchmark for program logistic_map

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 5.869 ± 0.052 5.803 5.980 24.20 ± 0.22
cairo-native (embedded AOT) 4.160 ± 0.066 4.088 4.319 17.16 ± 0.27
cairo-native (embedded JIT using LLVM's ORC Engine) 3.980 ± 0.029 3.940 4.015 16.41 ± 0.12
cairo-native (standalone AOT with -march=native) 0.243 ± 0.000 0.242 0.243 1.00

@codecov-commenter
Copy link

codecov-commenter commented Jan 16, 2025

Codecov Report

Attention: Patch coverage is 39.13043% with 42 lines in your changes missing coverage. Please review.

Project coverage is 80.85%. Comparing base (a6ddeee) to head (a0c3d41).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/utils/safe_runner.rs 33.33% 42 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1053      +/-   ##
==========================================
- Coverage   80.95%   80.85%   -0.10%     
==========================================
  Files         108      109       +1     
  Lines       29938    30003      +65     
==========================================
+ Hits        24237    24260      +23     
- Misses       5701     5743      +42     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@edg-l edg-l added the review-ready A PR that is ready for review label Jan 20, 2025
Copy link
Member

@edg-l edg-l left a comment

Choose a reason for hiding this comment

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

Is it possible to add a test that segfaults? Or too tricky?

@azteca1998
Copy link
Collaborator Author

azteca1998 commented Jan 20, 2025

It is technically possible, but it'd require a way to initialize the signal handler globally when testing, potentially messing up the test harness's signal handler (ex. when using nextest).

Instead, if we just initialized every (segfaulting) test then we'd end up initializing it multiple times, which could also cause problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review-ready A PR that is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants