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

ICE with axum #1823

Closed
1 task done
VelvetToroyashi opened this issue Mar 7, 2023 · 12 comments
Closed
1 task done

ICE with axum #1823

VelvetToroyashi opened this issue Mar 7, 2023 · 12 comments

Comments

@VelvetToroyashi
Copy link

VelvetToroyashi commented Mar 7, 2023

  • I have looked for existing issues (including closed) about this

Bug Report

Version

cargo tree | grep axum
--> axum v0.6.10

Platform

Windows 10 Home, Build 19045

Description

I've encountered an ICE (fun!) when attempting to use Axum, as the title says.

I tried this code:
https://github.com/VelvetThePanda/Kobalt/blob/ec48f8a07c063ecf1d68f28a3eade815ac1a393a/iridium/src/api.rs#L50

https://github.com/VelvetThePanda/Kobalt/blob/ec48f8a07c063ecf1d68f28a3eade815ac1a393a/iridium/src/api.rs#L84-L97

I expected to see this happen: My code would compile fine, and all would be well.

Instead, this happened: The code fails, causing an ICE, which appears to be from Axum throwing an error from what I've gathered of the stack trace. Furthermore, I have managed to narrow this down to the top_level_handler_fn! macro which appears to be causing this, but that's as far as I've managed to track this down on my own.

I'd also like to note that I was originally going to file an issue about this on the rust lang repo, but I was advised to file an issue here due to the fact that it appears to be a crate causing this.

The compile seems very fickle with this issue as well; something about having a hasher and making a reqwest call breaks it, but only if created as an Axum handler.

error: internal compiler error: compiler\rustc_middle\src\ty\instance.rs:397:18: failed to resolve instance for <fn(axum::extract::State<Config>, DiscordUser, axum::Json<SubmitImageResponse>) -> impl Future<Output = StatusCode> 
{create_image} as Handler<(axum_core::extract::private::ViaRequest, axum::extract::State<Config>, DiscordUser, axum::Json<SubmitImageResponse>), Config>>::with_state

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/7820b62d20bc548096d4632a3487987308cb4b5d\compiler\rustc_errors\src\lib.rs:1644:9
Extended Stacktrace

