All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] Problem throwing a C++ Exception on Blackfin
@ 2010-03-15 14:00 Kolja Waschk
  2010-03-15 14:30 ` Philippe Gerum
  0 siblings, 1 reply; 11+ messages in thread
From: Kolja Waschk @ 2010-03-15 14:00 UTC (permalink / raw)
  To: xenomai

Hi,

first I have to admit that my report is actually about a problem with a quite old Xenomai (Nucleus 2.4.7, I-pipe 1.10) in "stock" Blackfin uClinux kernel 2.6.28 as it comes in Blackfin uClinux-dist 2009R1-RC6.

Testing a newer code base would probably require some days of work to update a custom driver and bring up other problems, so I'm trying to find out whether it is worth the effort at this time. Maybe someone can (roughly) identify the problem's cause (from memory?) and help me to decide whether there is a simple solution, or an upgrade is necessary:

A simple C++ program that creates a task, which does nothing but throws an exception, crashes my BF537. Currently, it results in

> Data access CPLB miss
>  - Used by the MMU to signal a CPLB miss on a data access.
...
>  RETS: <0x004b02be> [ /tmp/test + 0x302be ]
>  PC  : <0x004aff88> [ /tmp/test + 0x2ff88 ]
> DCPLB_FAULT_ADDR: <0xf1380095> /* kernel dynamic memory */
> ICPLB_FAULT_ADDR: <0x004aff88> [ /tmp/test + 0x2ff88 ]

/tmp/test + 0x2ff88 resolves to /usr/src/packages/BUILD/blackfin-toolchain-09r1/../gcc-4.1/gcc/unwind-dw2-fde.c:273

I stripped it down to the small remainder which still triggers the problem (error handling for example was there but I left it out for this post). It doesn't always happen on the first start, but certainly on the second.

The last line showing up if I step through the program is the 'throw "foo"' here in test.cc.

#include <native/task.h>
void task_main(void* arg) {
     try {
         throw "foo";
     }
     catch (...) { }
}

int main() {
     RT_TASK task;
     rt_task_create(&task, "task", 128*1024, 99, T_FPU|T_JOINABLE);
     rt_task_start(&task, task_main, NULL);
}

Any first ideas? I'm going to install more recent versions of kernel and Adeos/I-PIPE/Xenomai, but ideally I would like to keep as much as in the 2009R1 (or 2009R1.1) release version of Blacking uClinux-dist..

Many thanks for taking a look at my problem in advance!
Kolja



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Xenomai-help] Problem throwing a C++ Exception on Blackfin
  2010-03-15 14:00 [Xenomai-help] Problem throwing a C++ Exception on Blackfin Kolja Waschk
@ 2010-03-15 14:30 ` Philippe Gerum
  2010-03-15 16:40   ` Gilles Chanteperdrix
  0 siblings, 1 reply; 11+ messages in thread
From: Philippe Gerum @ 2010-03-15 14:30 UTC (permalink / raw)
  To: xenoka09; +Cc: xenomai

On Mon, 2010-03-15 at 15:00 +0100, Kolja Waschk wrote:
> Hi,
> 
> first I have to admit that my report is actually about a problem with a quite old Xenomai (Nucleus 2.4.7, I-pipe 1.10) in "stock" Blackfin uClinux kernel 2.6.28 as it comes in Blackfin uClinux-dist 2009R1-RC6.
> 
> Testing a newer code base would probably require some days of work to update a custom driver and bring up other problems, so I'm trying to find out whether it is worth the effort at this time. Maybe someone can (roughly) identify the problem's cause (from memory?) and help me to decide whether there is a simple solution, or an upgrade is necessary:
> 

No obvious answer to this. 2.6.28/bfin has problems, the whole exception
management on blackfin is a problem per se. 2.6.28/bfin + I-pipe has
even more problems. You may want to try 2.6.31.6, while keeping the rest
of your uClinux-dist base. Nasty issues were fixed in the 2.6.30
timeframe.

> A simple C++ program that creates a task, which does nothing but throws an exception, crashes my BF537. Currently, it results in
> 
> > Data access CPLB miss
> >  - Used by the MMU to signal a CPLB miss on a data access.
> ...
> >  RETS: <0x004b02be> [ /tmp/test + 0x302be ]
> >  PC  : <0x004aff88> [ /tmp/test + 0x2ff88 ]
> > DCPLB_FAULT_ADDR: <0xf1380095> /* kernel dynamic memory */
> > ICPLB_FAULT_ADDR: <0x004aff88> [ /tmp/test + 0x2ff88 ]
> 

Try enabling CONFIG_DEBUG_BFIN_HWTRACE_ON.

> /tmp/test + 0x2ff88 resolves to /usr/src/packages/BUILD/blackfin-toolchain-09r1/../gcc-4.1/gcc/unwind-dw2-fde.c:273
> 

Any disassembly of that spot?

> I stripped it down to the small remainder which still triggers the problem (error handling for example was there but I left it out for this post). It doesn't always happen on the first start, but certainly on the second.
> 
> The last line showing up if I step through the program is the 'throw "foo"' here in test.cc.
> 
> #include <native/task.h>
> void task_main(void* arg) {
>      try {
>          throw "foo";
>      }
>      catch (...) { }
> }
> 
> int main() {
>      RT_TASK task;
>      rt_task_create(&task, "task", 128*1024, 99, T_FPU|T_JOINABLE);
>      rt_task_start(&task, task_main, NULL);
> }
> 
> Any first ideas? I'm going to install more recent versions of kernel and Adeos/I-PIPE/Xenomai, but ideally I would like to keep as much as in the 2009R1 (or 2009R1.1) release version of Blacking uClinux-dist..
> 
> Many thanks for taking a look at my problem in advance!
> Kolja
> 
> 
> _______________________________________________
> Xenomai-help mailing list
> Xenomai-help@domain.hid
> https://mail.gna.org/listinfo/xenomai-help


-- 
Philippe.




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Xenomai-help] Problem throwing a C++ Exception on Blackfin
  2010-03-15 14:30 ` Philippe Gerum
