
Hi Roberto, One thing I forgot to mention is that the host I'm building for is mingw not Cygwin but I am building under Cygwin. I had to install a 32 bit Cygwin to run memory2 under gdb and I have it failing in what looks like the same way. It looks like it might be a compiler issue. It gets into Parma_Polyhedra_Library::Init::Init() and the call there to ppl_set_GMP_memory_allocation_functions looks strange.
. . . Dump of assembler code for function Parma_Polyhedra_Library::Init::Init(): => 0x004044a0 <+0>: mov 0x4f83c4,%eax 0x004044a5 <+5>: lea 0x1(%eax),%edx 0x004044a8 <+8>: test %eax,%eax 0x004044aa <+10>: mov %edx,0x4f83c4 0x004044b0 <+16>: je 0x4044b4 <Parma_Polyhedra_Library::Init::Init()+20> 0x004044b2 <+18>: repz ret 0x004044b4 <+20>: sub $0x1c,%esp 0x004044b7 <+23>: call 0x401f50 <(anonymous namespace)::cxx_realloc(void*, size_t, size_t)+816> # This should be a call to ppl_set_GMP_memory_allocation_functions() 0x004044bc <+28>: movl $0x41ef40,0x4f844c 0x004044c6 <+38>: call 0x434ba0 <Parma_Polyhedra_Library::Coefficient_constants_initialize()> 0x004044cb <+43>: call 0x40ca00 <Parma_Polyhedra_Library::Linear_Expression::initialize()> 0x004044d0 <+48>: call 0x40d830 <Parma_Polyhedra_Library::Constraint::initialize()>
A disassembly of 0x401f50 results in: 0x00401f4f <+815>: movl $0x4cc130,0x4(%esp) 0x00401f57 <+823>: jmp 0x401f08 <(anonymous namespace)::cxx_realloc(void*, size_t, size_t)+744> 0x00401f59 <+825>: call 0x4849c8 <_ZSt16__throw_bad_castv>
And when I step into the call I get: (anonymous namespace)::cxx_realloc (q=0x6578652e, old_size=0, new_size=0) at memory2.cc:116 116 << endl; 2: /x $ebx = 0x28fe41 1: x/i $pc => 0x401f59 <(anonymous namespace)::cxx_realloc(void*, size_t, size_t)+825>: call 0x4849c8 <_ZSt16__throw_bad_castv>
I noticed that ppl_set_GMP_memory_allocation_functions is declared weak in src/Init.cc and maybe the compiler/linker is having trouble resolving the symbol. I'm continuing to investigate and I'll keep you posted.
And by the way setting a break in __cxa_throw didn't get caught.
Thanks, Keith
-----Original Message----- From: Roberto Bagnara [mailto:bagnara@cs.unipr.it] Sent: July 29, 2014 12:03 AM To: kclifford@tranaptic.ca Cc: The Parma Polyhedra Library developers' list Subject: Re: [PPL-devel] Failure building ppl under Cygwin 64 with a mingw target.
Hello Keith.
On 07/29/14 05:27, Keith Clifford wrote:
I set the environment variables as you requested and didn't get any
output.
I commented out ppl_set_GMP_memory_allocation_functions and got the following output:
$ ./memory2 test1() test2() **************** k = 4294967295 **************** *************** dry run *************** **************** k = 0 **************** test3() **************** k = 4294967295 **************** *************** dry run *************** **************** k = 0 ****************
With ppl_set_GMP_memory_allocation_functions back in and some debugging added I didn't see any of the debugging before the segfault:
$ ./memory2 Segmentation fault
Modified ppl_set_GMP_memory_allocation_functions:
extern "C" void ppl_set_GMP_memory_allocation_functions() { before_main = true;
nout << "ppl_set_GMP_memory_allocation_functions!" << endl; // Allow the static coefficients of the library to be allocated // without any limit. reset_allocators(ULONG_MAX, ULONG_MAX); mp_set_memory_functions(cxx_malloc, cxx_realloc, cxx_free);
}
I rebuilt with --enable-debugging and ran under strace with the following results:
$ strace memory2
This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. terminate called after throwing an instance of 'std::bad_cast' what(): std::bad_cast --- Process 7044, exception 4000001f at 000000007704103B
Does any of this help?
Yes. Can you please have a session with gdb in order to understand where the std::bad_cast exception is thrown? You can do this by setting a breakpoint at __cxa_throw. Thanks,
Roberto
-----Original Message----- From: Roberto Bagnara [mailto:bagnara@cs.unipr.it] Sent: July 26, 2014 1:00 AM To: kclifford@tranaptic.ca Cc: The Parma Polyhedra Library developers' list Subject: Re: [PPL-devel] Failure building ppl under Cygwin 64 with a mingw target.
Hello Keith, thanks for the report.
On 07/25/14 20:18, Keith Clifford wrote:
I'm building a set of cross compilers to run under mingw and I got the
error below.
The set of packages and their versions to do the build are:
Build machine:
CYGWIN_NT-6.1 1.7.31(0.272/5/3) 2014-07-21 18:40 x86_64 Cygwin
Components:
gmp-6.0.0a mpfr-3.1.2 mpc-1.0.2 isl-0.12.2 cloog-0.18.1 ppl-1.1 binutils-2.24 gcc-4.9.1 newlib-2.1.0 gdb-7.7
I've attached the script, mkx, that I use for building the cross compilers, the test-suit log, and the make and check logs. The individual test logs are empty. I'm set up to run so if you'd like me to try anything, let me know and I can give it a go. When the build failed it said let you know and I'm going to continue investigating. I'll let you know if I find anything.
As far as I can tell, building the PPL succeeded and only one test failed (memory2 in tests/Polyhedron). Can you please rerun just that test after defining the environment variables PPL_NOISY_TESTS and PPL_VERY_NOISY_TESTS to whatever you like? Then please send the resulting output to ppl-devel@cs.unipr.it King regards,
Roberto