rt_heap_alloc size 0 - syscall 7 denied
Hallo,
I'm using xenomai 3.0 on kernel 3.18.20 (64 bit).
When using single block heap, I'm getting memory allocation problem when calling rt_heap_alloc with size 0. I don't get the error when calling the function with size used in rt_heap_create. On the mailing list, I found there has been an issue with this in May : http://www.xenomai.org/pipermail/xenomai/2015-May/034165.html
Is this still an issue ?
In attachment a test program htest.c + makefile to generate the problem :
$ sudo ./htest 1 ==> use 0 htest.c:69: heapsize = 70000, usablemem = 70144, usedmem = 0 htest.c:79 ERROR: rt_heap_alloc(-12): Cannot allocate memory
$ sudo ./htest 1 ==> use same size as in create htest.c:69: heapsize = 70000, usablemem = 70144, usedmem = 0 htest.c:92: heapsize = 70000, usablemem = 70144, usedmem = 70144
However, I both cases, I get a trace in dmesg :
[Xenomai] syscall <7> denied to sysregd
I have no idea why I'm getting this trace. Does anybody has a suggestion ? I found that this error is printed probably in ./kernel/cobalt/posix/syscall.c
If I'm right, syscall 7 would be sc_cobalt_thread_setschedparam_ex (cfr. ./doc/prebuilt/html/xeno3prm/include_2cobalt_2uapi_2syscall_8h_source.html) I still have other problems which I'm looking at, so maybe they have the same cause.
This is the content of the registry when allocation succeeds :
/var/run/xenomai# find .
.
./root
./root/anon@21808
./root/anon@21808/21808 ./root/anon@21808/21808/alchemy ./root/anon@21808/21808/alchemy/heaps ./root/anon@21808/21808/alchemy/heaps/TESTHEAP ./root/anon@21808/system ./root/anon@21808/system/threads ./root/anon@21808/system/heaps ./root/anon@21808/system/version
# xeno-config --info Xenomai version: Xenomai/cobalt v3.0 -- Linux dev1 3.18.20-x86-64-xeno-3.03p.0.0 #1 SMP PREEMPT Tue Oct 13 16:58:44 CEST 2015 x86_64 GNU/Linux Kernel parameters: BOOT_IMAGE=/vmlinuz-3.18.20-x86-64-xeno-3.03p.0.0 root=UUID=20f2dd2f-f02f-4b82-8538-8fe52e55a8ff ro quiet I-pipe release #3 detected Cobalt core 3.0 detected Compiler: gcc version 4.9.2 (Debian 4.9.2-10) Build args: --prefix=/usr --includedir=/usr/include/xenomai --mandir=/usr/share/man --with-testdir=/usr/lib/xenomai/testsuite --with-core=cobalt --enable-smp --enable-pshared --enable-registry --build x86_64-linux-gnu build_alias=x86_64-linux-gnu
I have also attached the kernel config.
Kind regards,
Frederik
-------------- next part --------------
A non-text attachment was scrubbed...
Name: config-3.18.20-x86-64-xeno-3.03p.0.0
Type: application/octet-stream
Size: 128070 bytes
Desc: not available
URL: <http://xenomai.org/pipermail/xenomai/attachments/20151014/7024f00c/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: htest.c
Type: text/x-csrc
Size: 2268 bytes
Desc: not available
URL: <http://xenomai.org/pipermail/xenomai/attachments/20151014/7024f00c/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: makefile
Type: application/octet-stream
Size: 622 bytes
Desc: not available
URL: <http://xenomai.org/pipermail/xenomai/attachments/20151014/7024f00c/attachment-0001.obj>
Quoted 6 lines · Frederik Bayart
Hallo,
I'm using xenomai 3.0 on kernel 3.18.20 (64 bit).When using single block heap, I'm getting memory allocation problem when calling
rt_heap_allocwith size 0. I don't get the error when calling the function with size used inrt_heap_create. On the mailing list, I found there has been an issue with this in May : http://www.xenomai.org/pipermail/xenomai/2015-May/034165.html
Is this still an issue ?
No, this one is long gone.
Quoted 11 lines
In attachment a test program
htest.c+ makefile to generate the problem :$ sudo ./htest 1 ==> use 0 htest.c:69: heapsize = 70000, usablemem = 70144, usedmem = 0 htest.c:79 ERROR: rt_heap_alloc(-12): Cannot allocate memory$ sudo ./htest 1 ==> use same size as in create htest.c:69: heapsize = 70000, usablemem = 70144, usedmem = 0 htest.c:92: heapsize = 70000, usablemem = 70144, usedmem = 70144
Does this help?
lib/alchemy/heap.c +3 -1
@@ -442,7 +442,9 @@ int rt_heap_alloc_timed(RT_HEAP *heap, p =__mptr (hcb->sba);if (p) goto done; -if (size >0 && size != hcb->size) { +if (size ==0 ) + size =heapobj_size (&hcb->hobj); +else if (size != hcb->size) { ret = -EINVAL ; goto done; }
Quoted 4 lines
However, I both cases, I get a trace in dmesg :
[Xenomai] syscall <7> denied to sysregd
That one is a different issue. Does your application have supervisor or user privileges?
Signature · 1 line
Philippe.
Quoted 40 lines · Philippe Gerum
Quoted 6 lines · Frederik Bayart
Hallo,
I'm using xenomai 3.0 on kernel 3.18.20 (64 bit).When using single block heap, I'm getting memory allocation problem when calling
rt_heap_allocwith size 0. I don't get the error when calling the function with size used inrt_heap_create. On the mailing list, I found there has been an issue with this in May : http://www.xenomai.org/pipermail/xenomai/2015-May/034165.html
Is this still an issue ?No, this one is long gone.
Quoted 11 lines
In attachment a test program
htest.c+ makefile to generate the problem :$ sudo ./htest 1 ==> use 0 htest.c:69: heapsize = 70000, usablemem = 70144, usedmem = 0 htest.c:79 ERROR: rt_heap_alloc(-12): Cannot allocate memory$ sudo ./htest 1 ==> use same size as in create htest.c:69: heapsize = 70000, usablemem = 70144, usedmem = 0 htest.c:92: heapsize = 70000, usablemem = 70144, usedmem = 70144Does this help?
lib/alchemy/heap.c +3
-1@@ -442,7 +442,9 @@ int rt_heap_alloc_timed(RT_HEAP *heap, p = __mptr(hcb->sba); if (p) goto done; - if (size > 0 && size != hcb->size) { + if (size == 0) + size = heapobj_size(&hcb->hobj); + else if (size != hcb->size) { ret = -EINVAL; goto done;
Quoted 2 lines
}
After code reading, could it be that the exception for size == 0 has disappeared in the released code ?
if (hcb->mode & H_SINGLE) {
p = __mptr(hcb->sba);
if (p)
goto done;
if (size > 0 && size != hcb->size) {
ret = -EINVAL;
goto done;
}
p = heapobj_alloc(&hcb->hobj, size);
if (p == NULL) {
ret = -ENOMEM;
goto done;
}
hcb->sba = __moff(p);
goto done;
}
And if size is 0, alloc_block returns NULL so ENOMEM is returned.
Quoted 7 lines
Quoted 3 lines
However, I both cases, I get a trace in dmesg :
[Xenomai] syscall <7> denied to sysregd
That one is a different issue. Does your application have supervisor or user privileges?
I'm running the application as root. Is this the question ?
Quoted 2 lines
Signature · 1 line
Philippe.
Frederik
Quoted 40 lines · Frederik Bayart
Quoted 40 lines · Philippe Gerum
Quoted 6 lines · Frederik Bayart
Hallo,
I'm using xenomai 3.0 on kernel 3.18.20 (64 bit).When using single block heap, I'm getting memory allocation problem when calling
rt_heap_allocwith size 0. I don't get the error when calling the function with size used inrt_heap_create. On the mailing list, I found there has been an issue with this in May : http://www.xenomai.org/pipermail/xenomai/2015-May/034165.html
Is this still an issue ?No, this one is long gone.
Quoted 11 lines
In attachment a test program
htest.c+ makefile to generate the problem :$ sudo ./htest 1 ==> use 0 htest.c:69: heapsize = 70000, usablemem = 70144, usedmem = 0 htest.c:79 ERROR: rt_heap_alloc(-12): Cannot allocate memory$ sudo ./htest 1 ==> use same size as in create htest.c:69: heapsize = 70000, usablemem = 70144, usedmem = 0 htest.c:92: heapsize = 70000, usablemem = 70144, usedmem = 70144Does this help?
lib/alchemy/heap.c +3
-1@@ -442,7 +442,9 @@ int rt_heap_alloc_timed(RT_HEAP *heap, p =__mptr (hcb->sba);if (p) goto done; -if (size >0 && size != hcb->size) { +if (size ==0 ) + size =heapobj_size (&hcb->hobj); +else if (size != hcb->size) { ret = -EINVAL ; goto done;
Quoted 5 lines
Quoted 2 lines
}After code reading, could it be that the exception for size == 0 has disappeared in the released code ?
Did you try that patch?
Signature · 1 line
Philippe.
Quoted 43 lines · Philippe Gerum
Quoted 40 lines · Frederik Bayart
Quoted 40 lines · Philippe Gerum
Quoted 6 lines · Frederik Bayart
Hallo,
I'm using xenomai 3.0 on kernel 3.18.20 (64 bit).When using single block heap, I'm getting memory allocation problem when calling
rt_heap_allocwith size 0. I don't get the error when calling the function with size used inrt_heap_create. On the mailing list, I found there has been an issue with this in May : http://www.xenomai.org/pipermail/xenomai/2015-May/034165.html
Is this still an issue ?No, this one is long gone.
Quoted 11 lines
In attachment a test program
htest.c+ makefile to generate the problem :$ sudo ./htest 1 ==> use 0 htest.c:69: heapsize = 70000, usablemem = 70144, usedmem = 0 htest.c:79 ERROR: rt_heap_alloc(-12): Cannot allocate memory$ sudo ./htest 1 ==> use same size as in create htest.c:69: heapsize = 70000, usablemem = 70144, usedmem = 0 htest.c:92: heapsize = 70000, usablemem = 70144, usedmem = 70144Does this help?
lib/alchemy/heap.c +3
-1@@ -442,7 +442,9 @@ int rt_heap_alloc_timed(RT_HEAP *heap, p =__mptr (hcb->sba);if (p) goto done; -if (size >0 && size != hcb->size) { +if (size ==0 ) + size =heapobj_size (&hcb->hobj); +else if (size != hcb->size) { ret = -EINVAL ; goto done;
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
}After code reading, could it be that the exception for size == 0 has disappeared in the released code ?
Did you try that patch?
Sorry, I didn't understand that the patch still has to be applied. So the patch is working, thanks for the quick fix.
However the biggest problem is the denied syscall :
[Xenomai] syscall <7> denied to sysregd[22217]
I'm running the test program as root. Also sysregd is running as root.
root 22292 1 0 16:41 ? 00:00:00 sysregd --daemon --root /var/run/xenomai/root/anon@22289 --anon
So this would be sc_cobalt_thread_setschedparam_ex. So I'm thinking this is called maybe for the main thread shadowing, e.g. for the priority.
If I execute :
# ./htest –main-prio=15
then I see in /proc/xenomai/sched/threads :
CPU PID CLASS TYPE PRI TIMEOUT STAT NAME 0 16149 rt cobalt 0 - X htest 0 16152 rt cobalt 0 - X sysregd 0 16154 rt cobalt 0 - X sysregd 0 16156 rt cobalt 0 - X htest
so no prio 15.
The config dump :
# ./htest --dump-config based on Xenomai/cobalt v3.0 -- CONFIG_MMU=1 CONFIG_SMP=1 CONFIG_XENO_BUILD_ARGS=" '--prefix=/usr' '--includedir=/usr/include/xenomai' '--mandir=/usr/share/man' '--with-testdir=/usr/lib/xenomai/testsuite' '--with-core=cobalt' '--enable-smp' '--enable-pshared' '--enable-registry' '--build' 'x86_64-linux-gnu' 'build_alias=x86_64-linux-gnu'" CONFIG_XENO_BUILD_STRING="x86_64-pc-linux-gnu" CONFIG_XENO_COBALT=1 CONFIG_XENO_COMPILER="gcc version 4.9.2 (Debian 4.9.2-10) " CONFIG_XENO_DEFAULT_PERIOD=100000 CONFIG_XENO_FORTIFY=1 CONFIG_XENO_HOST_STRING="x86_64-pc-linux-gnu" CONFIG_XENO_LORES_CLOCK_DISABLED=1 CONFIG_XENO_PREFIX="/usr" CONFIG_XENO_PSHARED=1 CONFIG_XENO_RAW_CLOCK_ENABLED=1 CONFIG_XENO_REGISTRY=1 CONFIG_XENO_REGISTRY_ROOT="/var/run/xenomai" CONFIG_XENO_REVISION_LEVEL=0 CONFIG_XENO_SANITY=1 CONFIG_XENO_TLSF=1 CONFIG_XENO_TLS_MODEL="initial-exec" CONFIG_XENO_UAPI_LEVEL=14 CONFIG_XENO_VERSION_MAJOR=3 CONFIG_XENO_VERSION_MINOR=0 CONFIG_XENO_VERSION_NAME="Exact Zero" CONFIG_XENO_VERSION_STRING="3.0" CONFIG_XENO_X86_VSYSCALL=1 --- CONFIG_XENO_ASYNC_CANCEL is OFF CONFIG_XENO_COPPERPLATE_CLOCK_RESTRICTED is OFF CONFIG_XENO_DEBUG is OFF CONFIG_XENO_DEBUG_FULL is OFF CONFIG_XENO_LIBS_DLOPEN is OFF CONFIG_XENO_MERCURY is OFF CONFIG_XENO_VALGRIND_API is OFF CONFIG_XENO_WORKAROUND_CONDVAR_PI is OFF --- PTHREAD_STACK_DEFAULT=65536
Frederik
Quoted 4 lines · Frederik Bayart
However the biggest problem is the denied syscall :
[Xenomai] syscall <7> denied to sysregd[22217]
This one is not an issue, it's merely debug noise. You can silence it with this change; the result will be functionally the same, without the scary warning.
lib/copperplate/regd/regd.c +1 -1
@@ -538,7 +538,7 @@ int main(int argc, char *const *argv)/* Force SCHED_OTHER. */ schedp.sched_priority =0 ; -pthread_setschedparam (pthread_self (),SCHED_OTHER , &schedp); +__STD (pthread_setschedparam (pthread_self (),SCHED_OTHER , &schedp));memset (&sa,0 ,sizeof (sa)); sa.sa_handler =SIG_IGN ;
Signature · 1 line
Philippe.