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

Packet socket mode and callback causes segfault on stream start #941

Open
paulsammut opened this issue Sep 14, 2024 · 0 comments
Open

Packet socket mode and callback causes segfault on stream start #941

paulsammut opened this issue Sep 14, 2024 · 0 comments

Comments

@paulsammut
Copy link

paulsammut commented Sep 14, 2024

Describe the bug
When running with Packet socket mode enabled I get a segfault on stream start.

To Reproduce
Run packet socket mode using a callback and get segfault on stream start.

Expected behavior
Run packet socket mode using a callback without segfault

Camera description:

  • Manufacturer: Lucid Vision
  • Model: PHX124S
  • Interface [e.g. USB3]: GigE

Platform description:

  • Aravis version: 0.8.30 hash: 96cea98
  • OS: [e.g. Fedora 20]: Fedora 40
  • Hardware [e.g. x86_64]: x86_64

Additional context
My code uses a callback to service frame buffers. I am setting priority realtime to 10, and enabling packet socket mode by running sudo setcap cap_net_raw+ep.

With the same code I do not get this error under the following conditions:

  • Run in standard socket mode

Note When I run with ARV_DEBUG logging enabled or in a Debug build mode this segfault becomes harder to trigger. I have to create a script to start/stop the stream continuously for hundreds of times before hitting the segfault. If I run without AVR_DEBUG logging and in an optimized build I get the segfault on every stream start.

The segfault is happening due to a null dereference of frame in this line.

Stack trace of offending code:

#0  0x0000000003143899 in _find_frame_data (thread_data=0x7fb92067b000, packet=0x7fb94d6000ac, packet_size=62, frame_id=3759, packet_id=1580364, read_count=62, time_us=27579292116) at ./third-party/aravis/src/arvgvstream.c:384
#1  0x000000000314299c in _process_packet (thread_data=0x7fb92067b000, packet=0x7fb94d6000ac, packet_size=62, time_us=27579292116) at ./third-party/aravis/src/arvgvstream.c:899
#2  0x0000000003141af2 in _ring_buffer_loop (thread_data=0x7fb92067b000) at ./third-party/aravis/src/arvgvstream.c:1336
#3  0x00000000031414d8 in arv_gv_stream_thread (data=0x7fb92067b000) at ./third-party/aravis/src/arvgvstream.c:1383
#4  0x000000000341bbf7 in g_thread_proxy (data=0x7fb920608940) at gthread.c:784
#5  0x00007fb9a68b96d7 in start_thread () from /lib64/libc.so.6
#6  0x00007fb9a693d60c in clone3 () from /lib64/libc.so.6

Info on locals showing frame being null:

(gdb) info locals
frame = 0x0
buffer = 0x7fb8b40ec770
iter = 0x0
n_packets = 0
frame_id_inc = 1
extended_ids = 0

Output before segfault:

[22:40:20.441] 🅸 interface> [GvDiscoverSocket::new] Add interface 127.0.0.1 (127.0.0.1)
[22:40:20.441] 🅸 interface> [GvDiscoverSocket::new] Add interface 192.168.251.11 (192.168.251.127)
[22:40:20.441] 🅸 interface> [GvDiscoverSocket::new] Add interface 192.168.251.131 (192.168.251.255)
[22:40:20.441] 🅸 interface> [GvDiscoverSocket::new] Add interface 100.98.90.30 (100.98.90.31)
[22:40:20.445] 🅸 interface> [GvInterface::discovery] Device 'Lucid Vision Labs-PHX124S-M-XXXXXX' found (interface 192.168.251.131) user_id '' - MAC '1c:0f:af:06:fb:2b'
[22:40:20.445] 🅸 device> [GvDevice::new] Interface address = 192.168.251.131
[22:40:20.445] 🅸 device> [GvDevice::new] Device address = 192.168.251.210
[22:40:20.451] 🅸 device> [GvDevice::load_genicam] xml url = 'Local:Lucid_Vision_Labs_PHX124S-M_rev1_0_db4aaad522077f99e65fbd6c854ec858.zip;800ea2c8;1080f' at 0x200
[22:40:20.451] 🅸 device> [GvDevice::load_genicam] Xml address = 0x800ea2c8 - size = 0x1080f - Lucid_Vision_Labs_PHX124S-M_rev1_0_db4aaad522077f99e65fbd6c854ec858.zip
[22:40:20.547] 🅳 device> [GvDevice::Heartbeat] Ack value = 2
[22:40:20.998] 🅸 device> [GvDevice::load_genicam] Zipped xml data
[22:40:21.046] 🅸 device> [GvDevice::new] Device endianness = big
[22:40:21.046] 🅸 device> [GvDevice::new] Packet resend     = yes
[22:40:21.046] 🅸 device> [GvDevice::new] Write memory      = yes
[22:40:21.046] 🅸 device> [GvDevice::new] Legacy endianness handling = no
[INFO] [1726292421.049614141] [cam10.genicam]: arv_camera_new call done - took: 4414444237ns
[22:40:21.094] 🅸 device> [GvDevice::auto_packet_size] Try packet size = 8999 (8999 - min: 576 - max: 9000 - inc: 1)
[22:40:21.121] 🅸 device> [GvDevice::auto_packet_size] Packet size set to 8999 bytes
....
[INFO] [1726292834.012029736] [cam1.genicam]: Creating stream in id: 40474
[22:47:14.013] 🅸 device> [GvDevice::create_stream] Number of stream channels = 1
[22:47:14.013] 🅸 stream> [GvStream::stream_new] Stream channel = 0
[22:47:14.018] 🅸 stream> [GvStream::stream_new] Packet size = 8999 byte(s)
[22:47:14.024] 🅸 stream> [GvStream::stream_new] Destination stream port = 44308
[22:47:14.024] 🅸 stream> [GvStream::stream_new] Source stream port = 49154
[INFO] [1726292834.024823724] [cam1.genicam]: Stream cb called in 51554
[INFO] [1726292834.025043091] [cam1.genicam]: Set stream thread realtime priority to 10
[22:47:14.042] 🅸 stream> [GvStream::loop] Packet socket method
[22:47:14.070] 🅳 device> [GvDevice::Heartbeat] Ack value = 2
[22:47:14.084] 🅳 device> [GvDevice::Heartbeat] Ack value = 2
[INFO] [1726292834.092107699] [cam1.genicam]: Enabling performance improvements for GigE Vision cameras
[INFO] [1726292834.094027375] [cam1.genicam]: Created 32 buffers of size 16200000 bytes
Segmentation fault (core dumped)
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

1 participant