@ 2010-03-15 16:40   ` Gilles Chanteperdrix
  2010-03-15 17:10     ` Philippe Gerum
  0 siblings, 1 reply; 11+ messages in thread
From: Gilles Chanteperdrix @ 2010-03-15 16:40 UTC (permalink / raw)
  To: Philippe Gerum; +Cc: xenomai

Philippe Gerum wrote:
> On Mon, 2010-03-15 at 15:00 +0100, Kolja Waschk wrote:
>> Hi,
>>
>> first I have to admit that my report is actually about a problem with a quite old Xenomai (Nucleus 2.4.7, I-pipe 1.10) in "stock" Blackfin uClinux kernel 2.6.28 as it comes in Blackfin uClinux-dist 2009R1-RC6.
>>
>> Testing a newer code base would probably require some days of work to update a custom driver and bring up other problems, so I'm trying to find out whether it is worth the effort at this time. Maybe someone can (roughly) identify the problem's cause (from memory?) and help me to decide whether there is a simple solution, or an upgrade is necessary:
>>
> 
> No obvious answer to this. 2.6.28/bfin has problems, the whole exception
> management on blackfin is a problem per se. 2.6.28/bfin + I-pipe has
> even more problems. You may want to try 2.6.31.6, while keeping the rest
> of your uClinux-dist base. Nasty issues were fixed in the 2.6.30
> timeframe.

Are you sure C++ exceptions need hardware exceptions at all? That the
problem is not rather that we have some C code without exception
handling traversed by exceptions? Should not the Xenomai support
libraries be compiled with -fexceptions to allow mixing them with code
which throws/catches exceptions?


