RES: RES: Problem using Region Manager with very small segments
Fabrício de Novaes Kucinskis
fabricio at dea.inpe.br
Fri Jul 4 18:15:34 UTC 2008
Hi Joel,
I think I found the source of the error. But first, let me answer:
> Please send me some (simple) code that reproduces this and I
> will look into it.
I tried to create a simpler example which reproduces the error, but
couldn't. The example I created simply doesn't trigger the error.
> Do you have and is this reproducible on tsim? If so, then
> you should be able to set a breakpoint on the address written
> to and see what code does it.
I don't have TSIM. The error is reproducible on SIS, but as the error
involves interruptions I'm very limited in my debugging options. But I could
get deeper and discarded any possible error with the region manager.
Using the stack checker, I got a "stack pointer too low / blown stack"
message, and detected another error: a data access exception in
_Heap_Allocate. So it's clear that there is a memory overwrite somewhere.
Searching the mailing list, I found a discussion about the bug #1237
[http://www.rtems.org/bugzilla/show_bug.cgi?id=1237], which is exactly my
case. I use RTEMS 4.7.1, ERC32 (SPARC) BSP, with no patch.
I'm going to update to a newer version and see if this solves the problem.
Then, I'll send the result.
Thanks again,
Fabrício.
-----Mensagem original-----
De: Joel Sherrill [mailto:joel.sherrill at oarcorp.com]
Enviada em: quinta-feira, 3 de julho de 2008 14:21
Para: Fabrício de Novaes Kucinskis
Cc: 'RTEMS - Mailing List'
Assunto: Re: RES: Problem using Region Manager with very small segments
Fabrício de Novaes Kucinskis wrote:
> Thanks, Joel, I'll create a small example that will reproduce the error,
and
> send it to the list. Meanwhile, I have more information about the
> RTEMS_INVALID_SIZE error that may help understanding it.
>
> I looked inside rtems_region_get_segment, and noticed that the error
happens
> because the value of the_region->maximum_segment_size suddenly turns to
> zero! I don't think this value should change once the region is created,
so
> maybe the memory area to where "*the_region" points is being overwritten.
>
>
You are correct. It should not change after the region is created.
> More info: it appears that the error happens when the caller task is
> interrupted by a UART ISR. Since the interrupt stack uses memory from the
> RTEMS workspace area, is it possible that the interruption is triggering
> such overwrite? I don't think so, since the ERC32 reserves 16KB to the
> interrupt stack, which should be much more than enough - but I don't see
> other reasons for the error.
>
>
Do you have and is this reproducible on tsim? If so, then
you should be able to set a breakpoint on the address written
to and see what code does it.
It is always possible and likely that a blown stack will corrupt
the adjacent objects allocated from the workspace. Since you
are looking at the memory anyway, check the address range of
the Region_Control that is being corrupted and compare it to
the address ranges for the interrupt stack and various tasks.
> Regards,
>
>
> Fabrício.
>
>
> -----Mensagem original-----
> De: Joel Sherrill [mailto:joel.sherrill at oarcorp.com]
> Enviada em: quinta-feira, 3 de julho de 2008 09:46
> Para: Fabrício de Novaes Kucinskis
> Cc: 'RTEMS - Mailing List'
> Assunto: Re: Problem using Region Manager with very small segments
>
> Please send me some (simple) code that reproduces this and I
> will look into it.
>
> --joel
>
> Fabrício de Novaes Kucinskis wrote:
>
>> Hello all,
>>
>>
>> I have an ERC32 application, in which I create a Region with length = 512
>> bytes and page_size = 8 bytes.
>>
>> The RTEMS User Manual says that the page_size shall be a multiple of four
>> greater or equal four, but if I try to create a region with page_size = 4
>>
> I
>
>> got a "RTEMS_INVALID_PAGE_SIZE" error. Using page_size = 8 there is no
>>
> error
>
>> but, when I ask for a segment of, say, 5 bytes, I got a 12 byte-segment,
>>
> and
>
>> not a 8 byte-segment, as would be expected.
>>
>> Furthermore, I'm having a weird problem, and that's the main reason for
>>
> this
>
>> call for help: normally I ask for segments of 2 to 16 bytes. The
>>
> application
>
>> seems to work properly, but sometimes I got a RTEMS_INVALID_SIZE error
(do
>> not confuse with RTEMS_UNSATISFIED).
>>
>> The strange thing here is that I got this error when asking for a
>>
> three-byte
>
>> segment, when only two segments of no more than 24 bytes are allocated.
>> RTEMS_INVALID_SIZE should occur only when the size of the segment is zero
>>
> or
>
>> greater than the maximum segment possible, which is not the case.
>>
>> I checked, and my application doesn't write outside the segments
>>
> boundaries,
>
>> so I don't think the region is corrupted. Could be then some problem with
>> the segment's overhead? The manual states that there is an overhead for
>>
> each
>
>> segment, but it lacks information about the size of such overhead. I know
>>
> it
>
>> is not possible to calculate the number of bytes available in a region,
>>
> but
>
>> what is the overhead per segment?
>>
>> Any help or additional information will be greatly appreciated.
>> Thanks in advance and best regards,
>>
>>
>> Fabrício de Novaes Kucinskis - DEA / INPE
>> -----------------------------------------------
>> Onboard Data Handling Group - SUBORD
>> Aerospace Electronics Division
>> Brazilian National Institute for Space Research
>>
>> _______________________________________________
>> rtems-users mailing list
>> rtems-users at rtems.com
>> http://rtems.rtems.org/mailman/listinfo/rtems-users
>>
>>
>
>
> --
> Joel Sherrill, Ph.D. Director of Research & Development
> joel.sherrill at OARcorp.com On-Line Applications Research
> Ask me about RTEMS: a free RTOS Huntsville AL 35805
> Support Available (256) 722-9985
>
>
>
--
Joel Sherrill, Ph.D. Director of Research & Development
joel.sherrill at OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
More information about the users
mailing list