thread 'rustc' panicked at 'Box', /rustc/7820b62d20bc548096d4632a3487987308cb4b5d\compiler\rustc_errors\src\lib.rs:1644:9
stack backtrace:
0: 0x7ffba5666c82 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h71aa14ca5a78cea9
1: 0x7ffba56a548b - core::fmt::write::hd6dddebeb8f05e68
2: 0x7ffba565c35a - <std::io::IoSliceMut as core::fmt::Debug>::fmt::hbe5c6512075d6072
3: 0x7ffba56669cb - std::sys::common::alloc::realloc_fallback::h79f7a2bf9b29d2a9
4: 0x7ffba566a329 - std::panicking::default_hook::h4c92683644ea5b5f
5: 0x7ffba5669fab - std::panicking::default_hook::h4c92683644ea5b5f
6: 0x7ffb71b258cc - rustc_driver_impl[af203be264558e54]::describe_lints
7: 0x7ffba566ac92 - std::panicking::rust_panic_with_hook::h33ef57ac78d86764
8: 0x7ffb7206c1e3 - <rustc_middle[ac858212b739b5f5]::mir::GeneratorInfo as core[f7d117be605e2fd8]::fmt::Debug>::fmt
9: 0x7ffb7206a969 - <rustc_middle[ac858212b739b5f5]::mir::GeneratorInfo as core[f7d117be605e2fd8]::fmt::Debug>::fmt
10: 0x7ffb720f41d9 - <rustc_middle[ac858212b739b5f5]::ty::print::pretty::TraitRefPrintOnlyTraitPath as rustc_middle[ac858212b739b5f5]::ty::context::Lift>::lift_to_tcx
11: 0x7ffb720d0749 - <rustc_middle[ac858212b739b5f5]::ty::instance::InstanceDef as rustc_middle[ac858212b739b5f5]::ty::context::Lift>::lift_to_tcx
12: 0x7ffb720ccb20 - <rustc_middle[ac858212b739b5f5]::ty::instance::InstanceDef as rustc_middle[ac858212b739b5f5]::ty::context::Lift>::lift_to_tcx
13: 0x7ffb720cc6a2 - <rustc_middle[ac858212b739b5f5]::ty::instance::InstanceDef as rustc_middle[ac858212b739b5f5]::ty::context::Lift>::lift_to_tcx
14: 0x7ffb720c336a - rustc_middle[ac858212b739b5f5]::util::bug::bug_fmt
15: 0x7ffb720c1b1d - <rustc_middle[ac858212b739b5f5]::ty::consts::kind::UnevaluatedConst as rustc_errors[5eceb53523fa45d6]::diagnostic::IntoDiagnosticArg>::into_diagnostic_arg
16: 0x7ffb720c1ae1 - <rustc_middle[ac858212b739b5f5]::ty::consts::kind::UnevaluatedConst as rustc_errors[5eceb53523fa45d6]::diagnostic::IntoDiagnosticArg>::into_diagnostic_arg
17: 0x7ffb720c32a8 - rustc_middle[ac858212b739b5f5]::util::bug::bug_fmt
18: 0x7ffb720c3225 - rustc_middle[ac858212b739b5f5]::util::bug::bug_fmt
19: 0x7ffb705f084d - <rustc_monomorphize[9ab505a90e433a29]::collector::MirNeighborCollector as rustc_middle[ac858212b739b5f5]::mir::visit::Visitor>::visit_operand
20: 0x7ffb705e5876 - <rustc_monomorphize[9ab505a90e433a29]::collector::MirNeighborCollector as rustc_middle[ac858212b739b5f5]::mir::visit::Visitor>::visit_operand
21: 0x7ffb705e5ca3 - <rustc_monomorphize[9ab505a90e433a29]::collector::MirNeighborCollector as rustc_middle[ac858212b739b5f5]::mir::visit::Visitor>::visit_operand
22: 0x7ffb705e5ca3 - <rustc_monomorphize[9ab505a90e433a29]::collector::MirNeighborCollector as rustc_middle[ac858212b739b5f5]::mir::visit::Visitor>::visit_operand
23: 0x7ffb705e5ca3 - <rustc_monomorphize[9ab505a90e433a29]::collector::MirNeighborCollector as rustc_middle[ac858212b739b5f5]::mir::visit::Visitor>::visit_operand
24: 0x7ffb705e5ca3 - <rustc_monomorphize[9ab505a90e433a29]::collector::MirNeighborCollector as rustc_middle[ac858212b739b5f5]::mir::visit::Visitor>::visit_operand
25: 0x7ffb705e5ca3 - <rustc_monomorphize[9ab505a90e433a29]::collector::MirNeighborCollector as rustc_middle[ac858212b739b5f5]::mir::visit::Visitor>::visit_operand
26: 0x7ffb705e5ca3 - <rustc_monomorphize[9ab505a90e433a29]::collector::MirNeighborCollector as rustc_middle[ac858212b739b5f5]::mir::visit::Visitor>::visit_operand
27: 0x7ffb705e5ca3 - <rustc_monomorphize[9ab505a90e433a29]::collector::MirNeighborCollector as rustc_middle[ac858212b739b5f5]::mir::visit::Visitor>::visit_operand
28: 0x7ffb705e5ca3 - <rustc_monomorphize[9ab505a90e433a29]::collector::MirNeighborCollector as rustc_middle[ac858212b739b5f5]::mir::visit::Visitor>::visit_operand
29: 0x7ffb705e5ca3 - <rustc_monomorphize[9ab505a90e433a29]::collector::MirNeighborCollector as rustc_middle[ac858212b739b5f5]::mir::visit::Visitor>::visit_operand
30: 0x7ffb705e5ca3 - <rustc_monomorphize[9ab505a90e433a29]::collector::MirNeighborCollector as rustc_middle[ac858212b739b5f5]::mir::visit::Visitor>::visit_operand
31: 0x7ffb705e5ca3 - <rustc_monomorphize[9ab505a90e433a29]::collector::MirNeighborCollector as rustc_middle[ac858212b739b5f5]::mir::visit::Visitor>::visit_operand
32: 0x7ffb705e5ca3 - <rustc_monomorphize[9ab505a90e433a29]::collector::MirNeighborCollector as rustc_middle[ac858212b739b5f5]::mir::visit::Visitor>::visit_operand
33: 0x7ffb705e5ca3 - <rustc_monomorphize[9ab505a90e433a29]::collector::MirNeighborCollector as rustc_middle[ac858212b739b5f5]::mir::visit::Visitor>::visit_operand
34: 0x7ffb705e5ca3 - <rustc_monomorphize[9ab505a90e433a29]::collector::MirNeighborCollector as rustc_middle[ac858212b739b5f5]::mir::visit::Visitor>::visit_operand
35: 0x7ffb705e5ca3 - <rustc_monomorphize[9ab505a90e433a29]::collector::MirNeighborCollector as rustc_middle[ac858212b739b5f5]::mir::visit::Visitor>::visit_operand
36: 0x7ffb6f0ebe84 - <rustc_monomorphize[9ab505a90e433a29]::partitioning::default::DefaultPartitioning as rustc_monomorphize[9ab505a90e433a29]::partitioning::Partitioner>::place_inlined_mono_items
37: 0x7ffb6f0ed55e - <rustc_monomorphize[9ab505a90e433a29]::partitioning::default::DefaultPartitioning as rustc_monomorphize[9ab505a90e433a29]::partitioning::Partitioner>::place_inlined_mono_items
38: 0x7ffb6f0e7791 - <rustc_mir_transform[bc774b75d18db22b]::elaborate_drops::Elaborator as rustc_mir_dataflow[8b599228352e354b]::elaborate_drops::DropElaborator>::get_drop_flag
39: 0x7ffb6f0ef95c - rustc_monomorphize[9ab505a90e433a29]::provide
40: 0x7ffb6f24fc1f - rustc_privacy[797d4763e5e864d1]::provide
41: 0x7ffb6f2bd9d5 - <rustc_query_impl[f1faa5ca787a8303]::Queries as rustc_middle[ac858212b739b5f5]::ty::query::QueryEngine>::try_mark_green
42: 0x7ffb6ecb12e2 - <rustc_codegen_llvm[801c810974492b7f]::ModuleLlvm as core[f7d117be605e2fd8]::ops::drop::Drop>::drop
43: 0x7ffb6ecadb6b - <rustc_codegen_llvm[801c810974492b7f]::LlvmCodegenBackend as rustc_codegen_ssa[c53e3e9fe0f57c8d]::traits::backend::CodegenBackend>::codegen_crate
44: 0x7ffb6ef562fb - rustc_interface[bff7d1d3f9751698]::passes::start_codegen
45: 0x7ffb6ef4fb52 - rustc_interface[bff7d1d3f9751698]::passes::start_codegen
46: 0x7ffb6ef52c4a - rustc_interface[bff7d1d3f9751698]::passes::start_codegen
47: 0x7ffb6ef7db67 - <rustc_interface[bff7d1d3f9751698]::queries::Queries>::ongoing_codegen
48: 0x7ffb6ed93859 - rustc_driver_impl[af203be264558e54]::main
49: 0x7ffb6edada1c - rustc_driver_impl[af203be264558e54]::args::arg_expand_all
50: 0x7ffb6ed8213a - rustc_driver_impl[af203be264558e54]::main
51: 0x7ffb6ed807bd - rustc_driver_impl[af203be264558e54]::main
52: 0x7ffba567cadc - std::sys::windows::thread::Thread::new::h62b556989e817ecc
53: 0x7ffbf7197614 - BaseThreadInitThunk
54: 0x7ffbf75e26a1 - RtlUserThreadStart

