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

Panic on autocxx build. #903

Closed
lukesneeringer opened this issue Mar 9, 2022 · 15 comments · Fixed by #905
Closed

Panic on autocxx build. #903

lukesneeringer opened this issue Mar 9, 2022 · 15 comments · Fixed by #905

Comments

@lukesneeringer
Copy link
Contributor

Thanks for your help on my previous issue @adetaylor.

I have another one that I am pretty sure is an autocxx bug. When I build now, I get a long list of ignored methods (which is fully expected), followed by a autocxx_engine panic.

Expected Behavior

Not a panic. :)

Actual Behavior

  thread 'main' panicked at 'index out of bounds: the len is 1 but the index is 1', /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/autocxx-engine-0.17.0/src/conversion/analysis/fun/mod.rs:822:21
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
     1: core::panicking::panic_fmt
               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
     2: core::panicking::panic_bounds_check
               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:84:5
     3: <usize as core::slice::index::SliceIndex<[T]>>::index
               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/slice/index.rs:189:10
     4: core::slice::index::<impl core::ops::index::Index<I> for [T]>::index
               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/slice/index.rs:15:9
     5: <alloc::vec::Vec<T,A> as core::ops::index::Index<I>>::index
               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/alloc/src/vec/mod.rs:2520:9
     6: autocxx_engine::conversion::analysis::fun::FnAnalyzer::analyze_foreign_fn
               at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/autocxx-engine-0.17.0/src/conversion/analysis/fun/mod.rs:822:21
     7: autocxx_engine::conversion::analysis::fun::FnAnalyzer::analyze_foreign_fn_and_subclasses
               at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/autocxx-engine-0.17.0/src/conversion/analysis/fun/mod.rs:545:13
     8: autocxx_engine::conversion::analysis::fun::FnAnalyzer::analyze_functions::{{closure}}
               at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/autocxx-engine-0.17.0/src/conversion/analysis/fun/mod.rs:305:31
     9: autocxx_engine::conversion::error_reporter::convert_apis::{{closure}}
               at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/autocxx-engine-0.17.0/src/conversion/error_reporter.rs:151:18
    10: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/ops/function.rs:280:13
    11: core::option::Option<T>::map
               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/option.rs:883:29
    12: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next
               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/iter/adapters/map.rs:103:9
    13: <core::iter::adapters::fuse::Fuse<I> as core::iter::adapters::fuse::FuseImpl<I>>::next
               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/iter/adapters/fuse.rs:365:9
    14: <core::iter::adapters::fuse::Fuse<I> as core::iter::traits::iterator::Iterator>::next
               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/iter/adapters/fuse.rs:70:9
    15: <core::iter::adapters::flatten::FlattenCompat<I,U> as core::iter::traits::iterator::Iterator>::next
               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/iter/adapters/flatten.rs:299:19
    16: <core::iter::adapters::flatten::FlatMap<I,U,F> as core::iter::traits::iterator::Iterator>::next
               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/iter/adapters/flatten.rs:51:9
    17: autocxx_engine::conversion::apivec::ApiVec<P>::extend
               at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/autocxx-engine-0.17.0/src/conversion/apivec.rs:102:20
    18: autocxx_engine::conversion::error_reporter::convert_apis
               at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/autocxx-engine-0.17.0/src/conversion/error_reporter.rs:81:5
    19: autocxx_engine::conversion::analysis::fun::FnAnalyzer::analyze_functions
               at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/autocxx-engine-0.17.0/src/conversion/analysis/fun/mod.rs:302:9
    20: autocxx_engine::conversion::BridgeConverter::convert
               at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/autocxx-engine-0.17.0/src/conversion/mod.rs:157:21
    21: autocxx_engine::IncludeCppEngine::generate
               at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/autocxx-engine-0.17.0/src/lib.rs:394:26
    22: autocxx_engine::parse_file::ParsedFile::resolve_all
               at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/autocxx-engine-0.17.0/src/parse_file.rs:363:13
    23: autocxx_engine::builder::Builder<CTX>::build_listing_files
               at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/autocxx-engine-0.17.0/src/builder.rs:224:9
    24: autocxx_engine::builder::Builder<CTX>::build
               at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/autocxx-engine-0.17.0/src/builder.rs:186:9
    25: autocxx_engine::builder::Builder<CTX>::expect_build
               at /home/luke/.cargo/registry/src/github.com-1ecc6299db9ec823/autocxx-engine-0.17.0/src/builder.rs:273:9
    26: build_script_build::main
               at ./build.rs:7:3
    27: core::ops::function::FnOnce::call_once
               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/ops/function.rs:227:5

