GyulyVGC / sniffnet

Comfortably monitor your Internet traffic 🕵️‍♂️
https://sniffnet.net
Apache License 2.0
17.92k stars 546 forks source link

Segmentation fault #300

Closed omarandlorraine closed 1 year ago

omarandlorraine commented 1 year ago

Is there an existing issue for this?

What's the problem?

I am experiencing a segmentation fault shortly after the application starts.

The big window opens, and then a fraction of a second later, I get the segmentation fault.

If I run strace sniffnet:

uname({sysname="Linux", nodename="debian", ...}) = 0
openat(AT_FDCWD, "/dev", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
fstat(3, {st_mode=S_IFDIR|0755, st_size=3720, ...}) = 0
getdents64(3, 0x556f1be004b0 /* 186 entries */, 32768) = 5376
getdents64(3, 0x556f1be004b0 /* 0 entries */, 32768) = 0
close(3)                                = 0
socket(AF_NETLINK, SOCK_RAW, NETLINK_NETFILTER) = 3
close(3)                                = 0
write(10, "\1\0\0\0\0\0\0\0", 8)        = 8
write(12, "\1\0\0\0\0\0\0\0", 8)        = 8
futex(0x556f1bdba794, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x556f1bdba740, FUTEX_WAKE_PRIVATE, 1) = 1
clock_nanosleep(CLOCK_MONOTONIC, 0, {tv_sec=0, tv_nsec=100000},  <unfinished ...>
+++ killed by SIGSEGV +++
Segmentation fault

If I'm reading this right, the segfault is happening inside clock_nanosleep 🤔

How did you install the app?

installed from crates.io

Operating System

Linux

Additional context

I'm running debian bullseye which is oldstable.

While installing, (cargo install sniffnet), I had to sudo apt install libasound2-dev libfontconfig-dev for the build to complete.

GyulyVGC commented 1 year ago

Could you also post the output after simply running sniffnet?

omarandlorraine commented 1 year ago

Could you also post the output after simply running sniffnet?

$ sniffnet

  /---------------------------------------------------------\
 |     _____           _    __    __                  _      |
 |    / ____|         (_)  / _|  / _|                | |     |
 |   | (___    _ __    _  | |_  | |_   _ __     ___  | |_    |
 |    \___ \  | '_ \  | | |  _| |  _| | '_ \   / _ \ | __|   |
 |    ____) | | | | | | | | |   | |   | | | | |  __/ | |_    |
 |   |_____/  |_| |_| |_| |_|   |_|   |_| |_|  \___|  \__|   |
 |                                                           |
 |                   ___________                             |
 |                  /___________\                            |
 |                 | ___________ |                           |
 |                 | |         | |                           |
 |                 | | v1.2.1  | |                           |
 |                 | |_________| |________________________   |
 |                 \_____________/   by Giuliano Bellini  )  |
 |                 / ''''''''''' \                       /   |
 |                / ::::::::::::: \                  =D-'    |
 |               (_________________)                         |
  \_________________________________________________________/
WARNING: lavapipe is not a conformant vulkan implementation, testing use only.
Segmentation fault
GyulyVGC commented 1 year ago

I think the problem is with your graphical adapter. The library I use for the GUI uses wgpu as default graphical renderer, but sometimes it may be incompatible. I think you'll likely solve this problem by building the app from the glow-renderer branch, which uses an alternative graphical renderer.

GyulyVGC commented 1 year ago

News? Are you able to build from the branch I mentioned? Do you prefer being provided a ready made deb/rpm package?

omarandlorraine commented 1 year ago

Apologies, I hope to get back to you on Monday or Tuesday

omarandlorraine commented 1 year ago

Apologies for late reply,

I built sniffnet on the glow-renderer branch, and there's progress. But the program still does not start. Here's the backtrace:

$ RUST_BACKTRACE=1 cargo run   
warning: unused manifest key: target.cfg(windows).rustflags
    Finished dev [unoptimized + debuginfo] target(s) in 0.43s
     Running `target/debug/sniffnet`

  /---------------------------------------------------------\
 |     _____           _    __    __                  _      |
 |    / ____|         (_)  / _|  / _|                | |     |
 |   | (___    _ __    _  | |_  | |_   _ __     ___  | |_    |
 |    \___ \  | '_ \  | | |  _| |  _| | '_ \   / _ \ | __|   |
 |    ____) | | | | | | | | |   | |   | | | | |  __/ | |_    |
 |   |_____/  |_| |_| |_| |_|   |_|   |_| |_|  \___|  \__|   |
 |                                                           |
 |                   ___________                             |
 |                  /___________\                            |
 |                 | ___________ |                           |
 |                 | |         | |                           |
 |                 | | v1.2.1  | |                           |
 |                 | |_________| |________________________   |
 |                 \_____________/   by Giuliano Bellini  )  |
 |                 / ''''''''''' \                       /   |
 |                / ::::::::::::: \                  =D-'    |
 |               (_________________)                         |
  \_________________________________________________________/
Xlib: sequence lost (0x10083 > 0x85) in reply type 0x0!
Xlib: sequence lost (0x10088 > 0x8a) in reply type 0x0!
Xlib: sequence lost (0x1008d > 0x8f) in reply type 0x0!
Xlib: sequence lost (0x10092 > 0x94) in reply type 0x0!
Xlib: sequence lost (0x10097 > 0x99) in reply type 0x0!
thread 'main' panicked at '0:23(17): error: no function with name 'texture'
', /home/sam/.cargo/registry/src/github.com-1ecc6299db9ec823/iced_glow-0.8.0/src/program.rs:77:17
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/panicking.rs:64:14
   2: core::panicking::panic_display
             at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/panicking.rs:147:5
   3: iced_glow::program::Shader::compile
             at /home/sam/.cargo/registry/src/github.com-1ecc6299db9ec823/iced_glow-0.8.0/src/program.rs:77:17
   4: iced_glow::program::Shader::fragment
             at /home/sam/.cargo/registry/src/github.com-1ecc6299db9ec823/iced_glow-0.8.0/src/program.rs:103:9
   5: iced_glow::image::Pipeline::new
             at /home/sam/.cargo/registry/src/github.com-1ecc6299db9ec823/iced_glow-0.8.0/src/image.rs:51:35
   6: iced_glow::backend::Backend::new
             at /home/sam/.cargo/registry/src/github.com-1ecc6299db9ec823/iced_glow-0.8.0/src/backend.rs:40:30
   7: <iced_glow::window::compositor::Compositor<Theme> as iced_graphics::window::gl_compositor::GLCompositor>::new
             at /home/sam/.cargo/registry/src/github.com-1ecc6299db9ec823/iced_glow-0.8.0/src/window/compositor.rs:53:38
   8: iced_glutin::application::run
             at /home/sam/.cargo/registry/src/github.com-1ecc6299db9ec823/iced_glutin-0.8.0/src/application.rs:130:9
   9: iced::application::Application::run
             at /home/sam/.cargo/registry/src/github.com-1ecc6299db9ec823/iced-0.9.0/src/application.rs:209:12
  10: sniffnet::main
             at ./src/main.rs:100:5
  11: core::ops::function::FnOnce::call_once
             at /rustc/9eb3afe9ebe9c7d2b84b71002d44f4a0edac95e0/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I suppose this is a separate issue though? What do you think?

Do you prefer being provided a ready made deb/rpm package? I have no preference really; I can easily do building from source if it saves you a job.

GyulyVGC commented 1 year ago

The problem is still related to Iced and I wouldn't be surprised if it's again the renderer, even if in other circumstances problems were solved by glow.

I think the best thing to do is waiting that Iced releases the new version (should happen shortly). They are releasing a new software renderer and I hope this solves the problem.

In the meantime, if you are interested in troubleshooting, you could run Iced examples from their repo to see if they work. If they work on the master branch but not on the 0.9 release, then the new software renderer will be the solution.

omarandlorraine commented 1 year ago

In the meantime, if you are interested in troubleshooting, you could run Iced examples from their repo to see if they work. If they work on the master branch but not on the 0.9 release, then the new software renderer will be the solution.

Thanks for that advice!

For me, the iced examples do not work on the master branch, so I guess the bug is with them.

GyulyVGC commented 1 year ago

Damn... this means that your system is incompatible with wgpu, glow, and the new software renderer..

Or maybe there is another problem with Iced I'm not aware of.

I doubt it could be related to the fact that you are running from oldstable.

Thanks for having tried anyway!

GyulyVGC commented 1 year ago

A new release of Sniffnet has been published today. By default, it still uses wgpu but should fall back to the new software renderer if wgpu crashes.

However, since the master branch of iced didn't work for you, I also provide you a link to a Sniffnet version that uses directly the new renderer (tiny-skia): https://github.com/GyulyVGC/sniffnet/suites/14909529200/artifacts/849640693

Please let me know if at least one between the artifact from the release page or from this link work @omarandlorraine

joshuamegnauth54 commented 1 year ago

I recently found out (as in five minutes ago) that iced has a backend environmental variable which makes it really easy to use Tiny Skia.

Instead of this branch, users can launch Sniffnet with ICED_BACKEND=tiny-skia. I'm not sure if this is still relevant with the new fallback feature, but it might be useful information anyway.

I'm working on a small bug fix for iced where I've been recompiling it with default-features=false each time to test Tiny Skia. It turns out I didn't have have to do that, oops. Iced's maintainer mentions the env var there.

GyulyVGC commented 1 year ago

Thanks for pointing out. I could add info about this in the README maybe. However, I still plan to leave that branch because binaries built against it are also distributed for people to avoid them to set the env var. And yes, it's still relevant even if the fallback feature exists: sometimes wgpu doesn't crash but it has glitches and those are not detected and therefor fallback doesn't always occur when it should (only in case of crash).

omarandlorraine commented 1 year ago

For unrelated reasons, I have upgraded to Debian 12.1, which is bookworm. Well, I have retried iced's master branch examples, and they run just fine.

A new release of Sniffnet has been published today.

I installed this from Cargo (needed to sudo apt install libpcap-dev libasound2-dev first!) and it solved my problem as well. So I guess I'll close this issue. It must have been the oldstable at fault, but I am no longer able to pinpoint why that would be.

GyulyVGC commented 1 year ago

That's amazing, thanks for the update!