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

Sniffnet 1.3.2 crashes with error: user-provided comparison function does not correctly implement a total order #675

Open
1 task done
koshikas opened this issue Jan 8, 2025 · 18 comments
Labels
bug Something isn't working

Comments

@koshikas
Copy link

koshikas commented Jan 8, 2025

Is there an existing issue for this?

  • I have searched the existing issues.

What's the problem?

Sniffnet 1.3.2 crashes after selecting the network adapter and starting the analysis, the application crashes. i get following stack trace;

thread 'main' panicked at core/src/slice/sort/shared/smallsort.rs:865:5:
user-provided comparison function does not correctly implement a total order
stack backtrace:
0: 0x5f7b55bb4af9 -
1: 0x5f7b55511183 -
2: 0x5f7b55b7f302 -
3: 0x5f7b55bb9f32 -
4: 0x5f7b55bb9c7b -
5: 0x5f7b55bb99cf -
6: 0x5f7b55a5d001 -
7: 0x5f7b55bba1f9 -
8: 0x5f7b55bb9fd5 -
9: 0x5f7b55bb9f69 -
10: 0x5f7b55bb9f5c -
11: 0x5f7b553cf0ff -
12: 0x5f7b553cf77a -
13: 0x5f7b555b150f -
14: 0x5f7b555b37ff -
15: 0x5f7b555b2fc0 -
16: 0x5f7b555b2fc0 -
17: 0x5f7b555b26f4 -
18: 0x5f7b55b487fe -
19: 0x5f7b5542d8fb -
20: 0x5f7b554399da -
21: 0x5f7b55b5787a -
22: 0x5f7b55ada978 -
23: 0x5f7b554379f4 -
24: 0x5f7b55a5ab86 -
25: 0x5f7b5544c386 -
26: 0x5f7b55a5840e -
27: 0x794584f2ce08 -
28: 0x794584f2cecc - __libc_start_main
29: 0x5f7b554250d5 -
30: 0x0 -

after downgrading to Sniffnet 1.3.1, everything works as it should.

How did you install the app?

downloaded one of the provided packages

Operating System

Linux

Additional context

