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

rust: add example code and mention in the readme #724

Merged
merged 3 commits into from
Feb 5, 2021
Merged

Conversation

axic
Copy link
Member

@axic axic commented Feb 4, 2021

This is what the documentation looks like:
Screenshot

@codecov
Copy link

codecov bot commented Feb 4, 2021

Codecov Report

Merging #724 (27a33f4) into master (459dfb9) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #724   +/-   ##
=======================================
  Coverage   99.34%   99.34%           
=======================================
  Files          73       73           
  Lines       11125    11125           
=======================================
  Hits        11052    11052           
  Misses         73       73           
Flag Coverage Δ
rust 99.78% <ø> (ø)
spectests 90.84% <ø> (ø)
unittests 99.32% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
bindings/rust/src/lib.rs 99.78% <ø> (ø)

@axic
Copy link
Member Author

axic commented Feb 4, 2021

Not sure why there is a double free, fizzy_free_instance seems to be called once, and fizzy_free_module is not called.

* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00007fff6e8ff33a libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff6e9bbe60 libsystem_pthread.dylib`pthread_kill + 430
    frame #2: 0x00007fff6e886808 libsystem_c.dylib`abort + 120
    frame #3: 0x00007fff6e97c50b libsystem_malloc.dylib`malloc_vreport + 548
    frame #4: 0x00007fff6e97f40f libsystem_malloc.dylib`malloc_report + 151
    frame #5: 0x000000010000a7c5 fizzy-integration-test`std::__1::_DeallocateCaller::__do_call(__ptr=0x0000000100405870) at new:320:12
    frame #6: 0x000000010000a779 fizzy-integration-test`std::__1::_DeallocateCaller::__do_deallocate_handle_size(__ptr=0x0000000100405870, __size=2) at new:278:12
    frame #7: 0x000000010000a705 fizzy-integration-test`std::__1::_DeallocateCaller::__do_deallocate_handle_size_align(__ptr=0x0000000100405870, __size=2, __align=1) at new:254:14
    frame #8: 0x000000010000a6a5 fizzy-integration-test`std::__1::__libcpp_deallocate(__ptr=0x0000000100405870, __size=2, __align=1) at new:326:3
    frame #9: 0x000000010000b986 fizzy-integration-test`std::__1::allocator<fizzy::ValType>::deallocate(this=0x00000001004053c0, __p=0x0000000100405870, __n=2) at memory:1817:10
    frame #10: 0x000000010000b845 fizzy-integration-test`std::__1::allocator_traits<std::__1::allocator<fizzy::ValType> >::deallocate(__a=0x00000001004053c0, __p=0x0000000100405870, __n=2) at memory:1555:14
    frame #11: 0x000000010000b6e4 fizzy-integration-test`std::__1::__vector_base<fizzy::ValType, std::__1::allocator<fizzy::ValType> >::~__vector_base(this=0x00000001004053b0) at vector:465:9
    frame #12: 0x000000010000b5ba fizzy-integration-test`std::__1::vector<fizzy::ValType, std::__1::allocator<fizzy::ValType> >::~vector(this=0x00000001004053b0 size=0) at vector:556:5
    frame #13: 0x000000010000b585 fizzy-integration-test`std::__1::vector<fizzy::ValType, std::__1::allocator<fizzy::ValType> >::~vector(this=0x00000001004053b0 size=0) at vector:551:5
    frame #14: 0x000000010000b55c fizzy-integration-test`fizzy::FuncType::~FuncType(this=0x00000001004053b0) at types.hpp:30:8
    frame #15: 0x000000010000b525 fizzy-integration-test`fizzy::FuncType::~FuncType(this=0x00000001004053b0) at types.hpp:30:8
    frame #16: 0x000000010000b509 fizzy-integration-test`std::__1::allocator<fizzy::FuncType>::destroy(this=0x00000001004056e0, __p=0x00000001004053b0) at memory:1881:64
    frame #17: 0x000000010000b4dd fizzy-integration-test`void std::__1::allocator_traits<std::__1::allocator<fizzy::FuncType> >::__destroy<fizzy::FuncType>((null)=std::__1::true_type @ 0x00007ffeefbfeff8, __a=0x00000001004056e0, __p=0x00000001004053b0) at memory:1743:18
    frame #18: 0x000000010000b4ad fizzy-integration-test`void std::__1::allocator_traits<std::__1::allocator<fizzy::FuncType> >::destroy<fizzy::FuncType>(__a=0x00000001004056e0, __p=0x00000001004053b0) at memory:1596:14
    frame #19: 0x000000010000b468 fizzy-integration-test`std::__1::__vector_base<fizzy::FuncType, std::__1::allocator<fizzy::FuncType> >::__destruct_at_end(this=0x00000001004056d0, __new_last=0x00000001004053b0) at vector:427:9
    frame #20: 0x000000010000b3b8 fizzy-integration-test`std::__1::__vector_base<fizzy::FuncType, std::__1::allocator<fizzy::FuncType> >::clear(this=0x00000001004056d0) at vector:370:29
    frame #21: 0x000000010000b267 fizzy-integration-test`std::__1::__vector_base<fizzy::FuncType, std::__1::allocator<fizzy::FuncType> >::~__vector_base(this=0x00000001004056d0) at vector:464:9
    frame #22: 0x000000010000b15a fizzy-integration-test`std::__1::vector<fizzy::FuncType, std::__1::allocator<fizzy::FuncType> >::~vector(this=0x00000001004056d0 size=1) at vector:556:5
    frame #23: 0x000000010000a155 fizzy-integration-test`std::__1::vector<fizzy::FuncType, std::__1::allocator<fizzy::FuncType> >::~vector(this=0x00000001004056d0 size=1) at vector:551:5
    frame #24: 0x000000010000a0cc fizzy-integration-test`fizzy::Module::~Module(this=0x00000001004056d0) at module.hpp:14:8
    frame #25: 0x0000000100008dc5 fizzy-integration-test`fizzy::Module::~Module(this=0x00000001004056d0) at module.hpp:14:8
    frame #26: 0x0000000100016f1b fizzy-integration-test`std::__1::default_delete<fizzy::Module const>::operator(this=0x0000000100504080, __ptr=0x00000001004056d0)(fizzy::Module const*) const at memory:2339:5
    frame #27: 0x0000000100016ebf fizzy-integration-test`std::__1::unique_ptr<fizzy::Module const, std::__1::default_delete<fizzy::Module const> >::reset(this=0x0000000100504080, __p=0x0000000000000000) at memory:2652:7
    frame #28: 0x0000000100016e59 fizzy-integration-test`std::__1::unique_ptr<fizzy::Module const, std::__1::default_delete<fizzy::Module const> >::~unique_ptr(this=0x0000000100504080) at memory:2606:19
    frame #29: 0x0000000100008c25 fizzy-integration-test`std::__1::unique_ptr<fizzy::Module const, std::__1::default_delete<fizzy::Module const> >::~unique_ptr(this=0x0000000100504080) at memory:2606:17
    frame #30: 0x00000001000161dc fizzy-integration-test`fizzy::Instance::~Instance(this=0x0000000100504080) at instantiate.hpp:82:8
    frame #31: 0x0000000100009de5 fizzy-integration-test`fizzy::Instance::~Instance(this=0x0000000100504080) at instantiate.hpp:82:8
    frame #32: 0x0000000100009dbc fizzy-integration-test`::fizzy_free_instance(instance=0x0000000100504080) at capi.cpp:558:5
    frame #33: 0x00000001000057a1 fizzy-integration-test`_$LT$fizzy..Instance$u20$as$u20$core..ops..drop..Drop$GT$::drop::h886bfb910d6ff66a(self=0x00007ffeefbff310) at lib.rs:60:18
    frame #34: 0x00000001000011f1 fizzy-integration-test`core::ptr::drop_in_place::hd1c931065015e10f((null)=0x00007ffeefbff310) at mod.rs:175:1
    frame #35: 0x0000000100001600 fizzy-integration-test`fizzy_integration_test::main::h7ea1d6484d7de259 at main.rs:33:1
    frame #36: 0x000000010000118e fizzy-integration-test`core::ops::function::FnOnce::call_once::ha0d3047fb68cd523((null)=(fizzy-integration-test`fizzy_integration_test::main::h7ea1d6484d7de259 at main.rs:7), (null)=<unavailable>) at function.rs:227:5
    frame #37: 0x00000001000016b1 fizzy-integration-test`std::sys_common::backtrace::__rust_begin_short_backtrace::hdf5bb73bc506fc48(f=(fizzy-integration-test`fizzy_integration_test::main::h7ea1d6484d7de259 at main.rs:7)) at backtrace.rs:125:18
    frame #38: 0x0000000100001744 fizzy-integration-test`std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h1ee7801da914b482 at rt.rs:66:18
    frame #39: 0x000000010008a084 fizzy-integration-test`std::rt::lang_start_internal::h36ccce6e8a047133 [inlined] core::ops::function::impls::_$LT$impl$u20$core..ops..function..FnOnce$LT$A$GT$$u20$for$u20$$RF$F$GT$::call_once::h81f763a559f81b5c at function.rs:259:13 [opt]
    frame #40: 0x000000010008a07d fizzy-integration-test`std::rt::lang_start_internal::h36ccce6e8a047133 [inlined] std::panicking::try::do_call::h8f7e7501b4b6c841 at panicking.rs:381 [opt]
    frame #41: 0x000000010008a07d fizzy-integration-test`std::rt::lang_start_internal::h36ccce6e8a047133 [inlined] std::panicking::try::h5def58989e0f2c84 at panicking.rs:345 [opt]
    frame #42: 0x000000010008a07d fizzy-integration-test`std::rt::lang_start_internal::h36ccce6e8a047133 [inlined] std::panic::catch_unwind::h8210e1d7d92e8f91 at panic.rs:396 [opt]
    frame #43: 0x000000010008a07d fizzy-integration-test`std::rt::lang_start_internal::h36ccce6e8a047133 at rt.rs:51 [opt]
    frame #44: 0x0000000100001721 fizzy-integration-test`std::rt::lang_start::h0f0b19eee08fa02f(main=(fizzy-integration-test`fizzy_integration_test::main::h7ea1d6484d7de259 at main.rs:7), argc=1, argv=0x00007ffeefbff4e0) at rt.rs:65:5
    frame #45: 0x0000000100001652 fizzy-integration-test`main + 34
    frame #46: 0x00007fff6e7b7cc9 libdyld.dylib`start + 1

