Thank you Damjan for your confirmation. I'll restore to previous code. Thanks again.
From: Damjan Marion (damarion) <damar...@cisco.com> Sent: Wednesday, September 26, 2018 5:52 PM To: Lijian Zhang (Arm Technology China) <lijian.zh...@arm.com> Cc: d...@barachs.net; vpp-dev@lists.fd.io Subject: Re: unformat_check_input crashed during multiarch function initialization Ah, i forgot that you are executing this from constructor before clib_mem_init happens. So it is expected not to work. You will need to stay on your old code, sorry for wasting your time.. :( -- Damjan On 26 Sep 2018, at 11:28, Lijian Zhang (Arm Technology China) <lijian.zh...@arm.com<mailto:lijian.zh...@arm.com>> wrote: Hi Damjan, I tried to rewrite the function reading CPU info from /proc/cpuinfo, using VPP style functions, for multi-arch dynamic function selection. But function unformat_check_input failed and crashed. I pasted the /proc/cpuinfo reading function and gdb process as below. Could you suggest on this issue? static inline int clib_cpu_supports_implements (const u32 implid, const u32 partid) { u32 implementer = -1, part = -1; int fd; unformat_input_t input; fd = open ("/proc/cpuinfo", 0); if (fd < 0) return 0; unformat_init_clib_file (&input, fd); while (unformat_check_input (&input) != UNFORMAT_END_OF_INPUT) { if (unformat (&input, "CPU implementer : %x", &implementer)) ; else if (unformat (&input, "CPU part : %x", &part)) ; else unformat_skip_line (&input); if ((-1 != implementer) && (-1 != part)) break; } unformat_free (&input); close (fd); printf("++++++++++ %x %x\n", implementer, part); if ((implid == implementer) && (partid == part)) return 1; else return 0; } lijian@net-arm-thunderx2:~/tasks/vpp.upstream/vpp$<mailto:lijian@net-arm-thunderx2:~/tasks/vpp.upstream/vpp$> sudo gdb ./build-root/build-vpp_debug-native/vpp/bin/vpp -c /home/lijian/startup.conf GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1 Copyright (C) 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "aarch64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./build-root/build-vpp_debug-native/vpp/bin/vpp...done. "/home/lijian/startup.conf" is not a core dump: File format not recognized (gdb) b clib_cpu_supports_implements Function "clib_cpu_supports_implements" not defined. Make breakpoint pending on future shared library load? (y or [n]) y Breakpoint 1 (clib_cpu_supports_implements) pending. (gdb) run -c /home/lijian/startup.conf Starting program: /home/lijian/tasks/vpp.upstream/vpp/build-root/build-vpp_debug-native/vpp/bin/vpp -c /home/lijian/startup.conf warning: Unable to determine the number of hardware watchpoints available. warning: Unable to determine the number of hardware breakpoints available. [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1". Breakpoint 1, clib_cpu_supports_implements (implid=81, partid=3072) at /home/lijian/tasks/vpp.upstream/vpp/src/vppinfra/cpu.h:28 28 { (gdb) bt #0 clib_cpu_supports_implements (implid=81, partid=3072) at /home/lijian/tasks/vpp.upstream/vpp/src/vppinfra/cpu.h:28 #1 0x0000ffffbeac4294 in clib_cpu_march_priority_qdf24xx () at /home/lijian/tasks/vpp.upstream/vpp/src/vppinfra/cpu.h:248 #2 0x0000ffffbeac5c04 in svm_fifo_enqueue_nowait_march_constructor_qdf24xx () at /home/lijian/tasks/vpp.upstream/vpp/src/svm/svm_fifo.c:457 #3 0x0000ffffbf6dfb60 in call_init (l=<optimized out>, argc=argc@entry=3, argv=argv@entry=0xfffffffff5f8, env=env@entry=0xfffffffff618) at dl-init.c:72 #4 0x0000ffffbf6dfca8 in call_init (env=0xfffffffff618, argv=0xfffffffff5f8, argc=3, l=<optimized out>) at dl-init.c:30 #5 _dl_init (main_map=0xffffbf700190, argc=3, argv=0xfffffffff5f8, env=0xfffffffff618) at dl-init.c:120 #6 0x0000ffffbf6d2d44 in _dl_start_user () from /lib/ld-linux-aarch64.so.1 Backtrace stopped: previous frame identical to this frame (corrupt stack?) (gdb) n 29 u32 implementer = -1, part = -1; (gdb) 33 fd = open ("/proc/cpuinfo", 0); (gdb) 34 if (fd < 0) (gdb) 37 unformat_init_clib_file (&input, fd); (gdb) 39 while (unformat_check_input (&input) != UNFORMAT_END_OF_INPUT) (gdb) p input $1 = {buffer = 0x0, index = 0, buffer_marks = 0x0, fill_buffer = 0xffffbea41188 <clib_file_fill_buffer>, fill_buffer_arg = 0x3} (gdb) s unformat_check_input (i=0xfffffffff4f0) at /home/lijian/tasks/vpp.upstream/vpp/src/vppinfra/format.h:171 171 { (gdb) n 175 if (i->index >= vec_len (i->buffer) && i->index != UNFORMAT_END_OF_INPUT) (gdb) 179 _unformat_fill_input (i); (gdb) s _unformat_fill_input (i=0xfffffffff4f0) at /home/lijian/tasks/vpp.upstream/vpp/src/vppinfra/unformat.c:43 43 { (gdb) n 46 if (i->index == UNFORMAT_END_OF_INPUT) (gdb) 49 first_mark = l = vec_len (i->buffer); (gdb) 50 if (vec_len (i->buffer_marks) > 0) (gdb) 54 if (first_mark > 0) (gdb) 57 i->index = vec_len (i->buffer); (gdb) 58 for (l = 0; l < vec_len (i->buffer_marks); l++) (gdb) 62 if (i->fill_buffer) (gdb) 63 i->index = i->fill_buffer (i); (gdb) s clib_file_fill_buffer (input=0xfffffffff4f0) at /home/lijian/tasks/vpp.upstream/vpp/src/vppinfra/unformat.c:1041 1041 { (gdb) n 1042 int fd = pointer_to_uword (input->fill_buffer_arg); (gdb) 1045 l = vec_len (input->buffer); (gdb) 1046 vec_resize (input->buffer, 4096); (gdb) p input->buffer $2 = (u8 *) 0x0 (gdb) s _vec_resize_inline (v=0x0, length_increment=4096, data_bytes=4096, header_bytes=0, data_align=1) at /home/lijian/tasks/vpp.upstream/vpp/src/vppinfra/vec.h:121 121 { (gdb) n 122 vec_header_t *vh = _vec_find (v); (gdb) 125 aligned_header_bytes = vec_header_bytes (header_bytes); (gdb) 127 new_data_bytes = data_bytes + aligned_header_bytes; (gdb) p aligned_header_bytes $3 = 8 (gdb) n 129 if (PREDICT_TRUE (v != 0)) (gdb) 147 clib_max (sizeof (vec_header_t), (gdb) 145 return vec_resize_allocate_memory (v, length_increment, data_bytes, (gdb) s vec_resize_allocate_memory (v=0x0, length_increment=4096, data_bytes=4096, header_bytes=0, data_align=8) at /home/lijian/tasks/vpp.upstream/vpp/src/vppinfra/vec.c:48 48 { (gdb) n 49 vec_header_t *vh = _vec_find (v); (gdb) 53 header_bytes = vec_header_bytes (header_bytes); (gdb) 55 data_bytes += header_bytes; (gdb) 57 if (!v) (gdb) 59 new = clib_mem_alloc_aligned_at_offset (data_bytes, data_align, header_bytes, 1 /* yes, call os_out_of_memory */ (gdb) Program received signal SIGSEGV, Segmentation fault. 0x0000ffffbea52f24 in ok_magic (m=0x0) at /home/lijian/tasks/vpp.upstream/vpp/src/vppinfra/dlmalloc.c:1618 1618 return (m->magic == mparams.magic); (gdb) Thanks. IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#10669): https://lists.fd.io/g/vpp-dev/message/10669 Mute This Topic: https://lists.fd.io/mt/26229023/21656 Group Owner: vpp-dev+ow...@lists.fd.io Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-