Steps to Reproduce the Problem

Sadly I doubt I have anything useful here. I am prohibited from sharing the C++ code. :( If it would make a difference, I could screenshare or something temporarily.

Specifications

  • Version: 0.17.0
  • Platform: CentOS 7, clang 15.0, gcc 8.3, g++ 8.3
@adetaylor
Copy link
Collaborator

Thanks. I'll take a look but it seems unlikely I'll be able to figure this out without the code.

If I fail, then perhaps I'll see if we can get the test case minimization pipeline working for you - but it's fiddly so I'll have a look first.

@lukesneeringer
Copy link
Contributor Author

Yep, understandable. I didn't notice the mechanism to get extra output so I will try that. Worst case scenario hopefully I get you better information, because this is a lousy bug report as-is.

@lukesneeringer
Copy link
Contributor Author

Oh, I looked more carefully, and autocxx was in the process of trying to build Eigen, which is open source. That means it might be possible to make a portable reproduction case; I could separate Eigen out and try to build a trivial thing against it.

@adetaylor
Copy link
Collaborator

Here's what the call stack tells us.

  • autocxx is spotting some function which has a bindgen annotation saying it's a move or copy constructor
  • Move or copy constructors have two parameters - one for the destination pointer ('this') and one for the thing being moved- or copied-from.
  • But in this case, we've got only one.

Weird. It should be fairly straightforward to detect and ignore such APIs, so I'll work on a PR to do that.

@lukesneeringer
Copy link
Contributor Author

Wow, you're awesome. Thanks.

adetaylor added a commit that referenced this issue Mar 9, 2022
We expect bindgen to have two parameters for all copy and move
constructors, but it's been known to provide a single parameter in
circumstances which are not yet entirely clear. Ignore such functions.

Fixes #903.
adetaylor added a commit that referenced this issue Mar 9, 2022
We expect bindgen to have two parameters for all copy and move
constructors, but it's been known to provide a single parameter in
circumstances which are not yet entirely clear. Ignore such functions.

Fixes #903.
@adetaylor
Copy link
Collaborator

OK, there's a possible fix in #905. It would still be terrific to have a minimized test case here in case you're able to figure out what caused this...

@adetaylor
Copy link
Collaborator

OK, I landed the fix - please could you let me know if it works and reopen this if not? It wouldn't shock me if further work is needed... there might be other places where we make assumptions that move/copy constructors have a vaguely sensible number of parameters.

@lukesneeringer
Copy link
Contributor Author

Sure. If it does not work, I will do what I can to get a portable test case.

@lukesneeringer
Copy link
Contributor Author

Sadly, while this moved the baton farther, it did not fix the error, because there seems to be a naming collision:

Here's the error:

  thread 'main' panicked at 'Already have an API with that name: __cxxabiv1::__class_type_info. API was __cxxabiv1::__class_type_info (cpp=__class_type_info) (kind=Function)', /home/luke/.cargo/git/checkouts/autocxx-d68523a30590bac8/755ea1c/engine/src/conversion/apivec.rs:58:17

And here's the backtrace:

It happens right at the same spot in the series of files being compiled so I am reasonably confident it is the same issue.

  stack backtrace:
     0: rust_begin_unwind
               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
     1: core::panicking::panic_fmt
               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
     2: autocxx_engine::conversion::apivec::ApiVec<P>::push
               at /home/luke/.cargo/git/checkouts/autocxx-d68523a30590bac8/755ea1c/engine/src/conversion/apivec.rs:58:17
     3: autocxx_engine::conversion::apivec::ApiVec<P>::extend
               at /home/luke/.cargo/git/checkouts/autocxx-d68523a30590bac8/755ea1c/engine/src/conversion/apivec.rs:103:13
     4: autocxx_engine::conversion::error_reporter::convert_apis
               at /home/luke/.cargo/git/checkouts/autocxx-d68523a30590bac8/755ea1c/engine/src/conversion/error_reporter.rs:81:5
     5: autocxx_engine::conversion::analysis::fun::FnAnalyzer::analyze_functions
               at /home/luke/.cargo/git/checkouts/autocxx-d68523a30590bac8/755ea1c/engine/src/conversion/analysis/fun/mod.rs:302:9
     6: autocxx_engine::conversion::BridgeConverter::convert
               at /home/luke/.cargo/git/checkouts/autocxx-d68523a30590bac8/755ea1c/engine/src/conversion/mod.rs:157:21
     7: autocxx_engine::IncludeCppEngine::generate
               at /home/luke/.cargo/git/checkouts/autocxx-d68523a30590bac8/755ea1c/engine/src/lib.rs:394:26
     8: autocxx_engine::parse_file::ParsedFile::resolve_all
               at /home/luke/.cargo/git/checkouts/autocxx-d68523a30590bac8/755ea1c/engine/src/parse_file.rs:363:13
     9: autocxx_engine::builder::Builder<CTX>::build_listing_files
               at /home/luke/.cargo/git/checkouts/autocxx-d68523a30590bac8/755ea1c/engine/src/builder.rs:224:9
    10: autocxx_engine::builder::Builder<CTX>::build
               at /home/luke/.cargo/git/checkouts/autocxx-d68523a30590bac8/755ea1c/engine/src/builder.rs:186:9
    11: autocxx_engine::builder::Builder<CTX>::expect_build
               at /home/luke/.cargo/git/checkouts/autocxx-d68523a30590bac8/755ea1c/engine/src/builder.rs:273:9
    12: build_script_build::main
               at ./build.rs:7:3
    13: core::ops::function::FnOnce::call_once
               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/ops/function.rs:227:5

@lukesneeringer
Copy link
Contributor Author

reopen this if not

I can not reopen issues. :-)

