[Haskell-beginners] Strange Failure in extern code via FFI - SOLVED
Nathan Hüsken
nathan.huesken at posteo.de
Fri Sep 13 13:14:22 CEST 2013
Never mind.
I did something wrong at some other C++ code I called via the FFI. There
I did something that corrupted the memory.
I found out using valgrind.
So, not haskell related and solved. Sorry for the bother.
Regards,
Nathan
On 09/13/2013 01:05 PM, Nathan Hüsken wrote:
> Hey,
>
> I have C++ code which works perfectly when compiled in C++ program. Now
> I want to call this C++ code from haskell via FFI. When doing so, I get
> this error in a HUnit test program:
>
> test-rf: malloc.c:2369: sysmalloc: Assertion `(old_top == (((mbinptr)
> (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct
> malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >=
> (unsigned long)((((__builtin_offsetof (struct malloc_chunk,
> fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) -
> 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask)
> == 0)' failed.
>
> Something wrong with memory allocation I guess. The code I am running is
> complex and not mine. But I ran gdb over the problem and the error
> occurs at this code:
>
> data = alloc_.allocate(capacity);
>
> gdb tells me, that capacity==2, so it does not seem to be an out of
> memory error. Also about alloc_, gdb tells me:
>
> (gdb) p alloc_
> $3 = {<__gnu_cxx::new_allocator<unsigned int>> = {<No data fields>}, <No
> data fields>}
>
> The stack frames above the shown code are:
>
> #0 0x00007ffff69a8037 in raise () from /lib/x86_64-linux-gnu/libc.so.6
> #1 0x00007ffff69ab698 in abort () from /lib/x86_64-linux-gnu/libc.so.6
> #2 0x00007ffff69efb7a in ?? () from /lib/x86_64-linux-gnu/libc.so.6
> #3 0x00007ffff69f306c in ?? () from /lib/x86_64-linux-gnu/libc.so.6
> #4 0x00007ffff69f4580 in malloc () from /lib/x86_64-linux-gnu/libc.so.6
> #5 0x00007ffff7b3666d in operator new(unsigned long) () from
> /usr/lib/x86_64-linux-gnu/libstdc++.so.6
> #6 0x000000000040dbd0 in allocate (__n=2, this=0x7fffffff9a48) at
> /usr/include/c++/4.7/ext/new_allocator.h:94
>
> So ... it seems to be something with the new_allocator ...
> Maybe I am doing something different than in the C++ code, but I do not
> know what so I am suspecting it has something to do with the haskell FFI.
>
> Any Ideas?
> Thanks!
> Nathan
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
More information about the Beginners
mailing list