[llvm-bugs] [Bug 28453] New: Abort trap: 6 libc++abi.dylib: terminating with uncaught exception of type std::bad_alloc: std::bad_alloc

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 7 07:23:54 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=28453

            Bug ID: 28453
           Summary: Abort trap: 6 libc++abi.dylib: terminating with
                    uncaught exception of type std::bad_alloc:
                    std::bad_alloc
           Product: libc++abi
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: mr.chinmoy.dey at gmail.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
    Classification: Unclassified

Abort and malloc is failing while changing return value of the following
compareStr function. 

================================================
[07:52 PM] chinmoy.dey at CDEY-MBP Array $ ./a.out
\ [ ram ]  [ pot ]  [ mar ]  [ top ]  [ arm ]  [ opt ]  [ ram ]
a.out(17254,0x7fff7a158000) malloc: *** mach_vm_map(size=18446603775050240000)
failed (error code=3)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
libc++abi.dylib: terminating with uncaught exception of type std::bad_alloc:
std::bad_alloc
Abort trap: 6
==========================================

[07:58 PM] chinmoy.dey at CDEY-MBP Array $ uname -a
Darwin CDEY-MBP 15.4.0 Darwin Kernel Version 15.4.0: Fri Feb 26 22:08:05 PST
2016; root:xnu-3248.40.184~3/RELEASE_X86_64 x86_64

==========================================


bool compareStr(string a, string b){
    int arr[256] = {0};

    for(int i=0; i<a.size(); i++){
        arr[a[i]] = arr[a[i]] + 1;
    }
    for (int i=0; i<b.size(); i++ ){
        arr[b[i]] = arr[b[i]] - 1;
    }

    for (int i=0; i<256; i++){
        if(arr[i] != 0){
            return false; <-------ABORT: Make it true.
        }
    }
    return true; <-------and Make it false.
}


code
====
string input []= {"ram", "pot", "mar", "top", "arm", "opt", "ram"};
vector<string>  strVector(input, end(input));
sort(strVector.begin(), strVector.end(), compareStr);

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160707/45b9ef32/attachment.html>


More information about the llvm-bugs mailing list