From: Dan Williams <dan.j.williams@intel.com>
To: steve@digidescorp.com
Cc: Dan Carpenter <error27@gmail.com>,
David Rientjes <rientjes@google.com>,
linux-kernel@vger.kernel.org, microblaze-uclinux@itee.uq.edu.au,
Dave Hansen <dave@linux.vnet.ibm.com>
Subject: Re: Buggy variable-length array code...or compiler?
Date: Fri, 26 Feb 2010 12:43:10 -0700 [thread overview]
Message-ID: <e9c3a7c21002261143w9a4cc29ha738e84496ef5c4c@mail.gmail.com> (raw)
In-Reply-To: <1267211701.3124.204.camel@iscandar.digidescorp.com>
On Fri, Feb 26, 2010 at 12:15 PM, Steven J. Magnani
<steve@digidescorp.com> wrote:
> On Thu, 25 Feb 2010, Steven J. Magnani wrote:
>> >
>> > > When I run a memcpy dmatest with a Microblaze 2.6.33 noMMU kernel, the
>> > > system crashes after about 400 iterations. After much head scratching, I
>> > > believe I've narrowed the problem to this fragment of code in
>> > > drivers/dma/dmatest.c:
>> > >
>> > > static int dmatest_func(void *data)
>> > > {
>> > > ...
>> > > int src_cnt;
>> > > int dst_cnt;
>> > > ...
>> > > if (thread->type == DMA_MEMCPY)
>> > > src_cnt = dst_cnt = 1;
>> > > ...
>> > > while (!kthread_should_stop()
>> > > && !(iterations && total_tests >= iterations)) {
>> > > ...
>> > > dma_addr_t dma_srcs[src_cnt];
>> > > dma_addr_t dma_dsts[dst_cnt];
>> > > ...
>
> On Thu, Feb 25, 2010 at 03:46:48PM -0800, David Rientjes wrote:
>> > This could probably become the first kernel user of the flexible array
>> > library (see Documentation/flexible-arrays.txt). Dan?
>> > --
>
> On Fri, 2010-02-26 at 13:27 +0300, Dan Carpenter wrote:
>> I think the max that src_cnt can be is 3 and the most dst_cnt can be is 2.
>> We could just put that there.
>
> src_cnt is dependent on module parameters.
>
> The bug goes away if dma_srcs and dma_dsts are declared outside the
> loop, but that requires knocking the loop in another tabstop. At that
> point dmatest_func() would be begging for refactoring.
>
...and even if you refactored it there is no guarantee that gcc would
not re-inline the functions and put you back in the same situation.
Especially given the finding that J.A.'s simple test, where the size
of the array should have been constant, still failed.
--
Dan
next prev parent reply other threads:[~2010-02-26 19:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-25 23:17 Steven J. Magnani
2010-02-25 23:23 ` Samuel Thibault
2010-02-25 23:46 ` David Rientjes
2010-02-26 10:27 ` Dan Carpenter
2010-02-26 19:15 ` Steven J. Magnani
2010-02-26 19:43 ` Dan Williams [this message]
2010-02-26 0:46 ` J.A. Magallón
2010-02-26 17:43 ` Samuel Thibault
2010-02-26 18:52 ` Steven J. Magnani
2010-02-26 10:11 ` Dan Carpenter
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=e9c3a7c21002261143w9a4cc29ha738e84496ef5c4c@mail.gmail.com \
--to=dan.j.williams@intel.com \
--cc=dave@linux.vnet.ibm.com \
--cc=error27@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=microblaze-uclinux@itee.uq.edu.au \
--cc=rientjes@google.com \
--cc=steve@digidescorp.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®