-- 
Gilles Chanteperdrix, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Xenomai-help] Problem throwing a C++ Exception on Blackfin
  2010-03-15 16:40   ` Gilles Chanteperdrix
@ 2010-03-15 17:10     ` Philippe Gerum
  2010-03-15 17:57       ` Gilles Chanteperdrix
  0 siblings, 1 reply; 11+ messages in thread
From: Philippe Gerum @ 2010-03-15 17:10 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: xenomai

On Mon, 2010-03-15 at 17:40 +0100, Gilles Chanteperdrix wrote:
> Philippe Gerum wrote:
> > On Mon, 2010-03-15 at 15:00 +0100, Kolja Waschk wrote:
> >> Hi,
> >>
> >> first I have to admit that my report is actually about a problem with a quite old Xenomai (Nucleus 2.4.7, I-pipe 1.10) in "stock" Blackfin uClinux kernel 2.6.28 as it comes in Blackfin uClinux-dist 2009R1-RC6.
> >>
> >> Testing a newer code base would probably require some days of work to update a custom driver and bring up other problems, so I'm trying to find out whether it is worth the effort at this time. Maybe someone can (roughly) identify the problem's cause (from memory?) and help me to decide whether there is a simple solution, or an upgrade is necessary:
> >>
> > 
> > No obvious answer to this. 2.6.28/bfin has problems, the whole exception
> > management on blackfin is a problem per se. 2.6.28/bfin + I-pipe has
> > even more problems. You may want to try 2.6.31.6, while keeping the rest
> > of your uClinux-dist base. Nasty issues were fixed in the 2.6.30
> > timeframe.
> 
> Are you sure C++ exceptions need hardware exceptions at all? That the
> problem is not rather that we have some C code without exception
> handling traversed by exceptions? Should not the Xenomai support
> libraries be compiled with -fexceptions to allow mixing them with code
> which throws/catches exceptions?

It's not about using hw to process C++ exceptions. It's about having
problems handling hw exceptions in kernel space triggered by C++
exceptions in user-space.

> 
> 


-- 
Philippe.




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Xenomai-help] Problem throwing a C++ Exception on Blackfin
  2010-03-15 17:10     ` Philippe Gerum
@ 2010-03-15 17:57       ` Gilles Chanteperdrix
  2010-03-15 18:10         ` Philippe Gerum
  0 siblings, 1 reply; 11+ messages in thread
From: Gilles Chanteperdrix @ 2010-03-15 17:57 UTC (permalink / raw)
  To: Philippe Gerum; +Cc: xenomai

Philippe Gerum wrote:
> On Mon, 2010-03-15 at 17:40 +0100, Gilles Chanteperdrix wrote:
>> Philippe Gerum wrote:
>>> On Mon, 2010-03-15 at 15:00 +0100, Kolja Waschk wrote:
>>>> Hi,
>>>>
>>>> first I have to admit that my report is actually about a problem with a quite old Xenomai (Nucleus 2.4.7, I-pipe 1.10) in "stock" Blackfin uClinux kernel 2.6.28 as it comes in Blackfin uClinux-dist 2009R1-RC6.
>>>>
>>>> Testing a newer code base would probably require some days of work to update a custom driver and bring up other problems, so I'm trying to find out whether it is worth the effort at this time. Maybe someone can (roughly) identify the problem's cause (from memory?) and help me to decide whether there is a simple solution, or an upgrade is necessary:
>>>>
>>> No obvious answer to this. 2.6.28/bfin has problems, the whole exception
>>> management on blackfin is a problem per se. 2.6.28/bfin + I-pipe has
>>> even more problems. You may want to try 2.6.31.6, while keeping the rest
>>> of your uClinux-dist base. Nasty issues were fixed in the 2.6.30
>>> timeframe.
>> Are you sure C++ exceptions need hardware exceptions at all? That the
>> problem is not rather that we have some C code without exception
>> handling traversed by exceptions? Should not the Xenomai support
>> libraries be compiled with -fexceptions to allow mixing them with code
>> which throws/catches exceptions?
> 
> It's not about using hw to process C++ exceptions. It's about having
> problems handling hw exceptions in kernel space triggered by C++
> exceptions in user-space.

