* problem with sessions in xenomai 3.1 @ 2019-10-24 8:41 davy.regneau 2019-10-25 17:05 ` Jan Kiszka 2019-10-26 9:12 ` Philippe Gerum 0 siblings, 2 replies; 13+ messages in thread From: davy.regneau @ 2019-10-24 8:41 UTC (permalink / raw) To: xenomai Hi, Shared sessions do not seem to work with Xenomai 3.1. I made this simple code to test it : RT_TASK task; void foo(){ while(1){ printf("Hello !\n"); rt_task_sleep(2000000000); } } int main(int argc, char *argv[]){ int n; if (mlockall( MCL_CURRENT | MCL_FUTURE )!=0) return 1; if ((n=rt_task_spawn( &task, NULL, 0, 99, T_JOINABLE, &foo, NULL))!=0){ rt_printf("rt_task_spawn error %d\n",n); return 1; } rt_task_join(&task); } When I try to start 2 instance of this program with the same session label, the second give me a segmentaion fault: $ sudo ./foo --session=s Erreur de segmentation And this error appears in the kernel logs: foo[11885]: segfault at 3387c25020 ip 00007fee025a73f9 sp 00007ffe2611cbd8 error 4 in libcopperplate.so.0.0.0[7fee0259c000+11000] Code: 00 48 89 f8 48 03 47 18 74 51 4c 8b 4e 20 eb 17 90 44 89 c6 49 89 fa 83 c6 01 4c 03 54 f0 08 4c 89 d6 74 33 48 89 f0 4c 89 ce <48> 2b 70 20 45 31 c0 48 85 f6 41 0f 9f c0 48 c1 ee 3f 41 29 f0 75 I tested it with the kernel 4.19.66 patched with xenomai 3.1-rc1 and the kernel 4.19.75 with the next branch and observed the same issue. I also tried kernel 4.14.134 with xenomai 3.0.9 and it works. So I will stay in this version for the moment. My build : $ /usr/xenomai/bin/xeno-config --info Xenomai version: Xenomai/cobalt v3.1-rc2 Linux XportNew 4.19.75-xenomai-3.1 #2 SMP PREEMPT Wed Oct 23 14:34:21 CEST 2019 x86_64 GNU/Linux Kernel parameters: BOOT_IMAGE=/boot/vmlinuz-4.19.75-xenomai-3.1 root=/dev/mapper/isw_bdaaiafbje_Volume11 ro dmraid=true quiet splash nopat crashkernel=384M-:128M I-pipe release #7 detected Cobalt core 3.1-rc2 detected Compiler: gcc version 4.9.2 (Debian 4.9.2-10+deb8u1) Build args: --with-core=cobalt --enable-smp --enable-pshared regards, Davy -------------- next part -------------- A non-text attachment was scrubbed... Name: config-4.19.75-xenomai-3.1 Type: application/octet-stream Size: 201615 bytes Desc: not available URL: <http://xenomai.org/pipermail/xenomai/attachments/20191024/269f9137/attachment.obj> ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: problem with sessions in xenomai 3.1 2019-10-24 8:41 problem with sessions in xenomai 3.1 davy.regneau @ 2019-10-25 17:05 ` Jan Kiszka 2019-10-26 9:12 ` Philippe Gerum 1 sibling, 0 replies; 13+ messages in thread From: Jan Kiszka @ 2019-10-25 17:05 UTC (permalink / raw) To: davy.regneau, xenomai On 24.10.19 10:41, Davy via Xenomai wrote: > Hi, > > Shared sessions do not seem to work with Xenomai 3.1. > I made this simple code to test it : > > > RT_TASK task; > > void foo(){ > while(1){ > printf("Hello !\n"); > rt_task_sleep(2000000000); > } > } > > int main(int argc, char *argv[]){ > int n; > if (mlockall( MCL_CURRENT | MCL_FUTURE )!=0) > return 1; > if ((n=rt_task_spawn( &task, NULL, 0, 99, T_JOINABLE, &foo, NULL))!=0){ > rt_printf("rt_task_spawn error %d\n",n); > return 1; > } > rt_task_join(&task); > } > > > When I try to start 2 instance of this program with the same session > label, the second give me a segmentaion fault: > $ sudo ./foo --session=s > Erreur de segmentation > > And this error appears in the kernel logs: > foo[11885]: segfault at 3387c25020 ip 00007fee025a73f9 sp 00007ffe2611cbd8 > error 4 in libcopperplate.so.0.0.0[7fee0259c000+11000] > Code: 00 48 89 f8 48 03 47 18 74 51 4c 8b 4e 20 eb 17 90 44 89 c6 49 89 fa > 83 c6 01 4c 03 54 f0 08 4c 89 d6 74 33 48 89 f0 4c 89 ce <48> 2b 70 20 45 > 31 c0 48 85 f6 41 0f 9f c0 48 c1 ee 3f 41 29 f0 75 > > > I tested it with the kernel 4.19.66 patched with xenomai 3.1-rc1 and the > kernel 4.19.75 with the next branch and observed the same issue. > > I also tried kernel 4.14.134 with xenomai 3.0.9 and it works. So I will > stay in this version for the moment. > > > My build : > $ /usr/xenomai/bin/xeno-config --info > Xenomai version: Xenomai/cobalt v3.1-rc2 > Linux XportNew 4.19.75-xenomai-3.1 #2 SMP PREEMPT Wed Oct 23 14:34:21 CEST > 2019 x86_64 GNU/Linux > Kernel parameters: BOOT_IMAGE=/boot/vmlinuz-4.19.75-xenomai-3.1 > root=/dev/mapper/isw_bdaaiafbje_Volume11 ro dmraid=true quiet splash nopat > crashkernel=384M-:128M > I-pipe release #7 detected > Cobalt core 3.1-rc2 detected > Compiler: gcc version 4.9.2 (Debian 4.9.2-10+deb8u1) > Build args: --with-core=cobalt --enable-smp --enable-pshared > Thanks for reporting! I didn't find time to reproduce this so far. Unless someone else is faster with debugging the reason, this may have to wait until after the upcoming conference week in Lyon. Jan -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: problem with sessions in xenomai 3.1 2019-10-24 8:41 problem with sessions in xenomai 3.1 davy.regneau 2019-10-25 17:05 ` Jan Kiszka @ 2019-10-26 9:12 ` Philippe Gerum 2019-11-06 9:18 ` segmentation error when a task ends davy.regneau 1 sibling, 1 reply; 13+ messages in thread From: Philippe Gerum @ 2019-10-26 9:12 UTC (permalink / raw) To: davy.regneau, xenomai On 10/24/19 10:41 AM, Davy via Xenomai wrote: > Hi, > > Shared sessions do not seem to work with Xenomai 3.1. > I made this simple code to test it : > > > RT_TASK task; > > void foo(){ > while(1){ > printf("Hello !\n"); > rt_task_sleep(2000000000); > } > } > > int main(int argc, char *argv[]){ > int n; > if (mlockall( MCL_CURRENT | MCL_FUTURE )!=0) > return 1; > if ((n=rt_task_spawn( &task, NULL, 0, 99, T_JOINABLE, &foo, NULL))!=0){ > rt_printf("rt_task_spawn error %d\n",n); > return 1; > } > rt_task_join(&task); > } > > > When I try to start 2 instance of this program with the same session > label, the second give me a segmentaion fault: > $ sudo ./foo --session=s > Erreur de segmentation > > And this error appears in the kernel logs: > foo[11885]: segfault at 3387c25020 ip 00007fee025a73f9 sp 00007ffe2611cbd8 > error 4 in libcopperplate.so.0.0.0[7fee0259c000+11000] > Code: 00 48 89 f8 48 03 47 18 74 51 4c 8b 4e 20 eb 17 90 44 89 c6 49 89 fa > 83 c6 01 4c 03 54 f0 08 4c 89 d6 74 33 48 89 f0 4c 89 ce <48> 2b 70 20 45 > 31 c0 48 85 f6 41 0f 9f c0 48 c1 ee 3f 41 29 f0 75 > > > I tested it with the kernel 4.19.66 patched with xenomai 3.1-rc1 and the > kernel 4.19.75 with the next branch and observed the same issue. > > I also tried kernel 4.14.134 with xenomai 3.0.9 and it works. So I will > stay in this version for the moment. > > > My build : > $ /usr/xenomai/bin/xeno-config --info > Xenomai version: Xenomai/cobalt v3.1-rc2 > Linux XportNew 4.19.75-xenomai-3.1 #2 SMP PREEMPT Wed Oct 23 14:34:21 CEST > 2019 x86_64 GNU/Linux > Kernel parameters: BOOT_IMAGE=/boot/vmlinuz-4.19.75-xenomai-3.1 > root=/dev/mapper/isw_bdaaiafbje_Volume11 ro dmraid=true quiet splash nopat > crashkernel=384M-:128M > I-pipe release #7 detected > Cobalt core 3.1-rc2 detected > Compiler: gcc version 4.9.2 (Debian 4.9.2-10+deb8u1) > Build args: --with-core=cobalt --enable-smp --enable-pshared > Confirmed. Issue is with the AVL support in pshared mode. -- Philippe. ^ permalink raw reply [flat|nested] 13+ messages in thread
* segmentation error when a task ends 2019-10-26 9:12 ` Philippe Gerum @ 2019-11-06 9:18 ` davy.regneau 2019-11-06 9:28 ` Jan Kiszka 0 siblings, 1 reply; 13+ messages in thread From: davy.regneau @ 2019-11-06 9:18 UTC (permalink / raw) To: xenomai Hi, Thanks for patching the shared sessions. It works. Now I have another segmentation error that appears when a task ends or is deleted : RT_TASK task; void foo(){ int i = 3; while(i--){ printf("Hello !\n"); rt_task_sleep(1000000000); } return; } int main(int argc, char *argv[]){ int n; if (mlockall( MCL_CURRENT | MCL_FUTURE )!=0) return 1; if ((n=rt_task_spawn( &task, NULL, 0, 99, T_JOINABLE, &foo, NULL))!=0){ rt_printf("rt_task_spawn error %d\n",n); return 1; } printf("Join task\n"); rt_task_join(&task); return EXIT_SUCCESS; } $ sudo ./foo Hello ! Join task Hello ! Hello ! Erreur de segmentation regards, Davy ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: segmentation error when a task ends 2019-11-06 9:18 ` segmentation error when a task ends davy.regneau @ 2019-11-06 9:28 ` Jan Kiszka 2019-11-06 13:40 ` davy.regneau 0 siblings, 1 reply; 13+ messages in thread From: Jan Kiszka @ 2019-11-06 9:28 UTC (permalink / raw) To: davy.regneau, xenomai On 06.11.19 10:18, Davy via Xenomai wrote: > > Hi, > > Thanks for patching the shared sessions. It works. > > Now I have another segmentation error that appears when a task ends or is > deleted : > > > > RT_TASK task; > void foo(){ > int i = 3; > while(i--){ > printf("Hello !\n"); > rt_task_sleep(1000000000); > } > return; > } > int main(int argc, char *argv[]){ > int n; > if (mlockall( MCL_CURRENT | MCL_FUTURE )!=0) > return 1; > if ((n=rt_task_spawn( &task, NULL, 0, 99, T_JOINABLE, &foo, NULL))!=0){ > rt_printf("rt_task_spawn error %d\n",n); > return 1; > } > printf("Join task\n"); > rt_task_join(&task); > return EXIT_SUCCESS; > } > > > $ sudo ./foo > Hello ! > Join task > Hello ! > Hello ! > Erreur de segmentation > Works find here. Could you use a debugger to find out where the exception is thrown? Jan -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: segmentation error when a task ends 2019-11-06 9:28 ` Jan Kiszka @ 2019-11-06 13:40 ` davy.regneau 2019-11-06 13:50 ` Jan Kiszka 0 siblings, 1 reply; 13+ messages in thread From: davy.regneau @ 2019-11-06 13:40 UTC (permalink / raw) To: Jan Kiszka; +Cc: xenomai > On 06.11.19 10:18, Davy via Xenomai wrote: >> >> Hi, >> >> Thanks for patching the shared sessions. It works. >> >> Now I have another segmentation error that appears when a task ends or >> is >> deleted : >> >> >> >> RT_TASK task; >> void foo(){ >> int i = 3; >> while(i--){ >> printf("Hello !\n"); >> rt_task_sleep(1000000000); >> } >> return; >> } >> int main(int argc, char *argv[]){ >> int n; >> if (mlockall( MCL_CURRENT | MCL_FUTURE )!=0) >> return 1; >> if ((n=rt_task_spawn( &task, NULL, 0, 99, T_JOINABLE, &foo, NULL))!=0){ >> rt_printf("rt_task_spawn error %d\n",n); >> return 1; >> } >> printf("Join task\n"); >> rt_task_join(&task); >> return EXIT_SUCCESS; >> } >> >> >> $ sudo ./foo >> Hello ! >> Join task >> Hello ! >> Hello ! >> Erreur de segmentation >> > > Works find here. Could you use a debugger to find out where the > exception is thrown? > I obtain this : (gdb) run Starting program: /home/davy/Documents/Programmes_Test/test/foo [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". [New Thread 0x7ffff6db1700 (LWP 14620)] [New Thread 0x7ffff7ff6700 (LWP 14621)] Hello ! Join task 0"025.863| WARNING: [main] Xenomai compiled with full debug enabled, very high latencies expected [--enable-debug=full] Hello ! Hello ! Thread 3 "task@1[14616]" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7ffff7ff6700 (LWP 14621)] 0x00007ffff7799cf5 in shavlh_link (avl=0x7ffff7e47148, holder=0x0, dir=0) at ../../include/boilerplate/avl-inner.h:107 107 ptrdiff_t offset = holder->link[avl_type2index(dir)].offset; ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: segmentation error when a task ends 2019-11-06 13:40 ` davy.regneau @ 2019-11-06 13:50 ` Jan Kiszka 2019-11-06 14:23 ` davy.regneau 0 siblings, 1 reply; 13+ messages in thread From: Jan Kiszka @ 2019-11-06 13:50 UTC (permalink / raw) To: davy.regneau; +Cc: xenomai, Philippe Gerum On 06.11.19 14:40, davy.regneau@univ-grenoble-alpes.fr wrote: >> On 06.11.19 10:18, Davy via Xenomai wrote: >>> >>> Hi, >>> >>> Thanks for patching the shared sessions. It works. >>> >>> Now I have another segmentation error that appears when a task ends or >>> is >>> deleted : >>> >>> >>> >>> RT_TASK task; >>> void foo(){ >>> int i = 3; >>> while(i--){ >>> printf("Hello !\n"); >>> rt_task_sleep(1000000000); >>> } >>> return; >>> } >>> int main(int argc, char *argv[]){ >>> int n; >>> if (mlockall( MCL_CURRENT | MCL_FUTURE )!=0) >>> return 1; >>> if ((n=rt_task_spawn( &task, NULL, 0, 99, T_JOINABLE, &foo, NULL))!=0){ >>> rt_printf("rt_task_spawn error %d\n",n); >>> return 1; >>> } >>> printf("Join task\n"); >>> rt_task_join(&task); >>> return EXIT_SUCCESS; >>> } >>> >>> >>> $ sudo ./foo >>> Hello ! >>> Join task >>> Hello ! >>> Hello ! >>> Erreur de segmentation >>> >> >> Works find here. Could you use a debugger to find out where the >> exception is thrown? >> > > I obtain this : > > (gdb) run > Starting program: /home/davy/Documents/Programmes_Test/test/foo > [Thread debugging using libthread_db enabled] > Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". > [New Thread 0x7ffff6db1700 (LWP 14620)] > [New Thread 0x7ffff7ff6700 (LWP 14621)] > Hello ! > Join task > 0"025.863| WARNING: [main] Xenomai compiled with full debug enabled, > very high latencies expected > [--enable-debug=full] > Hello ! > Hello ! > > Thread 3 "task@1[14616]" received signal SIGSEGV, Segmentation fault. > [Switching to Thread 0x7ffff7ff6700 (LWP 14621)] > 0x00007ffff7799cf5 in shavlh_link (avl=0x7ffff7e47148, holder=0x0, dir=0) > at ../../include/boilerplate/avl-inner.h:107 > 107 ptrdiff_t offset = holder->link[avl_type2index(dir)].offset; > Backtrace? Values of the vars in question? How did you configure Xenomai userspace (beyond --enable-debug=full)? Philippe, any idea? Jan -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: segmentation error when a task ends 2019-11-06 13:50 ` Jan Kiszka @ 2019-11-06 14:23 ` davy.regneau 2019-11-06 14:40 ` Jan Kiszka 0 siblings, 1 reply; 13+ messages in thread From: davy.regneau @ 2019-11-06 14:23 UTC (permalink / raw) To: Jan Kiszka; +Cc: xenomai, Philippe Gerum > On 06.11.19 14:40, davy.regneau@univ-grenoble-alpes.fr wrote: >>> On 06.11.19 10:18, Davy via Xenomai wrote: >>>> >>>> Hi, >>>> >>>> Thanks for patching the shared sessions. It works. >>>> >>>> Now I have another segmentation error that appears when a task ends or >>>> is >>>> deleted : >>>> >>>> >>>> >>>> RT_TASK task; >>>> void foo(){ >>>> int i = 3; >>>> while(i--){ >>>> printf("Hello !\n"); >>>> rt_task_sleep(1000000000); >>>> } >>>> return; >>>> } >>>> int main(int argc, char *argv[]){ >>>> int n; >>>> if (mlockall( MCL_CURRENT | MCL_FUTURE )!=0) >>>> return 1; >>>> if ((n=rt_task_spawn( &task, NULL, 0, 99, T_JOINABLE, &foo, >>>> NULL))!=0){ >>>> rt_printf("rt_task_spawn error %d\n",n); >>>> return 1; >>>> } >>>> printf("Join task\n"); >>>> rt_task_join(&task); >>>> return EXIT_SUCCESS; >>>> } >>>> >>>> >>>> $ sudo ./foo >>>> Hello ! >>>> Join task >>>> Hello ! >>>> Hello ! >>>> Erreur de segmentation >>>> >>> >>> Works find here. Could you use a debugger to find out where the >>> exception is thrown? >>> >> >> I obtain this : >> >> (gdb) run >> Starting program: /home/davy/Documents/Programmes_Test/test/foo >> [Thread debugging using libthread_db enabled] >> Using host libthread_db library >> "/lib/x86_64-linux-gnu/libthread_db.so.1". >> [New Thread 0x7ffff6db1700 (LWP 14620)] >> [New Thread 0x7ffff7ff6700 (LWP 14621)] >> Hello ! >> Join task >> 0"025.863| WARNING: [main] Xenomai compiled with full debug enabled, >> very high latencies expected >> [--enable-debug=full] >> Hello ! >> Hello ! >> >> Thread 3 "task@1[14616]" received signal SIGSEGV, Segmentation fault. >> [Switching to Thread 0x7ffff7ff6700 (LWP 14621)] >> 0x00007ffff7799cf5 in shavlh_link (avl=0x7ffff7e47148, holder=0x0, >> dir=0) >> at ../../include/boilerplate/avl-inner.h:107 >> 107 ptrdiff_t offset = holder->link[avl_type2index(dir)].offset; >> > > Backtrace? Values of the vars in question? (gdb) backtrace #0 0x00007ffff7799cf5 in shavlh_link (avl=0x7ffff7e47148, holder=0x0, dir=0) at ../../include/boilerplate/avl-inner.h:107 #1 0x00007ffff7799fa7 in shavl_inorder (avl=0x7ffff7e47148, holder=0x0, dir=1) at avl.c:55 #2 0x00007ffff79b89a5 in shavl_next (avl=0x7ffff7e47148, holder=0x7ffff7e4d1c8) at ../../include/boilerplate/avl-inner.h:332 #3 0x00007ffff79b8fe5 in find_next_neighbour (ext=0x7ffff7e47128, r=0x7ffff7e4d1c8) at heapobj-pshared.c:276 #4 0x00007ffff79b90e0 in release_page_range (ext=0x7ffff7e47128, page=0x7ffff7f425c8, size=1024) at heapobj-pshared.c:303 #5 0x00007ffff79b9f84 in sheapmem_free (heap=0x7ffff7e46000, block=0x7ffff7f425c8) at heapobj-pshared.c:594 #6 0x00007ffff79bbb40 in xnfree (ptr=0x7ffff7f425c8) at heapobj-pshared.c:1203 #7 0x00007ffff79b46a5 in __threadobj_free (p=0x7ffff7f425c8) at ../../include/copperplate/threadobj.h:312 #8 0x00007ffff79b46d4 in threadobj_free (thobj=0x7ffff7f426d0) at ../../include/copperplate/threadobj.h:317 #9 0x00007ffff79b64d4 in finalize_thread (p=0x7ffff7f426d0) at threadobj.c:1548 #10 0x00007ffff735f5f9 in __nptl_deallocate_tsd () at pthread_create.c:291 #11 0x00007ffff7360658 in __nptl_deallocate_tsd () at pthread_create.c:449 #12 start_thread (arg=0x7ffff7ff6700) at pthread_create.c:469 #13 0x00007ffff6e9ad0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97 > > How did you configure Xenomai userspace (beyond --enable-debug=full)? $ /usr/xenomai/bin/xeno-config --info Xenomai version: Xenomai/cobalt v3.1-rc3 Linux XportNew 4.19.75-xenomai-3.1-rc3 #3 SMP PREEMPT Wed Nov 6 13:48:28 CET 2019 x86_64 GNU/Linux Kernel parameters: BOOT_IMAGE=/boot/vmlinuz-4.19.75-xenomai-3.1-rc3 root=/dev/mapper/isw_bdaaiafbje_Volume11 ro dmraid=true quiet splash nopat crashkernel=384M-:128M I-pipe release #7 detected Cobalt core 3.1-rc3 detected Compiler: gcc version 4.9.2 (Debian 4.9.2-10+deb8u1) Build args: --with-core=cobalt --enable-smp --enable-pshared --enable-debug=full > > Philippe, any idea? > > Jan > > -- > Siemens AG, Corporate Technology, CT RDA IOT SES-DE > Corporate Competence Center Embedded Linux > ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: segmentation error when a task ends 2019-11-06 14:23 ` davy.regneau @ 2019-11-06 14:40 ` Jan Kiszka 2019-11-07 10:12 ` davy.regneau 0 siblings, 1 reply; 13+ messages in thread From: Jan Kiszka @ 2019-11-06 14:40 UTC (permalink / raw) To: davy.regneau, Philippe Gerum; +Cc: xenomai On 06.11.19 15:23, davy.regneau@univ-grenoble-alpes.fr wrote: >> On 06.11.19 14:40, davy.regneau@univ-grenoble-alpes.fr wrote: >>>> On 06.11.19 10:18, Davy via Xenomai wrote: >>>>> >>>>> Hi, >>>>> >>>>> Thanks for patching the shared sessions. It works. >>>>> >>>>> Now I have another segmentation error that appears when a task ends or >>>>> is >>>>> deleted : >>>>> >>>>> >>>>> >>>>> RT_TASK task; >>>>> void foo(){ >>>>> int i = 3; >>>>> while(i--){ >>>>> printf("Hello !\n"); >>>>> rt_task_sleep(1000000000); >>>>> } >>>>> return; >>>>> } >>>>> int main(int argc, char *argv[]){ >>>>> int n; >>>>> if (mlockall( MCL_CURRENT | MCL_FUTURE )!=0) >>>>> return 1; >>>>> if ((n=rt_task_spawn( &task, NULL, 0, 99, T_JOINABLE, &foo, >>>>> NULL))!=0){ >>>>> rt_printf("rt_task_spawn error %d\n",n); >>>>> return 1; >>>>> } >>>>> printf("Join task\n"); >>>>> rt_task_join(&task); >>>>> return EXIT_SUCCESS; >>>>> } >>>>> >>>>> >>>>> $ sudo ./foo >>>>> Hello ! >>>>> Join task >>>>> Hello ! >>>>> Hello ! >>>>> Erreur de segmentation >>>>> >>>> >>>> Works find here. Could you use a debugger to find out where the >>>> exception is thrown? >>>> >>> >>> I obtain this : >>> >>> (gdb) run >>> Starting program: /home/davy/Documents/Programmes_Test/test/foo >>> [Thread debugging using libthread_db enabled] >>> Using host libthread_db library >>> "/lib/x86_64-linux-gnu/libthread_db.so.1". >>> [New Thread 0x7ffff6db1700 (LWP 14620)] >>> [New Thread 0x7ffff7ff6700 (LWP 14621)] >>> Hello ! >>> Join task >>> 0"025.863| WARNING: [main] Xenomai compiled with full debug enabled, >>> very high latencies expected >>> [--enable-debug=full] >>> Hello ! >>> Hello ! >>> >>> Thread 3 "task@1[14616]" received signal SIGSEGV, Segmentation fault. >>> [Switching to Thread 0x7ffff7ff6700 (LWP 14621)] >>> 0x00007ffff7799cf5 in shavlh_link (avl=0x7ffff7e47148, holder=0x0, >>> dir=0) >>> at ../../include/boilerplate/avl-inner.h:107 >>> 107 ptrdiff_t offset = holder->link[avl_type2index(dir)].offset; >>> >> >> Backtrace? Values of the vars in question? > > (gdb) backtrace > #0 0x00007ffff7799cf5 in shavlh_link (avl=0x7ffff7e47148, holder=0x0, > dir=0) at ../../include/boilerplate/avl-inner.h:107 > #1 0x00007ffff7799fa7 in shavl_inorder (avl=0x7ffff7e47148, holder=0x0, > dir=1) at avl.c:55 > #2 0x00007ffff79b89a5 in shavl_next (avl=0x7ffff7e47148, > holder=0x7ffff7e4d1c8) at ../../include/boilerplate/avl-inner.h:332 > #3 0x00007ffff79b8fe5 in find_next_neighbour (ext=0x7ffff7e47128, > r=0x7ffff7e4d1c8) at heapobj-pshared.c:276 > #4 0x00007ffff79b90e0 in release_page_range (ext=0x7ffff7e47128, > page=0x7ffff7f425c8, size=1024) at heapobj-pshared.c:303 > #5 0x00007ffff79b9f84 in sheapmem_free (heap=0x7ffff7e46000, > block=0x7ffff7f425c8) at heapobj-pshared.c:594 > #6 0x00007ffff79bbb40 in xnfree (ptr=0x7ffff7f425c8) at > heapobj-pshared.c:1203 > #7 0x00007ffff79b46a5 in __threadobj_free (p=0x7ffff7f425c8) at > ../../include/copperplate/threadobj.h:312 > #8 0x00007ffff79b46d4 in threadobj_free (thobj=0x7ffff7f426d0) at > ../../include/copperplate/threadobj.h:317 > #9 0x00007ffff79b64d4 in finalize_thread (p=0x7ffff7f426d0) at > threadobj.c:1548 > #10 0x00007ffff735f5f9 in __nptl_deallocate_tsd () at pthread_create.c:291 > #11 0x00007ffff7360658 in __nptl_deallocate_tsd () at pthread_create.c:449 > #12 start_thread (arg=0x7ffff7ff6700) at pthread_create.c:469 > #13 0x00007ffff6e9ad0f in clone () at > ../sysdeps/unix/sysv/linux/x86_64/clone.S:97 > >> >> How did you configure Xenomai userspace (beyond --enable-debug=full)? > > $ /usr/xenomai/bin/xeno-config --info > Xenomai version: Xenomai/cobalt v3.1-rc3 > Linux XportNew 4.19.75-xenomai-3.1-rc3 #3 SMP PREEMPT Wed Nov 6 13:48:28 > CET 2019 x86_64 GNU/Linux > Kernel parameters: BOOT_IMAGE=/boot/vmlinuz-4.19.75-xenomai-3.1-rc3 > root=/dev/mapper/isw_bdaaiafbje_Volume11 ro dmraid=true quiet splash nopat > crashkernel=384M-:128M > I-pipe release #7 detected > Cobalt core 3.1-rc3 detected > Compiler: gcc version 4.9.2 (Debian 4.9.2-10+deb8u1) > Build args: --with-core=cobalt --enable-smp --enable-pshared > --enable-debug=full > This is resolving the crash: diff --git a/lib/boilerplate/avl.c b/lib/boilerplate/avl.c index 3bf9bf1345..c13ec8a940 100644 --- a/lib/boilerplate/avl.c +++ b/lib/boilerplate/avl.c @@ -53,7 +53,7 @@ struct __AVL_T (avlh) * __AVL(inorder)(const struct __AVL_T(avl) * const avl, } else { for (;;) { next = __AVLH(up)(avl, holder); - if (next == __AVL(anchor)(avl)) + if (!next || next == __AVL(anchor)(avl)) return NULL; if (holder->type != dir) break; But I don't feel like we have a stable setup since 1a79c31c9f8. There could very well be further cases that now break under the new NULL return value. Philippe, please double check all affected code paths. Jan -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: segmentation error when a task ends 2019-11-06 14:40 ` Jan Kiszka @ 2019-11-07 10:12 ` davy.regneau 2019-11-10 17:25 ` Philippe Gerum 0 siblings, 1 reply; 13+ messages in thread From: davy.regneau @ 2019-11-07 10:12 UTC (permalink / raw) To: Jan Kiszka; +Cc: Philippe Gerum, xenomai > On 06.11.19 15:23, davy.regneau@univ-grenoble-alpes.fr wrote: >>> On 06.11.19 14:40, davy.regneau@univ-grenoble-alpes.fr wrote: >>>>> On 06.11.19 10:18, Davy via Xenomai wrote: >>>>>> >>>>>> Hi, >>>>>> >>>>>> Thanks for patching the shared sessions. It works. >>>>>> >>>>>> Now I have another segmentation error that appears when a task ends >>>>>> or >>>>>> is >>>>>> deleted : >>>>>> >>>>>> >>>>>> >>>>>> RT_TASK task; >>>>>> void foo(){ >>>>>> int i = 3; >>>>>> while(i--){ >>>>>> printf("Hello !\n"); >>>>>> rt_task_sleep(1000000000); >>>>>> } >>>>>> return; >>>>>> } >>>>>> int main(int argc, char *argv[]){ >>>>>> int n; >>>>>> if (mlockall( MCL_CURRENT | MCL_FUTURE )!=0) >>>>>> return 1; >>>>>> if ((n=rt_task_spawn( &task, NULL, 0, 99, T_JOINABLE, &foo, >>>>>> NULL))!=0){ >>>>>> rt_printf("rt_task_spawn error %d\n",n); >>>>>> return 1; >>>>>> } >>>>>> printf("Join task\n"); >>>>>> rt_task_join(&task); >>>>>> return EXIT_SUCCESS; >>>>>> } >>>>>> >>>>>> >>>>>> $ sudo ./foo >>>>>> Hello ! >>>>>> Join task >>>>>> Hello ! >>>>>> Hello ! >>>>>> Erreur de segmentation >>>>>> >>>>> >>>>> Works find here. Could you use a debugger to find out where the >>>>> exception is thrown? >>>>> >>>> >>>> I obtain this : >>>> >>>> (gdb) run >>>> Starting program: /home/davy/Documents/Programmes_Test/test/foo >>>> [Thread debugging using libthread_db enabled] >>>> Using host libthread_db library >>>> "/lib/x86_64-linux-gnu/libthread_db.so.1". >>>> [New Thread 0x7ffff6db1700 (LWP 14620)] >>>> [New Thread 0x7ffff7ff6700 (LWP 14621)] >>>> Hello ! >>>> Join task >>>> 0"025.863| WARNING: [main] Xenomai compiled with full debug >>>> enabled, >>>> very high latencies expected >>>> [--enable-debug=full] >>>> Hello ! >>>> Hello ! >>>> >>>> Thread 3 "task@1[14616]" received signal SIGSEGV, Segmentation fault. >>>> [Switching to Thread 0x7ffff7ff6700 (LWP 14621)] >>>> 0x00007ffff7799cf5 in shavlh_link (avl=0x7ffff7e47148, holder=0x0, >>>> dir=0) >>>> at ../../include/boilerplate/avl-inner.h:107 >>>> 107 ptrdiff_t offset = holder->link[avl_type2index(dir)].offset; >>>> >>> >>> Backtrace? Values of the vars in question? >> >> (gdb) backtrace >> #0 0x00007ffff7799cf5 in shavlh_link (avl=0x7ffff7e47148, holder=0x0, >> dir=0) at ../../include/boilerplate/avl-inner.h:107 >> #1 0x00007ffff7799fa7 in shavl_inorder (avl=0x7ffff7e47148, holder=0x0, >> dir=1) at avl.c:55 >> #2 0x00007ffff79b89a5 in shavl_next (avl=0x7ffff7e47148, >> holder=0x7ffff7e4d1c8) at ../../include/boilerplate/avl-inner.h:332 >> #3 0x00007ffff79b8fe5 in find_next_neighbour (ext=0x7ffff7e47128, >> r=0x7ffff7e4d1c8) at heapobj-pshared.c:276 >> #4 0x00007ffff79b90e0 in release_page_range (ext=0x7ffff7e47128, >> page=0x7ffff7f425c8, size=1024) at heapobj-pshared.c:303 >> #5 0x00007ffff79b9f84 in sheapmem_free (heap=0x7ffff7e46000, >> block=0x7ffff7f425c8) at heapobj-pshared.c:594 >> #6 0x00007ffff79bbb40 in xnfree (ptr=0x7ffff7f425c8) at >> heapobj-pshared.c:1203 >> #7 0x00007ffff79b46a5 in __threadobj_free (p=0x7ffff7f425c8) at >> ../../include/copperplate/threadobj.h:312 >> #8 0x00007ffff79b46d4 in threadobj_free (thobj=0x7ffff7f426d0) at >> ../../include/copperplate/threadobj.h:317 >> #9 0x00007ffff79b64d4 in finalize_thread (p=0x7ffff7f426d0) at >> threadobj.c:1548 >> #10 0x00007ffff735f5f9 in __nptl_deallocate_tsd () at >> pthread_create.c:291 >> #11 0x00007ffff7360658 in __nptl_deallocate_tsd () at >> pthread_create.c:449 >> #12 start_thread (arg=0x7ffff7ff6700) at pthread_create.c:469 >> #13 0x00007ffff6e9ad0f in clone () at >> ../sysdeps/unix/sysv/linux/x86_64/clone.S:97 >> >>> >>> How did you configure Xenomai userspace (beyond --enable-debug=full)? >> >> $ /usr/xenomai/bin/xeno-config --info >> Xenomai version: Xenomai/cobalt v3.1-rc3 >> Linux XportNew 4.19.75-xenomai-3.1-rc3 #3 SMP PREEMPT Wed Nov 6 13:48:28 >> CET 2019 x86_64 GNU/Linux >> Kernel parameters: BOOT_IMAGE=/boot/vmlinuz-4.19.75-xenomai-3.1-rc3 >> root=/dev/mapper/isw_bdaaiafbje_Volume11 ro dmraid=true quiet splash >> nopat >> crashkernel=384M-:128M >> I-pipe release #7 detected >> Cobalt core 3.1-rc3 detected >> Compiler: gcc version 4.9.2 (Debian 4.9.2-10+deb8u1) >> Build args: --with-core=cobalt --enable-smp --enable-pshared >> --enable-debug=full >> > > This is resolving the crash: > > diff --git a/lib/boilerplate/avl.c b/lib/boilerplate/avl.c > index 3bf9bf1345..c13ec8a940 100644 > --- a/lib/boilerplate/avl.c > +++ b/lib/boilerplate/avl.c > @@ -53,7 +53,7 @@ struct __AVL_T (avlh) * __AVL(inorder)(const struct > __AVL_T(avl) * const avl, > } else { > for (;;) { > next = __AVLH(up)(avl, holder); > - if (next == __AVL(anchor)(avl)) > + if (!next || next == __AVL(anchor)(avl)) > return NULL; > if (holder->type != dir) > break; > > But I don't feel like we have a stable setup since 1a79c31c9f8. There > could very well be further cases that now break under the new NULL > return value. > > Philippe, please double check all affected code paths. > > Jan > > -- > Siemens AG, Corporate Technology, CT RDA IOT SES-DE > Corporate Competence Center Embedded Linux > Hi, I still get an error if I call rt_task_join() after rt_task_delete() (like recomended in documentation) or if I try to delete another task. I ran this program with debugger : void foo(){ while(1){ printf("task 1 !\n"); rt_task_sleep(1000000000); } return; } void bar(){ while(1){ printf("task 2 !\n"); rt_task_sleep(1000000000); } } int main(int argc, char *argv[]){ int n; if (mlockall( MCL_CURRENT | MCL_FUTURE )!=0) return 1; if ((n=rt_task_spawn( &task, NULL, 0, 99, 0, &foo, NULL))!=0){ rt_printf("rt_task_spawn error %d\n",n); return 1; } if ((n=rt_task_spawn( &task2, NULL, 0, 99, 0, &bar, NULL))!=0){ rt_printf("rt_task_spawn error %d\n",n); return 1; } rt_task_sleep(2000000000); printf("Delete task 1\n"); rt_task_delete(&task); // printf("Join task 1\n"); // rt_task_join(&task); printf("Delete task 2\n"); rt_task_delete(&task2); return EXIT_SUCCESS; } (gdb) run Starting program: /home/davy/Documents/Programmes_Test/test/foo [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". [New Thread 0x7ffff6db1700 (LWP 32383)] [New Thread 0x7ffff7ff6700 (LWP 32384)] task 1 ! [New Thread 0x7ffff7fe5700 (LWP 32385)] task 2 ! 0"025.641| WARNING: [main] Xenomai compiled with full debug enabled, very high latencies expected [--enable-debug=full] task 1 ! task 2 ! task 1 ! task 2 ! Delete task 1 Delete task 2 Thread 3 "task@1[32379]" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7ffff7ff6700 (LWP 32384)] 0x00007ffff779a684 in avlh_balance_add (avl=0x7ffff7e47148, holder=0x0, delta=1) at avl.c:267 267 if (holder->balance == delta) (gdb) backtrace #0 0x00007ffff779a684 in avlh_balance_add (avl=0x7ffff7e47148, holder=0x0, delta=1) at avl.c:267 #1 0x00007ffff779ab11 in avl_insert_inner (avl=0x7ffff7e47148, parent=0x0, node=0x7ffff7f425c8, side=1) at avl.c:388 #2 0x00007ffff779aeda in shavl_insert (avl=0x7ffff7e47148, holder=0x7ffff7f425c8, ops=0x7ffff7bc27c0 <addr_search_ops>) at avl.c:502 #3 0x00007ffff79b91d1 in release_page_range (ext=0x7ffff7e47128, page=0x7ffff7f425c8, size=1024) at heapobj-pshared.c:318 #4 0x00007ffff79b9f84 in sheapmem_free (heap=0x7ffff7e46000, block=0x7ffff7f425c8) at heapobj-pshared.c:594 #5 0x00007ffff79bbb40 in xnfree (ptr=0x7ffff7f425c8) at heapobj-pshared.c:1203 #6 0x00007ffff79b46a5 in __threadobj_free (p=0x7ffff7f425c8) at ../../include/copperplate/threadobj.h:312 #7 0x00007ffff79b46d4 in threadobj_free (thobj=0x7ffff7f426d0) at ../../include/copperplate/threadobj.h:317 #8 0x00007ffff79b64d4 in finalize_thread (p=0x7ffff7f426d0) at threadobj.c:1548 #9 0x00007ffff735f5f9 in __nptl_deallocate_tsd () at pthread_create.c:291 #10 0x00007ffff7360658 in __nptl_deallocate_tsd () at pthread_create.c:449 #11 start_thread (arg=0x7ffff7ff6700) at pthread_create.c:469 #12 0x00007ffff6e9ad0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97 regards, Davy ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: segmentation error when a task ends 2019-11-07 10:12 ` davy.regneau @ 2019-11-10 17:25 ` Philippe Gerum 2019-11-13 13:48 ` Jan Kiszka 0 siblings, 1 reply; 13+ messages in thread From: Philippe Gerum @ 2019-11-10 17:25 UTC (permalink / raw) To: davy.regneau, Jan Kiszka; +Cc: xenomai On 11/7/19 11:12 AM, davy.regneau@univ-grenoble-alpes.fr wrote: >> On 06.11.19 15:23, davy.regneau@univ-grenoble-alpes.fr wrote: >>>> On 06.11.19 14:40, davy.regneau@univ-grenoble-alpes.fr wrote: >>>>>> On 06.11.19 10:18, Davy via Xenomai wrote: >>>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> Thanks for patching the shared sessions. It works. >>>>>>> >>>>>>> Now I have another segmentation error that appears when a task ends >>>>>>> or >>>>>>> is >>>>>>> deleted : >>>>>>> >>>>>>> >>>>>>> >>>>>>> RT_TASK task; >>>>>>> void foo(){ >>>>>>> int i = 3; >>>>>>> while(i--){ >>>>>>> printf("Hello !\n"); >>>>>>> rt_task_sleep(1000000000); >>>>>>> } >>>>>>> return; >>>>>>> } >>>>>>> int main(int argc, char *argv[]){ >>>>>>> int n; >>>>>>> if (mlockall( MCL_CURRENT | MCL_FUTURE )!=0) >>>>>>> return 1; >>>>>>> if ((n=rt_task_spawn( &task, NULL, 0, 99, T_JOINABLE, &foo, >>>>>>> NULL))!=0){ >>>>>>> rt_printf("rt_task_spawn error %d\n",n); >>>>>>> return 1; >>>>>>> } >>>>>>> printf("Join task\n"); >>>>>>> rt_task_join(&task); >>>>>>> return EXIT_SUCCESS; >>>>>>> } >>>>>>> >>>>>>> >>>>>>> $ sudo ./foo >>>>>>> Hello ! >>>>>>> Join task >>>>>>> Hello ! >>>>>>> Hello ! >>>>>>> Erreur de segmentation >>>>>>> >>>>>> >>>>>> Works find here. Could you use a debugger to find out where the >>>>>> exception is thrown? >>>>>> >>>>> >>>>> I obtain this : >>>>> >>>>> (gdb) run >>>>> Starting program: /home/davy/Documents/Programmes_Test/test/foo >>>>> [Thread debugging using libthread_db enabled] >>>>> Using host libthread_db library >>>>> "/lib/x86_64-linux-gnu/libthread_db.so.1". >>>>> [New Thread 0x7ffff6db1700 (LWP 14620)] >>>>> [New Thread 0x7ffff7ff6700 (LWP 14621)] >>>>> Hello ! >>>>> Join task >>>>> 0"025.863| WARNING: [main] Xenomai compiled with full debug >>>>> enabled, >>>>> very high latencies expected >>>>> [--enable-debug=full] >>>>> Hello ! >>>>> Hello ! >>>>> >>>>> Thread 3 "task@1[14616]" received signal SIGSEGV, Segmentation fault. >>>>> [Switching to Thread 0x7ffff7ff6700 (LWP 14621)] >>>>> 0x00007ffff7799cf5 in shavlh_link (avl=0x7ffff7e47148, holder=0x0, >>>>> dir=0) >>>>> at ../../include/boilerplate/avl-inner.h:107 >>>>> 107 ptrdiff_t offset = holder->link[avl_type2index(dir)].offset; >>>>> >>>> >>>> Backtrace? Values of the vars in question? >>> >>> (gdb) backtrace >>> #0 0x00007ffff7799cf5 in shavlh_link (avl=0x7ffff7e47148, holder=0x0, >>> dir=0) at ../../include/boilerplate/avl-inner.h:107 >>> #1 0x00007ffff7799fa7 in shavl_inorder (avl=0x7ffff7e47148, holder=0x0, >>> dir=1) at avl.c:55 >>> #2 0x00007ffff79b89a5 in shavl_next (avl=0x7ffff7e47148, >>> holder=0x7ffff7e4d1c8) at ../../include/boilerplate/avl-inner.h:332 >>> #3 0x00007ffff79b8fe5 in find_next_neighbour (ext=0x7ffff7e47128, >>> r=0x7ffff7e4d1c8) at heapobj-pshared.c:276 >>> #4 0x00007ffff79b90e0 in release_page_range (ext=0x7ffff7e47128, >>> page=0x7ffff7f425c8, size=1024) at heapobj-pshared.c:303 >>> #5 0x00007ffff79b9f84 in sheapmem_free (heap=0x7ffff7e46000, >>> block=0x7ffff7f425c8) at heapobj-pshared.c:594 >>> #6 0x00007ffff79bbb40 in xnfree (ptr=0x7ffff7f425c8) at >>> heapobj-pshared.c:1203 >>> #7 0x00007ffff79b46a5 in __threadobj_free (p=0x7ffff7f425c8) at >>> ../../include/copperplate/threadobj.h:312 >>> #8 0x00007ffff79b46d4 in threadobj_free (thobj=0x7ffff7f426d0) at >>> ../../include/copperplate/threadobj.h:317 >>> #9 0x00007ffff79b64d4 in finalize_thread (p=0x7ffff7f426d0) at >>> threadobj.c:1548 >>> #10 0x00007ffff735f5f9 in __nptl_deallocate_tsd () at >>> pthread_create.c:291 >>> #11 0x00007ffff7360658 in __nptl_deallocate_tsd () at >>> pthread_create.c:449 >>> #12 start_thread (arg=0x7ffff7ff6700) at pthread_create.c:469 >>> #13 0x00007ffff6e9ad0f in clone () at >>> ../sysdeps/unix/sysv/linux/x86_64/clone.S:97 >>> >>>> >>>> How did you configure Xenomai userspace (beyond --enable-debug=full)? >>> >>> $ /usr/xenomai/bin/xeno-config --info >>> Xenomai version: Xenomai/cobalt v3.1-rc3 >>> Linux XportNew 4.19.75-xenomai-3.1-rc3 #3 SMP PREEMPT Wed Nov 6 13:48:28 >>> CET 2019 x86_64 GNU/Linux >>> Kernel parameters: BOOT_IMAGE=/boot/vmlinuz-4.19.75-xenomai-3.1-rc3 >>> root=/dev/mapper/isw_bdaaiafbje_Volume11 ro dmraid=true quiet splash >>> nopat >>> crashkernel=384M-:128M >>> I-pipe release #7 detected >>> Cobalt core 3.1-rc3 detected >>> Compiler: gcc version 4.9.2 (Debian 4.9.2-10+deb8u1) >>> Build args: --with-core=cobalt --enable-smp --enable-pshared >>> --enable-debug=full >>> >> >> This is resolving the crash: >> >> diff --git a/lib/boilerplate/avl.c b/lib/boilerplate/avl.c >> index 3bf9bf1345..c13ec8a940 100644 >> --- a/lib/boilerplate/avl.c >> +++ b/lib/boilerplate/avl.c >> @@ -53,7 +53,7 @@ struct __AVL_T (avlh) * __AVL(inorder)(const struct >> __AVL_T(avl) * const avl, >> } else { >> for (;;) { >> next = __AVLH(up)(avl, holder); >> - if (next == __AVL(anchor)(avl)) >> + if (!next || next == __AVL(anchor)(avl)) >> return NULL; >> if (holder->type != dir) >> break; >> >> But I don't feel like we have a stable setup since 1a79c31c9f8. There >> could very well be further cases that now break under the new NULL >> return value. >> >> Philippe, please double check all affected code paths. >> >> Jan >> >> -- >> Siemens AG, Corporate Technology, CT RDA IOT SES-DE >> Corporate Competence Center Embedded Linux >> > > > Hi, > > I still get an error if I call rt_task_join() after rt_task_delete() (like > recomended in documentation) or if I try to delete another task. > > I ran this program with debugger : > > void foo(){ > while(1){ > printf("task 1 !\n"); > rt_task_sleep(1000000000); > } > return; > } > void bar(){ > while(1){ > printf("task 2 !\n"); > rt_task_sleep(1000000000); > } > } > int main(int argc, char *argv[]){ > int n; > if (mlockall( MCL_CURRENT | MCL_FUTURE )!=0) > return 1; > if ((n=rt_task_spawn( &task, NULL, 0, 99, 0, &foo, NULL))!=0){ > rt_printf("rt_task_spawn error %d\n",n); > return 1; > } > if ((n=rt_task_spawn( &task2, NULL, 0, 99, 0, &bar, NULL))!=0){ > rt_printf("rt_task_spawn error %d\n",n); > return 1; > } > rt_task_sleep(2000000000); > printf("Delete task 1\n"); > rt_task_delete(&task); > // printf("Join task 1\n"); > // rt_task_join(&task); > printf("Delete task 2\n"); > rt_task_delete(&task2); > return EXIT_SUCCESS; > } > > > (gdb) run > Starting program: /home/davy/Documents/Programmes_Test/test/foo > [Thread debugging using libthread_db enabled] > Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". > [New Thread 0x7ffff6db1700 (LWP 32383)] > [New Thread 0x7ffff7ff6700 (LWP 32384)] > task 1 ! > [New Thread 0x7ffff7fe5700 (LWP 32385)] > task 2 ! > 0"025.641| WARNING: [main] Xenomai compiled with full debug enabled, > very high latencies expected > [--enable-debug=full] > task 1 ! > task 2 ! > task 1 ! > task 2 ! > Delete task 1 > Delete task 2 > > Thread 3 "task@1[32379]" received signal SIGSEGV, Segmentation fault. > [Switching to Thread 0x7ffff7ff6700 (LWP 32384)] > 0x00007ffff779a684 in avlh_balance_add (avl=0x7ffff7e47148, holder=0x0, > delta=1) at avl.c:267 > 267 if (holder->balance == delta) > (gdb) backtrace > #0 0x00007ffff779a684 in avlh_balance_add (avl=0x7ffff7e47148, > holder=0x0, delta=1) at avl.c:267 > #1 0x00007ffff779ab11 in avl_insert_inner (avl=0x7ffff7e47148, > parent=0x0, node=0x7ffff7f425c8, side=1) at avl.c:388 > #2 0x00007ffff779aeda in shavl_insert (avl=0x7ffff7e47148, > holder=0x7ffff7f425c8, ops=0x7ffff7bc27c0 <addr_search_ops>) at avl.c:502 > #3 0x00007ffff79b91d1 in release_page_range (ext=0x7ffff7e47128, > page=0x7ffff7f425c8, size=1024) at heapobj-pshared.c:318 > #4 0x00007ffff79b9f84 in sheapmem_free (heap=0x7ffff7e46000, > block=0x7ffff7f425c8) at heapobj-pshared.c:594 > #5 0x00007ffff79bbb40 in xnfree (ptr=0x7ffff7f425c8) at > heapobj-pshared.c:1203 > #6 0x00007ffff79b46a5 in __threadobj_free (p=0x7ffff7f425c8) at > ../../include/copperplate/threadobj.h:312 > #7 0x00007ffff79b46d4 in threadobj_free (thobj=0x7ffff7f426d0) at > ../../include/copperplate/threadobj.h:317 > #8 0x00007ffff79b64d4 in finalize_thread (p=0x7ffff7f426d0) at > threadobj.c:1548 > #9 0x00007ffff735f5f9 in __nptl_deallocate_tsd () at pthread_create.c:291 > #10 0x00007ffff7360658 in __nptl_deallocate_tsd () at pthread_create.c:449 > #11 start_thread (arg=0x7ffff7ff6700) at pthread_create.c:469 > #12 0x00007ffff6e9ad0f in clone () at > ../sysdeps/unix/sysv/linux/x86_64/clone.S:97 > > The previous patch was half-baked. Please apply this one on top; the alchemy test suite, smokey's pshared test and a couple more are now happy with that change, but anything you can add will help. Feedback appreciated since this issue is a release blocker. TIA, diff --git a/include/boilerplate/avl-inner.h b/include/boilerplate/avl-inner.h index 8e4de8487..9c0576213 100644 --- a/include/boilerplate/avl-inner.h +++ b/include/boilerplate/avl-inner.h @@ -105,14 +105,14 @@ shavlh_link(const struct shavl *const avl, const struct shavlh *const holder, unsigned int dir) { ptrdiff_t offset = holder->link[avl_type2index(dir)].offset; - return offset ? (void *)avl + offset : NULL; + return offset == (ptrdiff_t)-1 ? NULL : (void *)avl + offset; } static inline void shavlh_set_link(struct shavl *const avl, struct shavlh *lhs, int dir, struct shavlh *rhs) { - ptrdiff_t offset = rhs ? (void *)rhs - (void *)avl : 0; + ptrdiff_t offset = rhs ? (void *)rhs - (void *)avl : (ptrdiff_t)-1; lhs->link[avl_type2index(dir)].offset = offset; } @@ -120,13 +120,13 @@ static inline struct shavlh *shavl_end(const struct shavl *const avl, int dir) { ptrdiff_t offset = avl->end[avl_type2index(dir)].offset; - return offset ? (void *)avl + offset : NULL; + return offset == (ptrdiff_t)-1 ? NULL : (void *)avl + offset; } static inline void shavl_set_end(struct shavl *const avl, int dir, struct shavlh *holder) { - ptrdiff_t offset = holder ? (void *)holder - (void *)avl : 0; + ptrdiff_t offset = holder ? (void *)holder - (void *)avl : (ptrdiff_t)-1; avl->end[avl_type2index(dir)].offset = offset; } -- Philippe. ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: segmentation error when a task ends 2019-11-10 17:25 ` Philippe Gerum @ 2019-11-13 13:48 ` Jan Kiszka 2019-11-17 11:49 ` Philippe Gerum 0 siblings, 1 reply; 13+ messages in thread From: Jan Kiszka @ 2019-11-13 13:48 UTC (permalink / raw) To: Philippe Gerum, davy.regneau; +Cc: xenomai On 10.11.19 18:25, Philippe Gerum wrote: > On 11/7/19 11:12 AM, davy.regneau@univ-grenoble-alpes.fr wrote: >>> On 06.11.19 15:23, davy.regneau@univ-grenoble-alpes.fr wrote: >>>>> On 06.11.19 14:40, davy.regneau@univ-grenoble-alpes.fr wrote: >>>>>>> On 06.11.19 10:18, Davy via Xenomai wrote: >>>>>>>> >>>>>>>> Hi, >>>>>>>> >>>>>>>> Thanks for patching the shared sessions. It works. >>>>>>>> >>>>>>>> Now I have another segmentation error that appears when a task ends >>>>>>>> or >>>>>>>> is >>>>>>>> deleted : >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> RT_TASK task; >>>>>>>> void foo(){ >>>>>>>> int i = 3; >>>>>>>> while(i--){ >>>>>>>> printf("Hello !\n"); >>>>>>>> rt_task_sleep(1000000000); >>>>>>>> } >>>>>>>> return; >>>>>>>> } >>>>>>>> int main(int argc, char *argv[]){ >>>>>>>> int n; >>>>>>>> if (mlockall( MCL_CURRENT | MCL_FUTURE )!=0) >>>>>>>> return 1; >>>>>>>> if ((n=rt_task_spawn( &task, NULL, 0, 99, T_JOINABLE, &foo, >>>>>>>> NULL))!=0){ >>>>>>>> rt_printf("rt_task_spawn error %d\n",n); >>>>>>>> return 1; >>>>>>>> } >>>>>>>> printf("Join task\n"); >>>>>>>> rt_task_join(&task); >>>>>>>> return EXIT_SUCCESS; >>>>>>>> } >>>>>>>> >>>>>>>> >>>>>>>> $ sudo ./foo >>>>>>>> Hello ! >>>>>>>> Join task >>>>>>>> Hello ! >>>>>>>> Hello ! >>>>>>>> Erreur de segmentation >>>>>>>> >>>>>>> >>>>>>> Works find here. Could you use a debugger to find out where the >>>>>>> exception is thrown? >>>>>>> >>>>>> >>>>>> I obtain this : >>>>>> >>>>>> (gdb) run >>>>>> Starting program: /home/davy/Documents/Programmes_Test/test/foo >>>>>> [Thread debugging using libthread_db enabled] >>>>>> Using host libthread_db library >>>>>> "/lib/x86_64-linux-gnu/libthread_db.so.1". >>>>>> [New Thread 0x7ffff6db1700 (LWP 14620)] >>>>>> [New Thread 0x7ffff7ff6700 (LWP 14621)] >>>>>> Hello ! >>>>>> Join task >>>>>> 0"025.863| WARNING: [main] Xenomai compiled with full debug >>>>>> enabled, >>>>>> very high latencies expected >>>>>> [--enable-debug=full] >>>>>> Hello ! >>>>>> Hello ! >>>>>> >>>>>> Thread 3 "task@1[14616]" received signal SIGSEGV, Segmentation fault. >>>>>> [Switching to Thread 0x7ffff7ff6700 (LWP 14621)] >>>>>> 0x00007ffff7799cf5 in shavlh_link (avl=0x7ffff7e47148, holder=0x0, >>>>>> dir=0) >>>>>> at ../../include/boilerplate/avl-inner.h:107 >>>>>> 107 ptrdiff_t offset = holder->link[avl_type2index(dir)].offset; >>>>>> >>>>> >>>>> Backtrace? Values of the vars in question? >>>> >>>> (gdb) backtrace >>>> #0 0x00007ffff7799cf5 in shavlh_link (avl=0x7ffff7e47148, holder=0x0, >>>> dir=0) at ../../include/boilerplate/avl-inner.h:107 >>>> #1 0x00007ffff7799fa7 in shavl_inorder (avl=0x7ffff7e47148, holder=0x0, >>>> dir=1) at avl.c:55 >>>> #2 0x00007ffff79b89a5 in shavl_next (avl=0x7ffff7e47148, >>>> holder=0x7ffff7e4d1c8) at ../../include/boilerplate/avl-inner.h:332 >>>> #3 0x00007ffff79b8fe5 in find_next_neighbour (ext=0x7ffff7e47128, >>>> r=0x7ffff7e4d1c8) at heapobj-pshared.c:276 >>>> #4 0x00007ffff79b90e0 in release_page_range (ext=0x7ffff7e47128, >>>> page=0x7ffff7f425c8, size=1024) at heapobj-pshared.c:303 >>>> #5 0x00007ffff79b9f84 in sheapmem_free (heap=0x7ffff7e46000, >>>> block=0x7ffff7f425c8) at heapobj-pshared.c:594 >>>> #6 0x00007ffff79bbb40 in xnfree (ptr=0x7ffff7f425c8) at >>>> heapobj-pshared.c:1203 >>>> #7 0x00007ffff79b46a5 in __threadobj_free (p=0x7ffff7f425c8) at >>>> ../../include/copperplate/threadobj.h:312 >>>> #8 0x00007ffff79b46d4 in threadobj_free (thobj=0x7ffff7f426d0) at >>>> ../../include/copperplate/threadobj.h:317 >>>> #9 0x00007ffff79b64d4 in finalize_thread (p=0x7ffff7f426d0) at >>>> threadobj.c:1548 >>>> #10 0x00007ffff735f5f9 in __nptl_deallocate_tsd () at >>>> pthread_create.c:291 >>>> #11 0x00007ffff7360658 in __nptl_deallocate_tsd () at >>>> pthread_create.c:449 >>>> #12 start_thread (arg=0x7ffff7ff6700) at pthread_create.c:469 >>>> #13 0x00007ffff6e9ad0f in clone () at >>>> ../sysdeps/unix/sysv/linux/x86_64/clone.S:97 >>>> >>>>> >>>>> How did you configure Xenomai userspace (beyond --enable-debug=full)? >>>> >>>> $ /usr/xenomai/bin/xeno-config --info >>>> Xenomai version: Xenomai/cobalt v3.1-rc3 >>>> Linux XportNew 4.19.75-xenomai-3.1-rc3 #3 SMP PREEMPT Wed Nov 6 13:48:28 >>>> CET 2019 x86_64 GNU/Linux >>>> Kernel parameters: BOOT_IMAGE=/boot/vmlinuz-4.19.75-xenomai-3.1-rc3 >>>> root=/dev/mapper/isw_bdaaiafbje_Volume11 ro dmraid=true quiet splash >>>> nopat >>>> crashkernel=384M-:128M >>>> I-pipe release #7 detected >>>> Cobalt core 3.1-rc3 detected >>>> Compiler: gcc version 4.9.2 (Debian 4.9.2-10+deb8u1) >>>> Build args: --with-core=cobalt --enable-smp --enable-pshared >>>> --enable-debug=full >>>> >>> >>> This is resolving the crash: >>> >>> diff --git a/lib/boilerplate/avl.c b/lib/boilerplate/avl.c >>> index 3bf9bf1345..c13ec8a940 100644 >>> --- a/lib/boilerplate/avl.c >>> +++ b/lib/boilerplate/avl.c >>> @@ -53,7 +53,7 @@ struct __AVL_T (avlh) * __AVL(inorder)(const struct >>> __AVL_T(avl) * const avl, >>> } else { >>> for (;;) { >>> next = __AVLH(up)(avl, holder); >>> - if (next == __AVL(anchor)(avl)) >>> + if (!next || next == __AVL(anchor)(avl)) >>> return NULL; >>> if (holder->type != dir) >>> break; >>> >>> But I don't feel like we have a stable setup since 1a79c31c9f8. There >>> could very well be further cases that now break under the new NULL >>> return value. >>> >>> Philippe, please double check all affected code paths. >>> >>> Jan >>> >>> -- >>> Siemens AG, Corporate Technology, CT RDA IOT SES-DE >>> Corporate Competence Center Embedded Linux >>> >> >> >> Hi, >> >> I still get an error if I call rt_task_join() after rt_task_delete() (like >> recomended in documentation) or if I try to delete another task. >> >> I ran this program with debugger : >> >> void foo(){ >> while(1){ >> printf("task 1 !\n"); >> rt_task_sleep(1000000000); >> } >> return; >> } >> void bar(){ >> while(1){ >> printf("task 2 !\n"); >> rt_task_sleep(1000000000); >> } >> } >> int main(int argc, char *argv[]){ >> int n; >> if (mlockall( MCL_CURRENT | MCL_FUTURE )!=0) >> return 1; >> if ((n=rt_task_spawn( &task, NULL, 0, 99, 0, &foo, NULL))!=0){ >> rt_printf("rt_task_spawn error %d\n",n); >> return 1; >> } >> if ((n=rt_task_spawn( &task2, NULL, 0, 99, 0, &bar, NULL))!=0){ >> rt_printf("rt_task_spawn error %d\n",n); >> return 1; >> } >> rt_task_sleep(2000000000); >> printf("Delete task 1\n"); >> rt_task_delete(&task); >> // printf("Join task 1\n"); >> // rt_task_join(&task); >> printf("Delete task 2\n"); >> rt_task_delete(&task2); >> return EXIT_SUCCESS; >> } >> >> >> (gdb) run >> Starting program: /home/davy/Documents/Programmes_Test/test/foo >> [Thread debugging using libthread_db enabled] >> Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". >> [New Thread 0x7ffff6db1700 (LWP 32383)] >> [New Thread 0x7ffff7ff6700 (LWP 32384)] >> task 1 ! >> [New Thread 0x7ffff7fe5700 (LWP 32385)] >> task 2 ! >> 0"025.641| WARNING: [main] Xenomai compiled with full debug enabled, >> very high latencies expected >> [--enable-debug=full] >> task 1 ! >> task 2 ! >> task 1 ! >> task 2 ! >> Delete task 1 >> Delete task 2 >> >> Thread 3 "task@1[32379]" received signal SIGSEGV, Segmentation fault. >> [Switching to Thread 0x7ffff7ff6700 (LWP 32384)] >> 0x00007ffff779a684 in avlh_balance_add (avl=0x7ffff7e47148, holder=0x0, >> delta=1) at avl.c:267 >> 267 if (holder->balance == delta) >> (gdb) backtrace >> #0 0x00007ffff779a684 in avlh_balance_add (avl=0x7ffff7e47148, >> holder=0x0, delta=1) at avl.c:267 >> #1 0x00007ffff779ab11 in avl_insert_inner (avl=0x7ffff7e47148, >> parent=0x0, node=0x7ffff7f425c8, side=1) at avl.c:388 >> #2 0x00007ffff779aeda in shavl_insert (avl=0x7ffff7e47148, >> holder=0x7ffff7f425c8, ops=0x7ffff7bc27c0 <addr_search_ops>) at avl.c:502 >> #3 0x00007ffff79b91d1 in release_page_range (ext=0x7ffff7e47128, >> page=0x7ffff7f425c8, size=1024) at heapobj-pshared.c:318 >> #4 0x00007ffff79b9f84 in sheapmem_free (heap=0x7ffff7e46000, >> block=0x7ffff7f425c8) at heapobj-pshared.c:594 >> #5 0x00007ffff79bbb40 in xnfree (ptr=0x7ffff7f425c8) at >> heapobj-pshared.c:1203 >> #6 0x00007ffff79b46a5 in __threadobj_free (p=0x7ffff7f425c8) at >> ../../include/copperplate/threadobj.h:312 >> #7 0x00007ffff79b46d4 in threadobj_free (thobj=0x7ffff7f426d0) at >> ../../include/copperplate/threadobj.h:317 >> #8 0x00007ffff79b64d4 in finalize_thread (p=0x7ffff7f426d0) at >> threadobj.c:1548 >> #9 0x00007ffff735f5f9 in __nptl_deallocate_tsd () at pthread_create.c:291 >> #10 0x00007ffff7360658 in __nptl_deallocate_tsd () at pthread_create.c:449 >> #11 start_thread (arg=0x7ffff7ff6700) at pthread_create.c:469 >> #12 0x00007ffff6e9ad0f in clone () at >> ../sysdeps/unix/sysv/linux/x86_64/clone.S:97 >> >> > > The previous patch was half-baked. Please apply this one on top; the alchemy test suite, smokey's pshared test and a couple more are now happy with that change, but anything you can add will help. Feedback appreciated since this issue is a release blocker. TIA, > > diff --git a/include/boilerplate/avl-inner.h b/include/boilerplate/avl-inner.h > index 8e4de8487..9c0576213 100644 > --- a/include/boilerplate/avl-inner.h > +++ b/include/boilerplate/avl-inner.h > @@ -105,14 +105,14 @@ shavlh_link(const struct shavl *const avl, > const struct shavlh *const holder, unsigned int dir) > { > ptrdiff_t offset = holder->link[avl_type2index(dir)].offset; > - return offset ? (void *)avl + offset : NULL; > + return offset == (ptrdiff_t)-1 ? NULL : (void *)avl + offset; > } > > static inline void > shavlh_set_link(struct shavl *const avl, struct shavlh *lhs, > int dir, struct shavlh *rhs) > { > - ptrdiff_t offset = rhs ? (void *)rhs - (void *)avl : 0; > + ptrdiff_t offset = rhs ? (void *)rhs - (void *)avl : (ptrdiff_t)-1; > lhs->link[avl_type2index(dir)].offset = offset; > } > > @@ -120,13 +120,13 @@ static inline > struct shavlh *shavl_end(const struct shavl *const avl, int dir) > { > ptrdiff_t offset = avl->end[avl_type2index(dir)].offset; > - return offset ? (void *)avl + offset : NULL; > + return offset == (ptrdiff_t)-1 ? NULL : (void *)avl + offset; > } > > static inline void > shavl_set_end(struct shavl *const avl, int dir, struct shavlh *holder) > { > - ptrdiff_t offset = holder ? (void *)holder - (void *)avl : 0; > + ptrdiff_t offset = holder ? (void *)holder - (void *)avl : (ptrdiff_t)-1; > avl->end[avl_type2index(dir)].offset = offset; > } > > Davy, were you able to test meanwhile? Philippe, could you send out a regular patch already? Thanks, Jan -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: segmentation error when a task ends 2019-11-13 13:48 ` Jan Kiszka @ 2019-11-17 11:49 ` Philippe Gerum 0 siblings, 0 replies; 13+ messages in thread From: Philippe Gerum @ 2019-11-17 11:49 UTC (permalink / raw) To: Jan Kiszka, davy.regneau; +Cc: xenomai On 11/13/19 2:48 PM, Jan Kiszka wrote: > On 10.11.19 18:25, Philippe Gerum wrote: >> On 11/7/19 11:12 AM, davy.regneau@univ-grenoble-alpes.fr wrote: >>>> On 06.11.19 15:23, davy.regneau@univ-grenoble-alpes.fr wrote: >>>>>> On 06.11.19 14:40, davy.regneau@univ-grenoble-alpes.fr wrote: >>>>>>>> On 06.11.19 10:18, Davy via Xenomai wrote: >>>>>>>>> >>>>>>>>> Hi, >>>>>>>>> >>>>>>>>> Thanks for patching the shared sessions. It works. >>>>>>>>> >>>>>>>>> Now I have another segmentation error that appears when a task ends >>>>>>>>> or >>>>>>>>> is >>>>>>>>> deleted : >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> RT_TASK task; >>>>>>>>> void foo(){ >>>>>>>>> int i = 3; >>>>>>>>> while(i--){ >>>>>>>>> printf("Hello !\n"); >>>>>>>>> rt_task_sleep(1000000000); >>>>>>>>> } >>>>>>>>> return; >>>>>>>>> } >>>>>>>>> int main(int argc, char *argv[]){ >>>>>>>>> int n; >>>>>>>>> if (mlockall( MCL_CURRENT | MCL_FUTURE )!=0) >>>>>>>>> return 1; >>>>>>>>> if ((n=rt_task_spawn( &task, NULL, 0, 99, T_JOINABLE, &foo, >>>>>>>>> NULL))!=0){ >>>>>>>>> rt_printf("rt_task_spawn error %d\n",n); >>>>>>>>> return 1; >>>>>>>>> } >>>>>>>>> printf("Join task\n"); >>>>>>>>> rt_task_join(&task); >>>>>>>>> return EXIT_SUCCESS; >>>>>>>>> } >>>>>>>>> >>>>>>>>> >>>>>>>>> $ sudo ./foo >>>>>>>>> Hello ! >>>>>>>>> Join task >>>>>>>>> Hello ! >>>>>>>>> Hello ! >>>>>>>>> Erreur de segmentation >>>>>>>>> >>>>>>>> >>>>>>>> Works find here. Could you use a debugger to find out where the >>>>>>>> exception is thrown? >>>>>>>> >>>>>>> >>>>>>> I obtain this : >>>>>>> >>>>>>> (gdb) run >>>>>>> Starting program: /home/davy/Documents/Programmes_Test/test/foo >>>>>>> [Thread debugging using libthread_db enabled] >>>>>>> Using host libthread_db library >>>>>>> "/lib/x86_64-linux-gnu/libthread_db.so.1". >>>>>>> [New Thread 0x7ffff6db1700 (LWP 14620)] >>>>>>> [New Thread 0x7ffff7ff6700 (LWP 14621)] >>>>>>> Hello ! >>>>>>> Join task >>>>>>> 0"025.863| WARNING: [main] Xenomai compiled with full debug >>>>>>> enabled, >>>>>>> very high latencies expected >>>>>>> [--enable-debug=full] >>>>>>> Hello ! >>>>>>> Hello ! >>>>>>> >>>>>>> Thread 3 "task@1[14616]" received signal SIGSEGV, Segmentation fault. >>>>>>> [Switching to Thread 0x7ffff7ff6700 (LWP 14621)] >>>>>>> 0x00007ffff7799cf5 in shavlh_link (avl=0x7ffff7e47148, holder=0x0, >>>>>>> dir=0) >>>>>>> at ../../include/boilerplate/avl-inner.h:107 >>>>>>> 107 ptrdiff_t offset = holder->link[avl_type2index(dir)].offset; >>>>>>> >>>>>> >>>>>> Backtrace? Values of the vars in question? >>>>> >>>>> (gdb) backtrace >>>>> #0 0x00007ffff7799cf5 in shavlh_link (avl=0x7ffff7e47148, holder=0x0, >>>>> dir=0) at ../../include/boilerplate/avl-inner.h:107 >>>>> #1 0x00007ffff7799fa7 in shavl_inorder (avl=0x7ffff7e47148, holder=0x0, >>>>> dir=1) at avl.c:55 >>>>> #2 0x00007ffff79b89a5 in shavl_next (avl=0x7ffff7e47148, >>>>> holder=0x7ffff7e4d1c8) at ../../include/boilerplate/avl-inner.h:332 >>>>> #3 0x00007ffff79b8fe5 in find_next_neighbour (ext=0x7ffff7e47128, >>>>> r=0x7ffff7e4d1c8) at heapobj-pshared.c:276 >>>>> #4 0x00007ffff79b90e0 in release_page_range (ext=0x7ffff7e47128, >>>>> page=0x7ffff7f425c8, size=1024) at heapobj-pshared.c:303 >>>>> #5 0x00007ffff79b9f84 in sheapmem_free (heap=0x7ffff7e46000, >>>>> block=0x7ffff7f425c8) at heapobj-pshared.c:594 >>>>> #6 0x00007ffff79bbb40 in xnfree (ptr=0x7ffff7f425c8) at >>>>> heapobj-pshared.c:1203 >>>>> #7 0x00007ffff79b46a5 in __threadobj_free (p=0x7ffff7f425c8) at >>>>> ../../include/copperplate/threadobj.h:312 >>>>> #8 0x00007ffff79b46d4 in threadobj_free (thobj=0x7ffff7f426d0) at >>>>> ../../include/copperplate/threadobj.h:317 >>>>> #9 0x00007ffff79b64d4 in finalize_thread (p=0x7ffff7f426d0) at >>>>> threadobj.c:1548 >>>>> #10 0x00007ffff735f5f9 in __nptl_deallocate_tsd () at >>>>> pthread_create.c:291 >>>>> #11 0x00007ffff7360658 in __nptl_deallocate_tsd () at >>>>> pthread_create.c:449 >>>>> #12 start_thread (arg=0x7ffff7ff6700) at pthread_create.c:469 >>>>> #13 0x00007ffff6e9ad0f in clone () at >>>>> ../sysdeps/unix/sysv/linux/x86_64/clone.S:97 >>>>> >>>>>> >>>>>> How did you configure Xenomai userspace (beyond --enable-debug=full)? >>>>> >>>>> $ /usr/xenomai/bin/xeno-config --info >>>>> Xenomai version: Xenomai/cobalt v3.1-rc3 >>>>> Linux XportNew 4.19.75-xenomai-3.1-rc3 #3 SMP PREEMPT Wed Nov 6 13:48:28 >>>>> CET 2019 x86_64 GNU/Linux >>>>> Kernel parameters: BOOT_IMAGE=/boot/vmlinuz-4.19.75-xenomai-3.1-rc3 >>>>> root=/dev/mapper/isw_bdaaiafbje_Volume11 ro dmraid=true quiet splash >>>>> nopat >>>>> crashkernel=384M-:128M >>>>> I-pipe release #7 detected >>>>> Cobalt core 3.1-rc3 detected >>>>> Compiler: gcc version 4.9.2 (Debian 4.9.2-10+deb8u1) >>>>> Build args: --with-core=cobalt --enable-smp --enable-pshared >>>>> --enable-debug=full >>>>> >>>> >>>> This is resolving the crash: >>>> >>>> diff --git a/lib/boilerplate/avl.c b/lib/boilerplate/avl.c >>>> index 3bf9bf1345..c13ec8a940 100644 >>>> --- a/lib/boilerplate/avl.c >>>> +++ b/lib/boilerplate/avl.c >>>> @@ -53,7 +53,7 @@ struct __AVL_T (avlh) * __AVL(inorder)(const struct >>>> __AVL_T(avl) * const avl, >>>> } else { >>>> for (;;) { >>>> next = __AVLH(up)(avl, holder); >>>> - if (next == __AVL(anchor)(avl)) >>>> + if (!next || next == __AVL(anchor)(avl)) >>>> return NULL; >>>> if (holder->type != dir) >>>> break; >>>> >>>> But I don't feel like we have a stable setup since 1a79c31c9f8. There >>>> could very well be further cases that now break under the new NULL >>>> return value. >>>> >>>> Philippe, please double check all affected code paths. >>>> >>>> Jan >>>> >>>> -- >>>> Siemens AG, Corporate Technology, CT RDA IOT SES-DE >>>> Corporate Competence Center Embedded Linux >>>> >>> >>> >>> Hi, >>> >>> I still get an error if I call rt_task_join() after rt_task_delete() (like >>> recomended in documentation) or if I try to delete another task. >>> >>> I ran this program with debugger : >>> >>> void foo(){ >>> while(1){ >>> printf("task 1 !\n"); >>> rt_task_sleep(1000000000); >>> } >>> return; >>> } >>> void bar(){ >>> while(1){ >>> printf("task 2 !\n"); >>> rt_task_sleep(1000000000); >>> } >>> } >>> int main(int argc, char *argv[]){ >>> int n; >>> if (mlockall( MCL_CURRENT | MCL_FUTURE )!=0) >>> return 1; >>> if ((n=rt_task_spawn( &task, NULL, 0, 99, 0, &foo, NULL))!=0){ >>> rt_printf("rt_task_spawn error %d\n",n); >>> return 1; >>> } >>> if ((n=rt_task_spawn( &task2, NULL, 0, 99, 0, &bar, NULL))!=0){ >>> rt_printf("rt_task_spawn error %d\n",n); >>> return 1; >>> } >>> rt_task_sleep(2000000000); >>> printf("Delete task 1\n"); >>> rt_task_delete(&task); >>> // printf("Join task 1\n"); >>> // rt_task_join(&task); >>> printf("Delete task 2\n"); >>> rt_task_delete(&task2); >>> return EXIT_SUCCESS; >>> } >>> >>> >>> (gdb) run >>> Starting program: /home/davy/Documents/Programmes_Test/test/foo >>> [Thread debugging using libthread_db enabled] >>> Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". >>> [New Thread 0x7ffff6db1700 (LWP 32383)] >>> [New Thread 0x7ffff7ff6700 (LWP 32384)] >>> task 1 ! >>> [New Thread 0x7ffff7fe5700 (LWP 32385)] >>> task 2 ! >>> 0"025.641| WARNING: [main] Xenomai compiled with full debug enabled, >>> very high latencies expected >>> [--enable-debug=full] >>> task 1 ! >>> task 2 ! >>> task 1 ! >>> task 2 ! >>> Delete task 1 >>> Delete task 2 >>> >>> Thread 3 "task@1[32379]" received signal SIGSEGV, Segmentation fault. >>> [Switching to Thread 0x7ffff7ff6700 (LWP 32384)] >>> 0x00007ffff779a684 in avlh_balance_add (avl=0x7ffff7e47148, holder=0x0, >>> delta=1) at avl.c:267 >>> 267 if (holder->balance == delta) >>> (gdb) backtrace >>> #0 0x00007ffff779a684 in avlh_balance_add (avl=0x7ffff7e47148, >>> holder=0x0, delta=1) at avl.c:267 >>> #1 0x00007ffff779ab11 in avl_insert_inner (avl=0x7ffff7e47148, >>> parent=0x0, node=0x7ffff7f425c8, side=1) at avl.c:388 >>> #2 0x00007ffff779aeda in shavl_insert (avl=0x7ffff7e47148, >>> holder=0x7ffff7f425c8, ops=0x7ffff7bc27c0 <addr_search_ops>) at avl.c:502 >>> #3 0x00007ffff79b91d1 in release_page_range (ext=0x7ffff7e47128, >>> page=0x7ffff7f425c8, size=1024) at heapobj-pshared.c:318 >>> #4 0x00007ffff79b9f84 in sheapmem_free (heap=0x7ffff7e46000, >>> block=0x7ffff7f425c8) at heapobj-pshared.c:594 >>> #5 0x00007ffff79bbb40 in xnfree (ptr=0x7ffff7f425c8) at >>> heapobj-pshared.c:1203 >>> #6 0x00007ffff79b46a5 in __threadobj_free (p=0x7ffff7f425c8) at >>> ../../include/copperplate/threadobj.h:312 >>> #7 0x00007ffff79b46d4 in threadobj_free (thobj=0x7ffff7f426d0) at >>> ../../include/copperplate/threadobj.h:317 >>> #8 0x00007ffff79b64d4 in finalize_thread (p=0x7ffff7f426d0) at >>> threadobj.c:1548 >>> #9 0x00007ffff735f5f9 in __nptl_deallocate_tsd () at pthread_create.c:291 >>> #10 0x00007ffff7360658 in __nptl_deallocate_tsd () at pthread_create.c:449 >>> #11 start_thread (arg=0x7ffff7ff6700) at pthread_create.c:469 >>> #12 0x00007ffff6e9ad0f in clone () at >>> ../sysdeps/unix/sysv/linux/x86_64/clone.S:97 >>> >>> >> >> The previous patch was half-baked. Please apply this one on top; the alchemy test suite, smokey's pshared test and a couple more are now happy with that change, but anything you can add will help. Feedback appreciated since this issue is a release blocker. TIA, >> >> diff --git a/include/boilerplate/avl-inner.h b/include/boilerplate/avl-inner.h >> index 8e4de8487..9c0576213 100644 >> --- a/include/boilerplate/avl-inner.h >> +++ b/include/boilerplate/avl-inner.h >> @@ -105,14 +105,14 @@ shavlh_link(const struct shavl *const avl, >> const struct shavlh *const holder, unsigned int dir) >> { >> ptrdiff_t offset = holder->link[avl_type2index(dir)].offset; >> - return offset ? (void *)avl + offset : NULL; >> + return offset == (ptrdiff_t)-1 ? NULL : (void *)avl + offset; >> } >> static inline void >> shavlh_set_link(struct shavl *const avl, struct shavlh *lhs, >> int dir, struct shavlh *rhs) >> { >> - ptrdiff_t offset = rhs ? (void *)rhs - (void *)avl : 0; >> + ptrdiff_t offset = rhs ? (void *)rhs - (void *)avl : (ptrdiff_t)-1; >> lhs->link[avl_type2index(dir)].offset = offset; >> } >> @@ -120,13 +120,13 @@ static inline >> struct shavlh *shavl_end(const struct shavl *const avl, int dir) >> { >> ptrdiff_t offset = avl->end[avl_type2index(dir)].offset; >> - return offset ? (void *)avl + offset : NULL; >> + return offset == (ptrdiff_t)-1 ? NULL : (void *)avl + offset; >> } >> static inline void >> shavl_set_end(struct shavl *const avl, int dir, struct shavlh *holder) >> { >> - ptrdiff_t offset = holder ? (void *)holder - (void *)avl : 0; >> + ptrdiff_t offset = holder ? (void *)holder - (void *)avl : (ptrdiff_t)-1; >> avl->end[avl_type2index(dir)].offset = offset; >> } >> > > Davy, were you able to test meanwhile? > > Philippe, could you send out a regular patch already? > Ok, done. This has been tested here, but no feedback from interested parties, so it looks like we may assume that absolutely nobody depends on copperplate's pshared mode for their application. In this case, we might not care about having this fix in for 3.1, or maybe we do, whatever fits, I guess. -- Philippe. ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2019-11-17 11:49 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-10-24 8:41 problem with sessions in xenomai 3.1 davy.regneau 2019-10-25 17:05 ` Jan Kiszka 2019-10-26 9:12 ` Philippe Gerum 2019-11-06 9:18 ` segmentation error when a task ends davy.regneau 2019-11-06 9:28 ` Jan Kiszka 2019-11-06 13:40 ` davy.regneau 2019-11-06 13:50 ` Jan Kiszka 2019-11-06 14:23 ` davy.regneau 2019-11-06 14:40 ` Jan Kiszka 2019-11-07 10:12 ` davy.regneau 2019-11-10 17:25 ` Philippe Gerum 2019-11-13 13:48 ` Jan Kiszka 2019-11-17 11:49 ` Philippe Gerum
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.