From: Christoph Permes <christoph.permes@domain.hid>
To: Jan Kiszka <jan.kiszka@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] Segmentation fault in rt_printf print thread
Date: Thu, 27 Aug 2009 14:00:43 +0200 [thread overview]
Message-ID: <1251374443.4321.40.camel@domain.hid> (raw)
In-Reply-To: <4A9642D3.5040304@domain.hid>
Hi,
I have examined the print_buffers() function and my core dump:
#1 0xb8087f61 in print_buffers () at rt_print.c:380
380 fprintf(head->dest, "%s", head->text);
(gdb) print head->dest
$1 = (FILE *) 0x445b205d
(gdb) print head->text
$2 = "_"
(gdb) print (char*)head
$3 = 0x8ea5a02 "] [D] [V_MainClampToteRequest ] ===> [1]\n"
(gdb) print buffer->read_pos
$4 = 3482
(gdb) print *(char*)buffer->ring@domain.hid
$5 = "... [67046.506] [CONTROL] [1104820] [\000] [D] [V_MainClamp"
As the above output shows the head pointer points to a wrong memory
address, the head->dest FILE pointer results from some text written to
the buffer.
buffer = get_next_buffer();
if (!buffer)
break;
read_pos = buffer->read_pos;
head = buffer->ring + read_pos;
len = strlen(head->text);
if (len) {
/* Print out non-empty entry and proceed */
fprintf(head->dest, "%s", head->text); // ==> SEGV
read_pos += sizeof(*head) + len;
} else {
/* Emptry entries mark the wrap-around */
read_pos = 0;
}
Obviously the value of buffer->read_pos is not correct or the buffer
pointer returned by get_next_buffer() points to a wrong address.
Christoph
Am Donnerstag, den 27.08.2009, 10:24 +0200 schrieb Jan Kiszka:
> Christoph Permes wrote:
> > Am Mittwoch, den 26.08.2009, 10:12 +0200 schrieb Gilles Chanteperdrix:
> >> Christoph Permes wrote:
> >>> Hi,
> >>>
> >>> I'm using rt_printf for debug output. When running tests for 20 hours or
> >>> longer, sometimes I get a segmentation fault.
> >>>
> >>> The backtrace shows:
> >>> #0 0xb7d008d8 in fputs () from /lib/libc.so.6
> >>> #1 0xb7f26f61 in print_buffers () from /usr/xenomai/lib/librtdk.so.0
> >>> #2 0xb7f26fb3 in printer_loop () from /usr/xenomai/lib/librtdk.so.0
> >>> #3 0xb7c92f3b in start_thread () from /lib/libpthread.so.0
> >>> #4 0xb7d6fb6e in clone () from /lib/libc.so.6
> >>>
> >>> It seems to me that there is a bug in the print thread.
> >>>
> >>> My program runs on x86 using the following software versions:
> >>> Kernel 2.6.29.5
> >>> Xenomai 2.4.9
> >>> I-Pipe patch: adeos-ipipe-2.6.29.5-x86-2.4-02.patch
> >> Could you try the following patch?
> >>
> >> diff --git a/src/rtdk/rt_print.c b/src/rtdk/rt_print.c
> >> index 0615247..a0aeec3 100644
> >> --- a/src/rtdk/rt_print.c
> >> +++ b/src/rtdk/rt_print.c
> >> @@ -422,6 +422,7 @@ void __rt_print_init(void)
> >> pthread_attr_t thattr;
> >> const char *value_str;
> >> unsigned long long period;
> >> + unsigned stksize;
> >>
> >> first_buffer = NULL;
> >> seq_no = 0;
> >> @@ -457,6 +458,9 @@ void __rt_print_init(void)
> >> pthread_cond_init(&printer_wakeup, NULL);
> >>
> >> pthread_attr_init(&thattr);
> >> - pthread_attr_setstacksize(&thattr, PTHREAD_STACK_MIN);
> >> + stksize = 32768;
> >> + if (stksize < PTHREAD_STACK_MIN)
> >> + stksize = PTHREAD_STACK_MIN;
> >> + pthread_attr_setstacksize(&thattr, stksize);
> >> pthread_create(&printer_thread, &thattr, printer_loop, NULL);
> >> }
> >>
> >
> > I have tried the patch but it crashed again with the same backtrace.
>
> Could you try to find out, what memory access is precisely causing the
> SEGV? Maybe even what variables of the rt_printf code have invalid
> states? Or do you have a portable test case for us to reproduce the issue?
>
> Thanks,
> Jan
>
next prev parent reply other threads:[~2009-08-27 12:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-26 8:01 [Xenomai-help] Segmentation fault in rt_printf print thread Christoph Permes
2009-08-26 8:12 ` Gilles Chanteperdrix
2009-08-27 6:24 ` Christoph Permes
2009-08-27 8:24 ` Jan Kiszka
2009-08-27 12:00 ` Christoph Permes [this message]
2009-08-28 7:38 ` Jan Kiszka
2009-08-28 8:38 ` Christoph Permes
2009-08-28 9:07 ` Jan Kiszka
2009-08-31 8:09 ` Christoph Permes
2009-09-07 7:35 ` Christoph Permes
2009-09-07 8:43 ` Jan Kiszka
2009-09-07 8:58 ` Gilles Chanteperdrix
2009-09-07 9:17 ` Jan Kiszka
2009-09-09 11:42 ` Gilles Chanteperdrix
2009-09-09 11:58 ` Gilles Chanteperdrix
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1251374443.4321.40.camel@domain.hid \
--to=christoph.permes@domain.hid \
--cc=jan.kiszka@domain.hid \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.