Skip to contentSkip to conversation

Problem throwing a C++ Exception on Blackfin

Xenomai-help Kolja Waschk 3 participants 11 messages Mar 15, 2010 – Mar 16, 2010 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

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

Quoted 2 lines

Data access CPLB miss
- Used by the MMU to signal a CPLB miss on a data access.

...

Quoted 4 lines

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

#1 lore raw
Quoted 6 lines · Kolja Waschk

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.

Quoted 10 lines

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

Quoted 2 lines

Data access CPLB miss
- Used by the MMU to signal a CPLB miss on a data access.

...

Quoted 4 lines

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.

Quoted 2 lines

/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?

Quoted 28 lines

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
[email protected]
https://mail.gna.org/listinfo/xenomai-help

Signature · 1 line
Philippe.
#2 lore raw
Quoted 5 lines · Philippe Gerum
Quoted 4 lines · Kolja Waschk

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.

Quoted 8 lines
Quoted 2 lines

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?

Signature · 4 lines
Gilles Chanteperdrix, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#3 lore raw
Quoted 15 lines · Gilles Chanteperdrix
Quoted 5 lines · Philippe Gerum
Quoted 4 lines · Kolja Waschk

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.

Quoted 8 lines
Quoted 2 lines

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.

Quoted 5 lines

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.

Quoted 2 lines
Signature · 1 line
Philippe.
#4 lore raw
Quoted 20 lines · Philippe Gerum
Quoted 13 lines · Gilles Chanteperdrix
Quoted 5 lines · Philippe Gerum
Quoted 4 lines · Kolja Waschk

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.

Quoted 7 lines
Quoted 2 lines

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.

Quoted 5 lines

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?

Quoted 3 lines

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.

Quoted 4 lines
Quoted 2 lines
Signature · 4 lines
Gilles Chanteperdrix, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#5 lore raw
Quoted 25 lines · Gilles Chanteperdrix
Quoted 20 lines · Philippe Gerum
Quoted 13 lines · Gilles Chanteperdrix
Quoted 5 lines · Philippe Gerum
Quoted 4 lines · Kolja Waschk

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.

Quoted 7 lines
Quoted 2 lines

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.

Quoted 5 lines

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?

Quoted 3 lines

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.

Quoted 5 lines

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.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Signature · 1 line
Philippe.
#6 lore raw
Quoted 30 lines · Philippe Gerum
Quoted 20 lines · Gilles Chanteperdrix
Quoted 19 lines · Philippe Gerum
Quoted 18 lines · Gilles Chanteperdrix
Quoted 5 lines · Philippe Gerum
Quoted 4 lines · Kolja Waschk

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.

Quoted 7 lines
Quoted 2 lines

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?

Quoted 8 lines
Quoted 3 lines

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.

Quoted 4 lines

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.

Signature · 4 lines
Gilles Chanteperdrix, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#7 lore raw
Quoted 3 lines

"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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw
Quoted 6 lines · Kolja Waschk
Quoted 2 lines

"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.

Quoted 5 lines

Kolja

Signature · 1 line
Philippe.
#10 lore raw
Quoted 1 line

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

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

Quoted 2 lines

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

#11 lore raw
In reply to Philippe Gerum
Quoted 3 lines
Quoted 1 line

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