System:
Kernel: 6.12.8-1-MANJARO arch: x86_64 bits: 64 compiler: gcc v: 14.2.1
clocksource: tsc avail: hpet,acpi_pm
parameters: BOOT_IMAGE=/boot/vmlinuz-6.12-x86_64
root=UUID=e0d878c7-******* rw
lsm=landlock,lockdown,yama,apparmor,bpf quiet rd.udev.log_level=3
i915.fastboot=1 audit=0 ipv6.disable=1 i8042.nomux=1 nowatchdog
Desktop: KDE Plasma v: 6.2.5 tk: Qt v: N/A info: frameworks v: 6.9.0
wm: kwin_x11 tools: avail: xtrlock vt: 2 dm: SDDM Distro: Manjaro
base: Arch Linux
Machine:
Type: Portable System: Dell product: Inspiron 5520 v: A14
serial: Chassis: type: 8 v: A14
serial:
Mobo: Dell model: 0XWH1P v: A00 serial:
CPU:
Info: model: Intel Core i7-3612QM bits: 64 type: MT MCP arch: Ivy Bridge
gen: core 3 level: v2 built: 2012-15 process: Intel 22nm family: 6
model-id: 0x3A (58) stepping: 9 microcode: 0x21
Topology: cpus: 1x dies: 1 clusters: 4 cores: 4 threads: 8 tpc: 2
smt: enabled cache: L1: 256 KiB desc: d-4x32 KiB; i-4x32 KiB L2: 1024 KiB
desc: 4x256 KiB L3: 6 MiB desc: 1x6 MiB
Speed (MHz): avg: 1200 min/max: 1200/2100 scaling: driver: intel_cpufreq
governor: schedutil cores: 1: 1200 2: 1200 3: 1200 4: 1200 5: 1200 6: 1200
7: 1200 8: 1200 bogomips: 33536
Flags: avx ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
Graphics:
Device-1: Intel 3rd Gen Core processor Graphics vendor: Dell driver: i915
v: kernel arch: Gen-7 process: Intel 22nm built: 2012-13 ports:
active: LVDS-1 empty: DP-1,HDMI-A-1,VGA-1 bus-ID: 00:02.0
chip-ID: 8086:0166 class-ID: 0300
Device-2: Advanced Micro Devices [AMD/ATI] Thames [Radeon HD 7500M/7600M
Series] vendor: Dell driver: radeon v: kernel alternate: amdgpu
arch: TeraScale-2 code: Evergreen process: TSMC 32-40nm built: 2009-15
pcie: gen: 1 speed: 2.5 GT/s lanes: 8 link-max: gen: 2 speed: 5 GT/s
lanes: 16 bus-ID: 01:00.0 chip-ID: 1002:6840 class-ID: 0300 temp: 48.0 C
Device-3: Microdia Laptop_Integrated_Webcam_HD driver: uvcvideo type: USB
rev: 2.0 speed: 480 Mb/s lanes: 1 mode: 2.0 bus-ID: 4-1.5:7
chip-ID: 0c45:644a class-ID: 0e02
Display: x11 server: X.Org v: 21.1.15 with: Xwayland v: 24.1.4
compositor: kwin_x11 driver: X: loaded: intel,radeon unloaded: modesetting
alternate: fbdev,vesa dri: i965,r600 gpu: i915 display-ID: :0 screens: 1
Screen-1: 0 s-res: 1366x768 s-dpi: 96 s-size: 361x203mm (14.21x7.99")
s-diag: 414mm (16.31")
Monitor-1: LVDS-1 mapped: LVDS1 model: LG Display 0x033a built: 2012
res: 1366x768 hz: 60 dpi: 102 gamma: 1.2 size: 340x190mm (13.39x7.48")
diag: 395mm (15.5") ratio: 16:9 modes: 1366x768
API: EGL v: 1.5 hw: drv: intel crocus drv: amd r600 platforms: device: 0
drv: crocus device: 1 drv: r600 device: 2 drv: swrast gbm: drv: crocus
surfaceless: drv: crocus x11: drv: crocus inactive: wayland
API: OpenGL v: 4.5 compat-v: 4.2 vendor: intel mesa v: 24.2.7-arch1.1
glx-v: 1.4 direct-render: yes renderer: Mesa Intel HD Graphics 4000 (IVB GT2)
device-ID: 8086:0166 memory: 1.46 GiB unified: yes
API: Vulkan v: 1.4.303 layers: N/A device: 0 type: integrated-gpu
name: Intel HD Graphics 4000 (IVB GT2) driver: N/A device-ID: 8086:0166
surfaces: xcb,xlib
Audio:
Device-1: Intel 7 Series/C216 Family High Definition Audio vendor: Dell
driver: snd_hda_intel v: kernel bus-ID: 00:1b.0 chip-ID: 8086:1e20
class-ID: 0403
API: ALSA v: k6.12.8-1-MANJARO status: kernel-api with: aoss
type: oss-emulator tools: alsactl,alsamixer,amixer
Server-1: PipeWire v: 1.2.7 status: active with: 1: pipewire-pulse
status: active 2: wireplumber status: active 3: pipewire-alsa type: plugin
4: pw-jack type: plugin tools: pactl,pw-cat,pw-cli,wpctl
Network:
Device-1: Realtek RTL810xE PCI Express Fast Ethernet vendor: Dell
driver: r8169 v: kernel pcie: gen: 1 speed: 2.5 GT/s lanes: 1 port: 2000
bus-ID: 07:00.0 chip-ID: 10ec:8136 class-ID: 0200
IF: enp7s0 state: down mac:
Device-2: Intel Centrino Wireless-N 2230 driver: iwlwifi v: kernel pcie:
gen: 1 speed: 2.5 GT/s lanes: 1 bus-ID: 08:00.0 chip-ID: 8086:0887
class-ID: 0280
IF: wlp8s0 state: up mac:
Info: services: NetworkManager, sshd, systemd-timesyncd, wpa_supplicant
Bluetooth:
Device-1: Intel Centrino Bluetooth Wireless Transceiver driver: btusb v: 0.8
type: USB rev: 2.0 speed: 12 Mb/s lanes: 1 mode: 1.1 bus-ID: 2-1.5:3
chip-ID: 8087:07da class-ID: e001
Report: btmgmt ID: hci0 rfk-id: 1 state: down bt-service: enabled,running
rfk-block: hardware: no software: yes address: bt-v: 4.0 lmp-v: 6
status: discoverable: no pairing: no
Info:
Memory: total: 8 GiB available: 7.63 GiB used: 3.23 GiB (42.3%)
Processes: 244 Power: uptime: 2h 14m states: freeze,mem,disk suspend: deep
avail: s2idle wakeups: 0 hibernate: platform avail: shutdown, reboot,
suspend, test_resume image: 3.03 GiB services: org_kde_powerdevil,
thermald, upowerd Init: systemd v: 257 default: graphical tool: systemctl
Packages: pm: pacman pkgs: 1812 libs: 387 tools: octopi,pamac,yay
Compilers: gcc: 14.2.1 Shell: Bash v: 5.2.37 running-in: konsole inxi: 3.3.36

@GyulyVGC GyulyVGC added the bug Something isn't working label Jan 8, 2025
@GyulyVGC
Copy link
Owner

GyulyVGC commented Jan 8, 2025

It seems something related to Rust 1.81 new sorting implementations.

Unfortunately I'm not able to reproduce this on any of my machines, but I'll try to find a fix.

@GyulyVGC GyulyVGC changed the title Sniffnet 1.3.2 crashes with just before starting the analysis Sniffnet 1.3.2 crashes with error: user-provided comparison function does not correctly implement a total order Jan 8, 2025
@koshikas
Copy link
Author

koshikas commented Jan 8, 2025

It seems something related to Rust 1.81 new sorting implementations.

Unfortunately I'm not able to reproduce this on any of my machines, but I'll try to find a fix.

no issues, i've reverted to 1.3.1, and it is functioning fine. let me know if i can help with more debugging from my end.

Thanks!

@GyulyVGC
Copy link
Owner

GyulyVGC commented Jan 8, 2025

Yes, I'll need your help to test once I come up with a potential fix.

Thanks very much 👍

@neogeographica
Copy link

Same thing experienced on my system, FWIW.

Because of issue #635 I launched sniffnet as:

ICED_BACKEND=tiny-skia sniffnet

and then it failed with

thread 'main' panicked at core/src/slice/sort/shared/smallsort.rs:865:5:
user-provided comparison function does not correctly implement a total order

as per above.

My OS is Pop!_OS 22.04.

v1.3.1 doesn't experience the error.

@GyulyVGC
Copy link
Owner

GyulyVGC commented Feb 4, 2025

Hey guys when does this error happen? In which screen of the application?

I'm asking this to understand where is the comparison function to fix.

@neogeographica
Copy link

As soon as it launches and tries to create a GUI window. I don't remember seeing much of what that window was supposed to be, but judging from the behavior of 1.3.1 when it launches, it's either an initial "no traffic has been detect yet" message or else the Overview window for the main/default adapter.

@GyulyVGC
Copy link
Owner

GyulyVGC commented Feb 4, 2025

Oh ok, if it's happening before you see anything, then it is the page where you have to select network adapters an filters.

@GyulyVGC
Copy link
Owner

GyulyVGC commented Feb 4, 2025

This is even more strange now as @koshikas is having this issue in the overview page instead.

@neogeographica
Copy link

As mentioned above it could well be the overview page since that seems to be the first page it launches into. It doesn't explicitly ask me to choose an adapter first. The "no traffic yet" message displays for a split second then it goes straight to overview.

@GyulyVGC
Copy link
Owner

GyulyVGC commented Feb 4, 2025

Oh ok sorry there was a misunderstanding.
I thought it was happening as soon as you started the app.

Ok so the problem is in the overview page for you as well.
I'm guessing it's because of the way hosts are being sorted.
I'll check again for possible fixes, and I hope to find an OS where I'm able to replicate the issue.

@GyulyVGC
Copy link
Owner

GyulyVGC commented Feb 4, 2025

I've built a new binary for you guys to test, find the links here (at the bottom of the page).

This is using the latest dependencies and Rust version.
I didn't change sort strategy since it already seems correct to me, I hope this was a problem solved with the newest Rust release.


For reference this is the piece of code used to sort items:

pub fn compare(&self, other: &Self, sort_type: SortType, chart_type: ChartType) -> Ordering {
    match chart_type {                                                                       
        ChartType::Packets => match sort_type {                                              
            SortType::Ascending => self.tot_packets().cmp(&other.tot_packets()),             
            SortType::Descending => other.tot_packets().cmp(&self.tot_packets()),            
            SortType::Neutral => other.final_timestamp.cmp(&self.final_timestamp),           
        },                                                                                   
        ChartType::Bytes => match sort_type {                                                
            SortType::Ascending => self.tot_bytes().cmp(&other.tot_bytes()),                 
            SortType::Descending => other.tot_bytes().cmp(&self.tot_bytes()),                
            SortType::Neutral => other.final_timestamp.cmp(&self.final_timestamp),           
        },                                                                                   
    }                                                                                        
}                                                                                            

As you can see I'm using cmp which implements total ordering, so I can't seem to find the root of the issue.

@koshikas
Copy link
Author

koshikas commented Feb 4, 2025

I've built a new binary for you guys to test, find the links here (at the bottom of the page).

just tried small issue on archlinux we are running libpcap 1.10.5. and the build you provided seems to be looking for libpcap 0.8.x. is there any way get libpcap further upstream to build at your end

error i get with your build;
./sniffnet: error while loading shared libraries: libpcap.so.0.8: cannot open shared object file: No such file or directory

@GyulyVGC
Copy link
Owner

GyulyVGC commented Feb 4, 2025

Unfortunately the package I build aren't for Arch Linux. However you can try checking the required dependencies, but not sure it'll work on Arch since there you have to install via pacman.

@koshikas
Copy link
Author

koshikas commented Feb 4, 2025

Unfortunately the package I build aren't for Arch Linux. However you can try checking the required dependencies, but not sure it'll work on Arch since there you have to install via pacman.

not a issue let me try compile libpcap myself, can yo confirm me the exect version of libpcap required here

@GyulyVGC
Copy link
Owner

GyulyVGC commented Feb 4, 2025

libpcap0.8

@koshikas
Copy link
Author

koshikas commented Feb 4, 2025

libpcap0.8

sorry i'm running into issues building that old of libcap build, all its dependecies have moved on since (sh of all things)

@neogeographica
Copy link

neogeographica commented Feb 4, 2025

Same issue for me, with that build.

It is definitely on the overview page, after getting past the "No traffic has been observed yet" message.

edit: Not a Rust-knower myself, but perhaps the match statements need default match-everything-else patterns to satisfy the analysis?

@GyulyVGC
Copy link
Owner

GyulyVGC commented Feb 4, 2025

In this case it's not needed since I'm just matching against all the variants of an enum. So there are no other cases possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants