Segmentation fault , ndpi_detection_process_packet from lib/libndpi.so.4
1.version: ndpi 4.6
2.gdb info1: 0 0x99097fIef3d494ee in ndpi_search_ookla () from /lib/libndpi.so.4 Missing separate debuginfos, use: debuginfo-install glibc-2.17-260.el7_6.6.x86_64 libgcc-4.8.5-44.el7.x86_64 libgpg-error-1.12-3.el7.x86_64 libibverbs-29.0-3.el8.x86_64 libnl3-3.2.28-4.el7. x86_64 libstdc++-4.8.5-44.el7.x86_64 numactl-libs-2.0.12-5.el7.x86_64 sqlite-3.7.17-8.el7.x86_64 sqlite-3.7.17-8.el7_7.1.x86_64 (gdb) bt 0 0xO0007flef3d494ee in ndpi_search_ookla () from /lib/libndpi.so.4 1 0xO0007flef3d6efe5 in check_ndpi_detection_func () from /lib/libndpi.so.4 2 0xO0007flef3d73804 in ndpi detection process packet () from /lib/libndpi.so.4
3.gdb info2:
program terminated with signal 11, Segmentation fault. 0x00007fd6134fb737 in ndpi_search_snmp () from /lib/libndpi.so.4 lissing separate debuginfos, use: debuginfo-install glibc-2.17-260.el7_6.6.x86_64 libgcc-4.8.5-44.el7.x86_64 libgpg-error-1.12-3.el7.x86_64 libibverbs-29.0-3.el8.x86_64 libnl3-3.2.28-4.el7. <86_64 libstdc++-4.8.5-44.el7.x86_64 numactl-libs-2.0.12-5.el7.x86_64 sqlite-377.17-8.el7.x86_64 sqlite-3.7.17-8.el7_7.1.x86_64 Igdb) bt f0 0x00007fd6134fb737 in ndpi_search_snmp () from /lib/libndpi.so.4 fl 0x00007fd613525fe5 in check_ndpi_detection_func () from /lib/libndpi.so.4 (2 0x00007fd61352a804 in ndpi_detection_process_packet () from /lib/libndpi.so.4
4.Every time program is executed, the error message randomly appears in a certain application layer protocol,but only UDP protocol may cause error.
5.how I use ndpi-API?as follows:
Initialize one ndpi_detection_module_struct on each logical core.
struct ndpi_detection_module_struct *g_nDPIModule[MAX_CORE_SIZE]; ndpi_init_prefs init_prefs = ndpi_no_prefs; int i = 0; for (i = 0; i < coresize; i++) { g_nDPIModule[i] = ndpi_init_detection_module(init_prefs); if (g_nDPIModule[i] == NULL){ state = 1; break; } NDPI_PROTOCOL_BITMASK protos; NDPI_BITMASK_SET_ALL(protos); ndpi_set_protocol_detection_bitmask2(g_nDPIModule[i], &protos); ndpi_finalize_initialization(g_nDPIModule[i]);
- each 5-tuple(src_addr,dst_addr,src_port,dst_port,udp-17)session(udpflow) has its ndpi_flow, as follows:
if (NULL == udpflow->ndpi_flow) { udpflow->ndpi_flow=(struct ndpi_flow_struct *) ndpi_flow_malloc(SIZEOF_FLOW_STRUCT); if (udpflow->ndpi_flow == NULL) { return NULL; } memset(udpflow->ndpi_flow, 0, SIZEOF_FLOW_STRUCT);
- one udpflow calls “ndpi_detection_process_packet” function on one lcore, use its udpflow->ndpi_flow, use its udp packet,as follows: `struct ndpi_flow_input_info input_info; input_info.in_pkt_dir = NDPI_IN_PKT_DIR_UNKNOWN; input_info.seen_flow_beginning = NDPI_FLOW_BEGINNING_UNKNOWN;
ndpi_protocol ndpi_detected_app = ndpi_detection_process_packet(g-nDPIModule[lcore_id], udpflow->ndpi_flow, packet, packet_len, packet_time_ms, &input_info);
//try to guess one uint8_t guessed = 0; if (ndpi_detected_app.master.protocol == 0 && ndpi_detected_app.app.protocol == 0) { ndpi_detected_app = ndpi_detection_giveup( g_nDPIModule[lcore_id], udpflow->ndpi_flow, 1, // 1 allow guess protocol, 0 not allow &guessed); }`
Question: why segmentation fault always appears? please help me, Thanks very much.
The information you provided is not enough to help you fix this issue.
Some useful information could be:
- provide a coredump file
- provide a stack trace that contains source files/lines
- provide more source code of your implementation e.g. how do you distribute packets across multiple threads
- How does your flow manager logic work?