@adetaylor adetaylor reopened this Mar 10, 2022
@adetaylor
Copy link
Collaborator

Right.
Hm.
This is a different issue. This may be an instance of #486, a long-standing issue where we don't quite yet do the right thing with names. I'm not sure yet - I will see if I can think of a creative way to come up with a bug like this and see if it comes up with this sort of call stack.

@adetaylor
Copy link
Collaborator

Actually @lukesneeringer I think it would be tremendously helpful if you can provide me a test case. No need to minimize it. For example you could make a PR with an Eigen-related example in the examples directory, or just upload something somewhere.

@adetaylor
Copy link
Collaborator

This second problem was (I hope) fixed under #911. Please raise a new issue if you encounter further problems, thanks!

@lukesneeringer
Copy link
Contributor Author

Actually @lukesneeringer I think it would be tremendously helpful if you can provide me a test case. No need to minimize it. For example you could make a PR with an Eigen-related example in the examples directory, or just upload something somewhere.

Hey @adetaylor, sorry, I dropped the ball on this. I'll work on getting you a test case (unless the problem is fixed, of course).

Sorry for disappearing on you.

@adetaylor
Copy link
Collaborator

No probs! Let me know what other issues you encounter, and yes, if you happen to be able to come up with a minimized test case that'd be great - even if it's already fixed, it will ensure this doesn't regress in future.

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 a pull request may close this issue.

2 participants