The main problem may be why C++ exceptions in user-space do trigger hw
exceptions in kernel-space. And I would tend to think that a missing
-fexceptions could be the cause. Except that in the testcase, the
exception does not traverse any Xenomai library code, since it is thrown
and handled in the same function.

> 
>>
> 
> 


-- 
Gilles Chanteperdrix, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Xenomai-help] Problem throwing a C++ Exception on Blackfin
  2010-03-15 17:57       ` Gilles Chanteperdrix
@ 2010-03-15 18:10         ` Philippe Gerum
  2010-03-15 18:15           ` Gilles Chanteperdrix
  0 siblings, 1 reply; 11+ messages in thread
From: Philippe Gerum @ 2010-03-15 18:10 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: xenomai

On Mon, 2010-03-15 at 18:57 +0100, Gilles Chanteperdrix wrote:
> Philippe Gerum wrote:
> > On Mon, 2010-03-15 at 17:40 +0100, Gilles Chanteperdrix wrote:
> >> Philippe Gerum wrote:
> >>> On Mon, 2010-03-15 at 15:00 +0100, Kolja Waschk wrote:
> >>>> Hi,
> >>>>
> >>>> first I have to admit that my report is actually about a problem with a quite old Xenomai (Nucleus 2.4.7, I-pipe 1.10) in "stock" Blackfin uClinux kernel 2.6.28 as it comes in Blackfin uClinux-dist 2009R1-RC6.
> >>>>
> >>>> Testing a newer code base would probably require some days of work to update a custom driver and bring up other problems, so I'm trying to find out whether it is worth the effort at this time. Maybe someone can (roughly) identify the problem's cause (from memory?) and help me to decide whether there is a simple solution, or an upgrade is necessary:
> >>>>
> >>> No obvious answer to this. 2.6.28/bfin has problems, the whole exception
> >>> management on blackfin is a problem per se. 2.6.28/bfin + I-pipe has
> >>> even more problems. You may want to try 2.6.31.6, while keeping the rest
> >>> of your uClinux-dist base. Nasty issues were fixed in the 2.6.30
> >>> timeframe.
> >> Are you sure C++ exceptions need hardware exceptions at all? That the
> >> problem is not rather that we have some C code without exception
> >> handling traversed by exceptions? Should not the Xenomai support
> >> libraries be compiled with -fexceptions to allow mixing them with code
> >> which throws/catches exceptions?
> > 
> > It's not about using hw to process C++ exceptions. It's about having
> > problems handling hw exceptions in kernel space triggered by C++
> > exceptions in user-space.
> 
> The main problem may be why C++ exceptions in user-space do trigger hw
> exceptions in kernel-space. And I would tend to think that a missing
> -fexceptions could be the cause. Except that in the testcase, the
> exception does not traverse any Xenomai library code, since it is thrown
> and handled in the same function.

That is one issue, but the basic issue we should be after first, is that
we have a CPLB miss triggered by a kernel memory access. Fixing a
possible user-space issue should come next, so that we don't paper over
that bug.

> 
> > 
> >>
> > 
> > 
> 
> 


-- 
Philippe.




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Xenomai-help] Problem throwing a C++ Exception on Blackfin
  2010-03-15 18:10         ` Philippe Gerum