@axic
Copy link
Member Author

axic commented Feb 4, 2021

Previous issue fixed by #725.

@axic axic marked this pull request as ready for review February 4, 2021 16:25
@axic axic requested review from gumb0 and chfast February 4, 2021 16:25
@@ -14,7 +14,7 @@ Fizzy aims to be a fast, deterministic, and pedantic WebAssembly interpreter wri

I) Code quality
- [x] Clean and modern C++17 codebase without external dependencies
- [ ] Easily embeddable (*and take part of the standardisation of the "C/C++ embedding API"*)
- [x] Easily embeddable (*and take part of the standardisation of the "C/C++ embedding API"*)
Copy link
Member Author

Choose a reason for hiding this comment

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

I think the public C API we have accomplishes this goal already.

@gumb0
Copy link
Collaborator

gumb0 commented Feb 4, 2021

Looks fine, but CI failed.

@axic
Copy link
Member Author

axic commented Feb 4, 2021

Looks fine, but CI failed.

Because cargo doc executes the example and it seems somehow we need to pass it flags for ASan.

@axic axic force-pushed the rust-readme branch 3 times, most recently from 4726db3 to 3af0cfc Compare February 4, 2021 19:23
@axic axic merged commit cb81237 into master Feb 5, 2021
@axic axic deleted the rust-readme branch February 5, 2021 12:58
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.

3 participants