<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Abort trap: 6 libc++abi.dylib: terminating with uncaught exception of type std::bad_alloc: std::bad_alloc"
href="https://llvm.org/bugs/show_bug.cgi?id=28453">28453</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Abort trap: 6 libc++abi.dylib: terminating with uncaught exception of type std::bad_alloc: std::bad_alloc
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++abi
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</td>
</tr>
<tr>
<th>OS</th>
<td>MacOS X
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mr.chinmoy.dey@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Abort and malloc is failing while changing return value of the following
compareStr function.
================================================
[07:52 PM] chinmoy.dey@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@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);</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>