Coder Social home page Coder Social logo

Comments (4)

hroi avatar hroi commented on May 29, 2024

Can you try to reproduce with the latest master?

from treebitmap.

DevQps avatar DevQps commented on May 29, 2024

I still have it when I execute this code:

use treebitmap::IpLookupTable;
use std::net::Ipv4Addr;

fn main() {
    let mut table: IpLookupTable<Ipv4Addr, u32> = IpLookupTable::new();

    for x in 0..1000 {
        let address = Ipv4Addr::from(x);
        table.insert(address, x % 32, x);
    }
}

Error:

thread 'main' panicked at 'assertion failed: ret > 0', C:\Users\Christian\.cargo\git\checkouts\treebitmap-1850d5d1ddb6d462\9540ae5\src\tree_bitmap\node.rs:66:5
stack backtrace:
   0: std::sys::windows::backtrace::set_frames
             at /rustc/428943cc290e64187e0698f41853ef316c0a7d03\/src\libstd\sys\windows\backtrace\mod.rs:95
   1: std::sys::windows::backtrace::unwind_backtrace
             at /rustc/428943cc290e64187e0698f41853ef316c0a7d03\/src\libstd\sys\windows\backtrace\mod.rs:82
   2: std::sys_common::backtrace::_print
             at /rustc/428943cc290e64187e0698f41853ef316c0a7d03\/src\libstd\sys_common\backtrace.rs:71
   3: std::sys_common::backtrace::print
             at /rustc/428943cc290e64187e0698f41853ef316c0a7d03\/src\libstd\sys_common\backtrace.rs:59
   4: std::panicking::default_hook::{{closure}}
             at /rustc/428943cc290e64187e0698f41853ef316c0a7d03\/src\libstd\panicking.rs:197
   5: std::panicking::default_hook
             at /rustc/428943cc290e64187e0698f41853ef316c0a7d03\/src\libstd\panicking.rs:211
   6: std::panicking::rust_panic_with_hook
             at /rustc/428943cc290e64187e0698f41853ef316c0a7d03\/src\libstd\panicking.rs:474
   7: std::panicking::begin_panic<str*>
             at /rustc/428943cc290e64187e0698f41853ef316c0a7d03\src\libstd\panicking.rs:408
   8: treebitmap::tree_bitmap::node::gen_bitmap
             at <::std::macros::panic macros>:3
   9: treebitmap::tree_bitmap::TreeBitmap<u32>::insert<u32>
             at C:\Users\Christian\.cargo\git\checkouts\treebitmap-1850d5d1ddb6d462\9540ae5\src\tree_bitmap\mod.rs:178
  10: treebitmap::IpLookupTable<std::net::ip::Ipv4Addr, u32>::insert<std::net::ip::Ipv4Addr,u32>
             at C:\Users\Christian\.cargo\git\checkouts\treebitmap-1850d5d1ddb6d462\9540ae5\src\lib.rs:100
  11: dummy::main
             at .\src\main.rs:9
  12: std::rt::lang_start::{{closure}}<()>
             at /rustc/428943cc290e64187e0698f41853ef316c0a7d03\src\libstd\rt.rs:64
  13: std::rt::lang_start_internal::{{closure}}
             at /rustc/428943cc290e64187e0698f41853ef316c0a7d03\/src\libstd\rt.rs:49
  14: std::panicking::try::do_call<closure,i32>
             at /rustc/428943cc290e64187e0698f41853ef316c0a7d03\/src\libstd\panicking.rs:293
  15: panic_unwind::__rust_maybe_catch_panic
             at /rustc/428943cc290e64187e0698f41853ef316c0a7d03\/src\libpanic_unwind\lib.rs:87
  16: std::panicking::try
             at /rustc/428943cc290e64187e0698f41853ef316c0a7d03\/src\libstd\panicking.rs:272
  17: std::panic::catch_unwind
             at /rustc/428943cc290e64187e0698f41853ef316c0a7d03\/src\libstd\panic.rs:388
  18: std::rt::lang_start_internal
             at /rustc/428943cc290e64187e0698f41853ef316c0a7d03\/src\libstd\rt.rs:48
  19: std::rt::lang_start<()>
             at /rustc/428943cc290e64187e0698f41853ef316c0a7d03\src\libstd\rt.rs:64
  20: main
  21: invoke_main
             at d:\agent\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  22: __scrt_common_main_seh
             at d:\agent\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  23: BaseThreadInitThunk
  24: RtlUserThreadStart
error: process didn't exit successfully: `target\debug\dummy.exe` (exit code: 101)

Process finished with exit code 101

from treebitmap.

pusateri avatar pusateri commented on May 29, 2024

This is a duplicate of #9. If you make sure the host portion is 0, it works ok. I think panicing is the wrong behavior. The insert code should just mask out the host portion so this never happens. You can confirm with this modified code:

use treebitmap::IpLookupTable;
use std::net::Ipv4Addr;

fn main() {
    let mut table: IpLookupTable<Ipv4Addr, u32> = IpLookupTable::new();

    for x in 0..1000 {
        
        let plen = x % 32;
        let address_mask: u32 = match plen {
        	0 => 0,
        	n => 1 << (32 - n),
        };
        let address = Ipv4Addr::from(x & address_mask);
        println!("{:?}/{:x}({}) for {}", address, address_mask, plen, x);
        table.insert(address, plen, x);
    }
}

from treebitmap.

DevQps avatar DevQps commented on May 29, 2024

Thanks for your response! Let's close this one now then.

from treebitmap.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.