@jplatte
Copy link
Member

jplatte commented Mar 7, 2023

I'd also like to note that I was originally going to file an issue about this on the rust lang repo

That would have been exactly right 😅
ICEs are always compiler bugs, not library bugs. (but feel free to link the rust issue here, I'd be curious to watch it)

@jplatte jplatte closed this as not planned Won't fix, can't repro, duplicate, stale Mar 7, 2023
@VelvetToroyashi
Copy link
Author

Apologies then; I'll file this on the rust repo

@davidpdrsn
Copy link
Member

I was advised to file an issue here due to the fact that it appears to be a crate causing this.

Your friend is wrong. A compiler bug is a bug in the compiler, not a library. Libraries can't "throw compiler errors" or "use the compiler wrong". So filing a rustc issue is the way to go.

Just out of interest. Are you on nightly, if so which one? I haven't heard about this on stable.

@VelvetToroyashi
Copy link
Author

Well yes, I do agree that it's a compiler issue; my friend's wording was more along the lines of filing here so an MVP could be created, and an issue filed with that. Sorry about any miscommunication.

As for rustc, 1.7.0 nightly (7820b62d2)

@davidpdrsn
Copy link
Member

my friend's wording was more along the lines of filing here so an MVP could be created, and an issue filed with that

That makes sense! I might take a look and see if I can narrow it down.

@jplatte
Copy link
Member

jplatte commented Mar 7, 2023

If you are really on 1.7.0, then you need to upgrade. That version is from around the end of 2015 / start of 2016! 😄

@VelvetToroyashi
Copy link
Author

VelvetToroyashi commented Mar 7, 2023

Did I not specify nightly? Oops. Compiler Commit was from 2 days ago

More specifically: 1.70.0-nightly (7820b62d2 2023-03-05) (seems I mistyped before, Bwah.)

@jplatte
Copy link
Member

jplatte commented Mar 7, 2023

You did specify nightly, but nightly versions are ahead of regular compiler versions. I'm guessing you mean 1.70.0, which is indeed very recent.

@VelvetToroyashi
Copy link
Author

I think I've found at least part of the issue. In my code I linked, on stable it complains about the handler not being Send because I'm declaring a variable that's used after an await, which explains why it broke when I added the reqwest call!

@VelvetToroyashi
Copy link
Author

Just tested, and this is in fact the case. However, I still believe axum has something to do with this, as if I remove it as a handler, the same code works.

@davidpdrsn
Copy link
Member

However, I still believe axum has something to do with this, as if I remove it as a handler, the same code works.

"axum having something to do with it" and "its a bug in axum" are two very different things. ICEs are bugs in the compiler, not libraries.

@VelvetToroyashi
Copy link
Author

Yes, yes, I believe the resulting code of becoming a handler is what's causing the ICE, rather than axum itself.

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

No branches or pull requests

3 participants