Can't build libpthread for M3
Andrii
bearrailgun at gmail.com
Mon Nov 3 15:53:54 UTC 2014
I've tried to apply Sergei' 3 patches to the original 0.9.33.2 and run test
app on it.
Still got a crash:
/ # /opt/zpm_thread
00032 : pthread_initialize: initial thread stack bounds: bos=0x1,
tos=0xffffffff
00032 : __pthread_initialize_manager: manager stack: size=8160,
bos=0xa00a2008, tos=0xa00a3fe8
00032 : __pthread_initialize_manager: send REQ_DEBUG to manager thread
00032 : pthread_create: write REQ_CREATE to manager thread
00032 : pthread_create: before suspend(self)
00033 : __pthread_manager: before poll
00033 : __pthread_manager: after poll
00033 : __pthread_manager: before read
00033 : __pthread_manager: after read, n=28
00033 : __pthread_manager: got REQ_CREATE
00033 : pthread_allocate_stack: malloced chunk: base=0xa00a8008, size=0x4000
00033 : pthread_allocate_stack: thread stack: bos=0xa00a8008, tos=0xa00abea8
00033 : pthread_allocate_stack: initial stack: bos=0x1, tos=0xa00a2008
00033 : pthread_handle_create: cloning new_thread = 0xa00abea8
00033 : pthread_handle_create: new thread pid = 34
00033 : __pthread_manager: restarting 0xa008e8d0
00032 : pthread_create: after suspend(self)
thread #0 created
00033 : __pthread_manager: before poll
00034 : pthread_start_thread:
new thread 1 executed.
00032 : pthread_create: write REQ_CREATE to manager thread
00032 : pthread_create: before suspend(self)
00033 : __pthread_manager: after poll
00033 : __pthread_manager: before read
00033 : __pthread_manager: after read, n=28
00033 : __pthread_manager: got REQ_CREATE
00033 : pthread_allocate_stack: malloced chunk: base=0xa03d8008, size=0x4000
00033 : pthread_allocate_stack: thread stack: bos=0xa03d8008, tos=0xa03dbea8
00033 : pthread_allocate_stack: initial stack: bos=0x1, tos=0xa00a2008
00033 : pthread_handle_create: cloning new_thread = 0xa03dbea8
00033 : pthread_handle_create: new thread pid = 35
00033 : __pthread_manager: restarting 0xa008e8d0
00033 : __pthread_manager: before poll
00035 : pthread_start_thread:
new thread 1 executed.
00032 : pthread_create: after suspend(self)
thread #1 created
00032 : pthread_create: write REQ_CREATE to manager thread
00033 : __pthread_manager: after poll
00033 : __pthread_manager: before read
00033 : __pthread_manager: after read, n=28
00033 : __pthread_manager: got REQ_CREATE
00032 : pthread_create: before suspend(self)
[ 12.390000]
[ 12.390000] zpm_thread: unhandled MPU fault (0x08) at 0x00000000
[pc=0xa0084c74,sp=0xa00a3f20]
[ 12.390000]
[ 12.390000] Pid: 33, comm: zpm_thread
[ 12.390000] CPU: 0 Not tainted (2.6.33-arm1 #2)
[ 12.390000] pc : [<a0084c74>] lr : [<a008478f>] psr: 21000000
[ 12.390000] sp : a00a3f20 ip : 5220746f fp : 00000803
[ 12.390000] Code dump at pc [a0084c74]:
[ 12.390000] a003f848 463b4621 ff98f7ff 681b4b04
[ 12.390000] r10: 00005000 r9 : 00000003 r8 : a0020000
[ 12.390000] r7 : a0092f04 r6 : 00000100 r5 : a0092e0c r4 : a0024ff4
[ 12.390000] r3 : 00004ff4 r2 : 00000000 r1 : a0092e10 r0 : a0092e0c
[ 12.390000] Flags: nzCv IRQs on FIQs on Mode USER_26 ISA unknown
Segment user
[ 12.390000] Backtrace: invalid frame pointer 0x00000803
>From my observations it crashes in malloc() during allocation of 16Kb stack
for a new thread while trying to find and link a new free area.
Here is the app code. It's trivial:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <pthread.h>
#define NUM_THREADS 10
pthread_t thread[NUM_THREADS] = {0};
int thread_cnt = 0;
void* start_routine(void *arg)
{
printf("new thread %d executed.\n", thread_cnt);
while(1)
{
sleep(1);
}
}
void main()
{
int i;
int rv;
for (i = 0; i < NUM_THREADS; i++)
{
rv = pthread_create(&thread[thread_cnt], NULL,
start_routine, NULL);
if (rv)
printf("<error> thread was not created! Error num
is : %d\n", rv);
printf("thread #%d created \n", thread_cnt);
thread_cnt++;
sleep(1);
}
while(1)
{
static int loop_cnt = 0;
printf("app loop: %d\n", loop_cnt);
sleep(1);
loop_cnt++;
if (loop_cnt == 10)
break;
}
}
uClibc config is attached.
Could someone please try it on M3 and tell me the results?
Regards.
On Sat, Nov 1, 2014 at 10:52 AM, Sergei Poselenov <sposelenov at emcraft.com>
wrote:
> Hello,
>
> On Thu, 2014-10-23 at 17:25 +0200, Bernhard Reutner-Fischer wrote:
> > On 22 October 2014 12:11:26 CEST, Sergei Poselenov <
> sposelenov at emcraft.com> wrote:
> > >Hello,
> > >
> >
> > >Uclibc (still) lacks pthreads support on Cortex-M3.
> > >
> > >I'm attaching two patches:
> > > - implement testandset() for Cortex-M3.
> > > - Fix a bug in implementation of clone() for Cortex-M3.
> >
> > Can you please send the two patches with appropriate signed-off-by lines?
>
> I'm sending the patches made against the pristine 0.9.33.2 in the next
> emails. Note that the changes may be not quite portable, feel free to
> modify them.
>
> Regards,
>
> Sergei
> > TIA,
> >
>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config
Type: application/octet-stream
Size: 5821 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/uclibc/attachments/20141103/f878ef4a/attachment.obj>
More information about the uClibc
mailing list