@ 2010-03-15 18:15           ` Gilles Chanteperdrix
  2010-03-16  9:12             ` Kolja Waschk
       [not found]             ` <alpine.DEB.1.10.1003161001560.29063@domain.hid>
  0 siblings, 2 replies; 11+ messages in thread
From: Gilles Chanteperdrix @ 2010-03-15 18:15 UTC (permalink / raw)
  To: Philippe Gerum; +Cc: xenomai

Philippe Gerum wrote:
> On Mon, 2010-03-15 at 18:57 +0100, Gilles Chanteperdrix wrote:
>> Philippe Gerum wrote:
>>> On Mon, 2010-03-15 at 17:40 +0100, Gilles Chanteperdrix wrote:
>>>> Philippe Gerum wrote:
>>>>> On Mon, 2010-03-15 at 15:00 +0100, Kolja Waschk wrote:
>>>>>> Hi,
>>>>>>
>>>>>> first I have to admit that my report is actually about a problem with a quite old Xenomai (Nucleus 2.4.7, I-pipe 1.10) in "stock" Blackfin uClinux kernel 2.6.28 as it comes in Blackfin uClinux-dist 2009R1-RC6.
>>>>>>
>>>>>> Testing a newer code base would probably require some days of work to update a custom driver and bring up other problems, so I'm trying to find out whether it is worth the effort at this time. Maybe someone can (roughly) identify the problem's cause (from memory?) and help me to decide whether there is a simple solution, or an upgrade is necessary:
>>>>>>
>>>>> No obvious answer to this. 2.6.28/bfin has problems, the whole exception
>>>>> management on blackfin is a problem per se. 2.6.28/bfin + I-pipe has
>>>>> even more problems. You may want to try 2.6.31.6, while keeping the rest
>>>>> of your uClinux-dist base. Nasty issues were fixed in the 2.6.30
>>>>> timeframe.
>>>> Are you sure C++ exceptions need hardware exceptions at all? That the
>>>> problem is not rather that we have some C code without exception
>>>> handling traversed by exceptions? Should not the Xenomai support
>>>> libraries be compiled with -fexceptions to allow mixing them with code
>>>> which throws/catches exceptions?
>>> It's not about using hw to process C++ exceptions. It's about having
>>> problems handling hw exceptions in kernel space triggered by C++
>>> exceptions in user-space.
>> The main problem may be why C++ exceptions in user-space do trigger hw
>> exceptions in kernel-space. And I would tend to think that a missing
>> -fexceptions could be the cause. Except that in the testcase, the
>> exception does not traverse any Xenomai library code, since it is thrown
>> and handled in the same function.
> 
> That is one issue, but the basic issue we should be after first, is that
> we have a CPLB miss triggered by a kernel memory access. Fixing a
> possible user-space issue should come next, so that we don't paper over
> that bug.

Yes, of course.

FWIW, I tried the test program on ARM, and it runs just fine (except
that it is missing the obvious mlockall). If we do not catch the
exception, the glibc is also completely able to handle it and generate a
"clean" abort. So, I guess there is no -fexceptions issue.

Sorry for the noise.

-- 
Gilles Chanteperdrix, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Xenomai-help] Problem throwing a C++ Exception on Blackfin
  2010-03-15 18:15           ` Gilles Chanteperdrix
@ 2010-03-16  9:12             ` Kolja Waschk
       [not found]             ` <alpine.DEB.1.10.1003161001560.29063@domain.hid>
  1 sibling, 0 replies; 11+ messages in thread
From: Kolja Waschk @ 2010-03-16  9:12 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: xenomai


> "clean" abort. So, I guess there is no -fexceptions issue.
> Sorry for the noise.

Hm, it seems I'm to blame for unnecessary noise on this list - the problem appears even without any task switching in the process. Sorry that I didn't consider to try that first, I was somehow sure it's related to the extra task. I think I better move over to the uClinux etc Forums...

Even this is sufficient to trigger the problem: int main(){try{throw "foo";}catch(...){}};

Kolja





^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Xenomai-help] Problem throwing a C++ Exception on Blackfin
       [not found]             ` <alpine.DEB.1.10.1003161001560.29063@domain.hid>
@ 2010-03-16  9:15               ` Philippe Gerum
  2010-03-16  9:23                 ` Kolja Waschk
  2010-03-16 14:11                 ` Kolja Waschk
  0 siblings, 2 replies; 11+ messages in thread
