[botan-devel] Cygwin failure creating initialization vector

William K. Foster wkf at alum.mit.edu
Mon Feb 21 14:55:26 EST 2011


Hello Jack,

I find that it is a specific rng that is corrupted, a newly created rng
works fine.

On stackoverflow, someone pointed out that we have no copy constructor for
AutoSeeded_RNG and it has a pointer which if copied to a new object could go
away if the original object was destructed.

So perhaps that is what is going on here.

I am looking into this line of thought now with a copy constructor defined
to make a new object instead of copying the old.

Certainly for robustness, the code should be updated to define a copy ctor
and an operator= since the default bit copy ones will give bad result of
copied pointer.

Thanks.

-William


On Mon, Feb 21, 2011 at 10:23 AM, Jack Lloyd <lloyd at randombit.net> wrote:

> Hi William,
>
> Is it possible that somewhere between where your code runs and where
> the library is initialized, the library is either shutdown, or the
> internal state is corrupted somehow? That could explain why it works
> from main but not in a later function call...
>
> Perhaps in AutoSeeded_RNG::AutoSeeded_RNG
> (src/rng/auto_rng/auto_rng.cpp) add debug output to ensure that the
> constructor is actually running, and that the rng pointer is not being
> modified?
>
> Also: before calling rng.randomize, try writing to the buffer (eg
> iv_val[0] = 0;) first; since it's not entirely clear from this
> backtrace which pointer is invalid (though the rng certainly seems
> like the likely candidate).
>
> -Jack
>
>
> On Mon, Feb 21, 2011 at 09:51:33AM -0800, William K. Foster wrote:
> > Hi Jack,
> >
> > I got the debugger working (issue was I was looking at wrong thread by
> > default).
> >
> > Now that I have the debugger working I see segv:
> >
> > (gdb) s
> > Botan::AutoSeeded_RNG::randomize (this=0x1270380, out=0x5841420 "",
> len=1)
> >     at ../../src/Botan-1.8.11/build/include/botan/auto_rng.h:23
> > (gdb) s
> >
> > Program received signal SIGSEGV, Segmentation fault.
> > 0x005d79ee in Botan::AutoSeeded_RNG::randomize (this=0x1270380,
> >     out=0x5841420 "", len=1)
> >     at ../../src/Botan-1.8.11/build/include/botan/auto_rng.h:23
> > (gdb) p rng
> > $7 = (class Botan::RandomNumberGenerator *) 0x5841324
> > (gdb) p *this
> > $8 = {<Botan::RandomNumberGenerator> = {
> >     _vptr$RandomNumberGenerator = 0x11efc14}, rng = 0x5841324}
> >
> > Thanks.
> >
> > -William
> >
> > On Mon, Feb 21, 2011 at 9:23 AM, William K. Foster <wkf at alum.mit.edu>
> wrote:
> >
> > > Hello Jack,
> > >
> > > I lowered the size down to 16 and it still fails.
> > >
> > > I added a try catch block around the code, and no exception is caught.
> > >
> > > I changed the code to what you show below, and the failure occurs
> inside
> > > the last line:
> > >
> > >
> > >     _rng.randomize(&iv_val[0], size);
> > >
> > > I also tried size 1 and it also fails the same way.
> > >
> > > Finally, I moved the code to the beginning of main() and it works fine.
>  So
> > > something is going wrong elsewhere that causes this to fail later.  How
> can
> > > we track this down best?
> > >
> > > Thanks.
> > >
> > > -William
> > >
> > >
> _______________________________________________
> botan-devel mailing list
> botan-devel at randombit.net
> http://lists.randombit.net/mailman/listinfo/botan-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.randombit.net/pipermail/botan-devel/attachments/20110221/92d56bc6/attachment.html>


More information about the botan-devel mailing list