You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/02/01 07:57:57 UTC

[GitHub] [incubator-nuttx] btashton edited a comment on issue #2663: kthread_create hangs waiting on semaphore while trying to copy file descriptors

btashton edited a comment on issue #2663:
URL: https://github.com/apache/incubator-nuttx/issues/2663#issuecomment-770651598


   @xiaoxiang781216 I just noticed something similar when trying to create a kernel thread off of a call in `sim_bringup()` (I'm add usbhost support via libusb).  I get a segfault because in `sched_dupfiles` `rtcb->group` is 0 which means parent and child are both invalid
   
   ```c
   Thread 1 "nuttx" received signal SIGSEGV, Segmentation fault.
                                                                sched_dupfiles (tcb=0x7ffff3e295d0) at group/group_setuptaskfiles.c:103
   103           if (parent[i].f_inode &&
   Missing separate debuginfos, use: dnf debuginfo-install libgcc-10.2.1-9.fc33.x86_64 libusbx-1.0.23-2.fc33.x86_64 systemd-libs-246.7-2.fc33.x86_64 zlib-1.2.11-23.fc33.x86_64
   (gdb) p parent
   $1 = (struct file *) 0x78
   (gdb) list
   98            /* Check if this file is opened by the parent.  We can tell if
   99             * if the file is open because it contain a reference to a non-NULL
   100            * i-node structure.
   101            */
   102
   103           if (parent[i].f_inode &&
   104               (parent[i].f_oflags & O_CLOEXEC) == 0)
   105             {
   106               /* Yes... duplicate it for the child */
   107
   (gdb) p rtcb
   $2 = (struct tcb_s *) 0x7ffff3e27c90
   (gdb) p rtcb->group
   $3 = (struct task_group_s *) 0x0
   (gdb) p rtcb*
   A syntax error in expression, near `'.
   (gdb) p *rtcb
   $4 = {flink = 0x43f8a0 <g_idletcb>, blink = 0x7ffff7f38020 <_IO_strn_jumps>, group = 0x0, pid = 1, start = 0x402184 <nxtask_start>, entry = {pthread = 0x408e78 <nsh_main>, main = 0x408e78 <nsh_main>}, sched_priority = 100 'd', 
     init_priority = 100 'd', task_state = 3 '\003', flags = 0, lockcount = 0, errcode = 0, waitdog = {next = 0x0, func = 0x85b82ce26aee8900, lag = 0, flags = 0 '\000', arg = 9635500753727424768}, adj_stack_size = 140737285094944, 
     stack_alloc_ptr = 0x85b82ce26aee8900, adj_stack_ptr = 0x4412a0, waitsem = 0x0, sigprocmask = 4091706928, sigwaitmask = 32767, sigpendactionq = {head = 0x4412a0, tail = 0xffffffff}, sigpostedq = {head = 0x3, tail = 0x4441d0}, sigunbinfo = {
       si_signo = 5 '\005', si_code = 23 '\027', si_errno = 232 '\350', si_value = {sival_int = 48, sival_ptr = 0x3000000030}, si_pid = 32304, si_status = 32767}, msgwaitq = 0x7ffff3e27d60, mhead = 0x85b82ce26aee8900, xcp = {
       sigdeliver = 0x7ffff3e27e1c, regs = {4539616, 0, 0, 0, 140737353413158, 4473296, 140737351999557, 140737351996080}}, name = "x\030\371\367\377\177\000\000\000\000\000\000\000\000\000\000 \203\363\367\t\000\000\000\340DE\000\000\000\000"}
   (gdb) p rtcb->group
   $5 = (struct task_group_s *) 0x0
   
   (gdb) bt
   #0  sched_dupfiles (tcb=0x7ffff3e295d0) at group/group_setuptaskfiles.c:103
   #1  0x00000000004028c8 in group_setuptaskfiles (tcb=0x7ffff3e295d0) at group/group_setuptaskfiles.c:219
   #2  0x0000000000401ae8 in nxtask_init (tcb=0x7ffff3e295d0, name=0x4335bf "usbhost", priority=50, stack=0x0, stack_size=65536, entry=0x42e28a <usbhost_waiter>, argv=0x0) at task/task_init.c:105
   #3  0x000000000040196f in nxthread_create (name=0x4335bf "usbhost", ttype=2 '\002', priority=50, stack_size=65536, entry=0x42e28a <usbhost_waiter>, argv=0x0) at task/task_create.c:94
   #4  0x0000000000401a83 in kthread_create (name=0x4335bf "usbhost", priority=50, stack_size=65536, entry=0x42e28a <usbhost_waiter>, argv=0x0) at task/task_create.c:235
   #5  0x000000000042e3a8 in up_init_usbhost (bus=0) at sim_bringup.c:129
   #6  0x000000000042e4e8 in sim_bringup () at sim_bringup.c:491
   #7  0x000000000042e283 in board_app_initialize (arg=0) at sim_appinit.c:82
   #8  0x000000000042a78f in boardctl (cmd=65281, arg=0) at boardctl.c:326
   #9  0x0000000000408f33 in nsh_initialize () at nsh_init.c:103
   #10 0x0000000000408ec4 in nsh_main (argc=1, argv=0x7ffff3e29340) at nsh_main.c:143
   #11 0x000000000040591d in nxtask_startup (entrypt=0x408e78 <nsh_main>, argc=1, argv=0x7ffff3e29340) at sched/task_startup.c:165
   #12 0x0000000000402232 in nxtask_start () at task/task_start.c:144
   #13 0x0000000000000000 in ?? ()
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org