It's crashing in the destructor of the std::string variable in the function, probably because you freed or corrupted the memory that the string owns. Trying using Asan or valgrind, if they work on cygwin. On Thu, 19 Jun 2025, 21:26 skidmarks, <home@xxxxxxxxxxxx> wrote: > Win 11-64 Pro > Cygwin 3.7.0 > g++ 15.1.1 > gdb (Cygwin 15.2-1) 15.2 > > I'm trying to track down an error in my code which produces an abort on > a return statement. I don't understand why I get an abort on a return > statement. The other puzzler is that the function was successful on two > prior executions and failed on the third. I don't know what I did wrong. > > The code is given below plus a few steps and backtraces from gdb. I'm > stumped on this. > > ==================== code =================== > > bool runTest(SlipHeader& out, const string& testName) { > string list = string(); > out.write(list); > SlipHeader& in = SlipHeader::read(list, true); > bool flag = compareLists(in, out); > if (!flag) writeDiagnostics(__FILE__, list); > testResultOutput(testName, 0.0, flag); > in.deleteList(); > return flag; > }; // bool runTest(SlipHeader&SlipHeader& out, const string& testName) > > ==================== gdb ==================== > > Thread 1 "sliptest" hit Breakpoint 17, runTest (out=..., testName=...) > at TestIO.cpp:134 > 134 return flag; > (gdb) bt > #0 runTest (out=..., testName=...) at TestIO.cpp:134 > #1 0x000000010040c8d5 in testListMark () at TestIO.cpp:190 > #2 0x000000010040d428 in testIO () at TestIO.cpp:315 > #3 0x000000010040129b in main (argc=1, argv=0xa00002110) at > SlipTest.cpp:101 > (gdb) s > 135 }; // bool runTest(SlipHeader&SlipHeader& out, const string& > testName) > (gdb) bt > #0 runTest (out=..., testName=...) at TestIO.cpp:135 > #1 0x000000010040c8d5 in testListMark () at TestIO.cpp:190 > #2 0x000000010040d428 in testIO () at TestIO.cpp:315 > #3 0x000000010040129b in main (argc=1, argv=0xa00002110) at > SlipTest.cpp:101 > (gdb) s > std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::~basic_string ( > this=0x7ffffc7f8) at > /usr/lib/gcc/x86_64-pc-cygwin/15/include/c++/bits/cow_string.h:759 > 759 { _M_rep()->_M_dispose(this->get_allocator()); } > (gdb) bt > #0 std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::~basic_string ( > this=0x7ffffc7f8) at > /usr/lib/gcc/x86_64-pc-cygwin/15/include/c++/bits/cow_string.h:759 > #1 0x000000010040be59 in runTest (out=..., testName=...) at TestIO.cpp:135 > #2 0x000000010040c8d5 in testListMark () at TestIO.cpp:190 > #3 0x000000010040d428 in testIO () at TestIO.cpp:315 > #4 0x000000010040129b in main (argc=1, argv=0xa00002110) at > SlipTest.cpp:101 > (gdb) s > [New Thread 12564.0x7980] > std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::_M_rep (this=0x7ffffc7f8) > at /usr/lib/gcc/x86_64-pc-cygwin/15/include/c++/bits/cow_string.h:338 > 338 { return &((reinterpret_cast<_Rep*> (_M_data()))[-1]); } > (gdb) bt > #0 std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::_M_rep ( > this=0x7ffffc7f8) at > /usr/lib/gcc/x86_64-pc-cygwin/15/include/c++/bits/cow_string.h:338 > #1 0x000000010047feab in std::basic_string<char, > std::char_traits<char>, std::allocator<char> >::~basic_string > (this=0x7ffffc7f8) > at /usr/lib/gcc/x86_64-pc-cygwin/15/include/c++/bits/cow_string.h:759 > #2 0x000000010040be59 in runTest (out=..., testName=...) at TestIO.cpp:135 > #3 0x000000010040c8d5 in testListMark () at TestIO.cpp:190 > #4 0x000000010040d428 in testIO () at TestIO.cpp:315 > #5 0x000000010040129b in main (argc=1, argv=0xa00002110) at > SlipTest.cpp:101 > (gdb) s > std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::_M_data (this=0x7ffffc7f8) > at /usr/lib/gcc/x86_64-pc-cygwin/15/include/c++/bits/cow_string.h:330 > 330 { return _M_dataplus._M_p; } > (gdb) bt > #0 std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::_M_data ( > this=0x7ffffc7f8) at > /usr/lib/gcc/x86_64-pc-cygwin/15/include/c++/bits/cow_string.h:330 > #1 0x000000010047df48 in std::basic_string<char, > std::char_traits<char>, std::allocator<char> >::_M_rep > (this=0x7ffffc7f8) at > /usr/lib/gcc/x86_64-pc-cygwin/15/include/c++/bits/cow_string.h:338 > #2 0x000000010047feab in std::basic_string<char, > std::char_traits<char>, std::allocator<char> >::~basic_string > (this=0x7ffffc7f8) > at /usr/lib/gcc/x86_64-pc-cygwin/15/include/c++/bits/cow_string.h:759 > #3 0x000000010040be59 in runTest (out=..., testName=...) at TestIO.cpp:135 > #4 0x000000010040c8d5 in testListMark () at TestIO.cpp:190 > #5 0x000000010040d428 in testIO () at TestIO.cpp:315 > #6 0x000000010040129b in main (argc=1, argv=0xa00002110) at > SlipTest.cpp:101 > (gdb) c > Continuing. > > Thread 1 "sliptest" received signal SIGABRT, Aborted. > 0x00007ffd56b21b84 in ntdll!ZwWaitForSingleObject () from > /Windows/SYSTEM32/ntdll.dll > (gdb) bt > #0 0x00007ffd56b21b84 in ntdll!ZwWaitForSingleObject () from > /Windows/SYSTEM32/ntdll.dll > #1 0x00007ffd543bd26f in WaitForSingleObjectEx () from > /Windows/System32/KERNELBASE.dll > #2 0x00007ffc9ef4b892 in sigfillset () from /usr/bin/cygwin1.dll > #3 0x00007ffc9ef47b1e in sched_getscheduler () from /usr/bin/cygwin1.dll > #4 0x00007ffc9ef47ef9 in sched_getscheduler () from /usr/bin/cygwin1.dll > #5 0x00007ffc9f099078 in cygwin1!abort () from /usr/bin/cygwin1.dll > #6 0x00007ffc9f0991a5 in cygwin1!abort () from /usr/bin/cygwin1.dll > #7 0x00007ffc9f0012ea in truncl () from /usr/bin/cygwin1.dll > #8 0x00007ffc9f01cda4 in timegm () from /usr/bin/cygwin1.dll > #9 0x0000000000001022 in ?? () > #10 0x0000000a00000000 in ?? () > #11 0x0000000000000000 in ?? () > >