From: Philippe Gerum @ 2010-03-16  9:15 UTC (permalink / raw)
  To: Kolja Waschk; +Cc: xenomai, Gilles Chanteperdrix

On Tue, 2010-03-16 at 10:09 +0100, Kolja Waschk wrote:
> > "clean" abort. So, I guess there is no -fexceptions issue.
> > Sorry for the noise.
> 
> Hm, it seems I'm to blame for unnecessary noise on this list - the problem appears even without any task switching in the process. Sorry that I didn't consider to try that first, I was somehow sure it's related to the extra task. I think I better move over to the uClinux etc Forums...
> 
> Even this is sufficient to trigger the problem: int main(){try{throw "foo";}catch(...){}};

Still, you should try disabling CONFIG_IPIPE on your kernel to see
whether this makes a difference on 2.6.28. If it does, then you may want
to try 2.6.31.6 instead.

> 
> Kolja
> 
> 
> 


-- 
Philippe.




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Xenomai-help] Problem throwing a C++ Exception on Blackfin
  2010-03-16  9:15               ` Philippe Gerum
@ 2010-03-16  9:23                 ` Kolja Waschk
  2010-03-16 14:11                 ` Kolja Waschk
  1 sibling, 0 replies; 11+ messages in thread
From: Kolja Waschk @ 2010-03-16  9:23 UTC (permalink / raw)
  To: Philippe Gerum; +Cc: xenomai

> Still, you should try disabling CONFIG_IPIPE on your kernel to see

I'll do and report here if it makes a difference.

> whether this makes a difference on 2.6.28. If it does, then you may want
> to try 2.6.31.6 instead.

It now does happen with 2.6.31.6 as well.

Thanks for your suggestions!
Kolja



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Xenomai-help] Problem throwing a C++ Exception on Blackfin
  2010-03-16  9:15               ` Philippe Gerum
  2010-03-16  9:23                 ` Kolja Waschk
@ 2010-03-16 14:11                 ` Kolja Waschk
  1 sibling, 0 replies; 11+ messages in thread
From: Kolja Waschk @ 2010-03-16 14:11 UTC (permalink / raw)
  To: Philippe Gerum; +Cc: xenomai, Gilles Chanteperdrix

>> Even this is sufficient to trigger the problem: int main(){try{throw "foo";}catch(...){}};
> Still, you should try disabling CONFIG_IPIPE on your kernel to see
> whether this makes a difference on 2.6.28. If it does, then you may want

The problem appears even without CONFIG_IPIPE. It is somehow related to other activity and/or other tasks at the same time, but not specifically to realtime activity. On a fresh install of uClinux-dist-2009R1.1-RC4 with matching toolchain, the above little test can be run continously without problems in a loop, but will crash as soon as another telnet session to the board is started. Or it is run in gdb.

Anyway, this is not a problem with I-pipe/Xenomai/etc. ... I'll look for help at the more appriorate places. Thanks!

Greetings from Hamburg,
Kolja



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-03-16 14:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-15 14:00 [Xenomai-help] Problem throwing a C++ Exception on Blackfin Kolja Waschk
2010-03-15 14:30 ` Philippe Gerum
2010-03-15 16:40   ` Gilles Chanteperdrix
2010-03-15 17:10     ` Philippe Gerum
2010-03-15 17:57       ` Gilles Chanteperdrix
2010-03-15 18:10         ` Philippe Gerum
2010-03-15 18:15           ` Gilles Chanteperdrix
2010-03-16  9:12             ` Kolja Waschk
     [not found]             ` <alpine.DEB.1.10.1003161001560.29063@domain.hid>
2010-03-16  9:15               ` Philippe Gerum
2010-03-16  9:23                 ` Kolja Waschk
2010-03-16 14:11                 ` Kolja Waschk

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.