Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.
This repository was archived by the owner on Jan 29, 2023. It is now read-only.

Panic when loading hocon document, for entering unreachable code #26

@alexhexabeam

Description

@alexhexabeam

src/main.rs

use hocon::HoconLoader;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let doc = HoconLoader::new()
        .load_file(
            "/path/to/my/hocon.conf",
        )?
        .hocon()?;
    println!("{:?}", doc["DefaultParsers"]);
    Ok(())
}

Panics when it loads the document (run in release mode, as debug mode doesn't seem to ever finish loading):

thread 'main' panicked at 'internal error: entered unreachable code', /Users/alexhunt/.cargo/registry/src/github.com-1ecc6299db9ec823/hocon-0.3.5/src/internals/value.rs:332:18
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::panicking::default_hook::{{closure}}
   4: std::panicking::default_hook
   5: std::panicking::rust_panic_with_hook
   6: std::panicking::begin_panic
   7: core::hash::impls::<impl core::hash::Hash for [T]>::hash
   8: hashbrown::map::make_hash
   9: hashbrown::rustc_entry::<impl hashbrown::map::HashMap<K,V,S>>::rustc_entry
  10: hocon::internals::internal::HoconInternal::merge
  11: hocon::HoconLoader::hocon
  12: ironlime::main
  13: std::rt::lang_start::{{closure}}
  14: std::rt::lang_start_internal
  15: main

I unfortunately cannot give you the document(s) that cause this, as they are proprietary. I also do not have a minimum working example, as I have no idea what triggers it yet. The file being loaded includes many other files, and exercises many hocon features. In total, it's almost 100,000 lines of hocon, so it may take me a while to find a minimum reproducible example.

It seems to be hitting the unreachable() in src/internals/value.rs:

impl std::hash::Hash for HoconValue {
    fn hash<H>(&self, state: &mut H)
    where
        H: std::hash::Hasher,
    {
        match self {
            HoconValue::Integer(i) => i.hash(state),
            HoconValue::String(s) => s.hash(state),
            _ => unreachable!(),
        };
    }
}

Tested with hocon v0.3.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions