How to fix "A debugging check in this application failed" codeblocks? - c++
I was working on a project in Codeblocks, but at one point when I wanted to Run it, the Debug window just remained empty.I thought that it was just an infinite thing, but while I was looking at it, it showed this, sayng that "A debugging check in this application failed".If I pressed "Continue" it would let me go and it would give me the result, but when I tried to debug the code, it said the same thing, and afterwards it wouldn't let me debug.
Here is the code:
#include <fstream>
using namespace std;
ifstream fin("forta.in");
ofstream fout("forta.out");
int main()
{
int p,n,maxx=0;
long long x,minn=2000000000;
fin>>p>>n;
if(p==1)
{
for(int i=0; i<n; i++)
{
fin>>x;
long long divt=1,p,cx=x,m=0;
long long frp[x+1], prim[x+1];
frp[0]=0;
frp[1]=0;
for(int i=2; i<=x; i++)
frp[i]=1;
for(int i=2; i<=x; i++)
{
if(frp[i]==1)
{
prim[m++] =i; ///stochez nr prime
for(int j=i+i; j<=x; j=j+i)
frp[j]=0;
}
}
for(int i=0; i<m ; i++) /// sirul de nr prime
{
p=0;
while(x%prim[i]==0)
{
p++;
x=x/prim[i];
}
divt=divt*(p+1);
}
if(divt>maxx)
{
maxx=divt;
minn=cx;
}
else if(divt==maxx)
{
if(cx<minn)
minn=cx;
}
}
fout<<minn;
}
if(p==2)
{
int fr[20000]= {0}, maxx=0;
for(int i=0; i<n; i++)
{
fin>>x;
long long divt=1,p,cx=x,m=0;
long long frp[x+1], prim[x+1];
frp[0]=0;
frp[1]=0;
for(int i=2; i<=x; i++)
frp[i]=1;
for(int i=2; i<=x; i++)
{
if(frp[i]==1)
{
prim[++m] =i; ///stochez nr prime
for(int j=i+i; j<=x; j=j+i)
frp[j]=0;
}
}
for(int i=0; i<m ; i++) /// sirul de nr prime
{
p=0;
while(x%prim[i]==0)
{
p++;
x=x/prim[i];
}
divt=divt*(p+1);
}
fr[divt]++; /// frecventa pe nr de div
if(maxx<fr[divt])
maxx=fr[divt];
}
fout<<maxx;
}
return 0;
}
It all goes well until "fout<<minn;"(line 54)
I wonder what caused that error and how to fix it.
P.S.
Here is the debug log:
Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\Users\Tudor\CodeBlocks\OJI_2020_A6-A_forta\
Adding source dir: C:\Users\Tudor\CodeBlocks\OJI_2020_A6-A_forta\
Adding file: C:\Users\Tudor\CodeBlocks\OJI_2020_A6-A_forta\bin\Debug\OJI_2020_A6-A_forta.exe
Changing directory to: C:/Users/TT/CodeBlocks/OJI_2020_A6-A_forta/.
Set variable: PATH=.;C:\Program Files\CodeBlocks\MinGW\bin;C:\Program Files\CodeBlocks\MinGW;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Users\TT\AppData\Local\Programs\Python\Python37\Scripts;C:\Users\TT\AppData\Local\Programs\Python\Python37
[debug]Command-line: C:\Program Files\CodeBlocks\MINGW\bin\gdb.exe -nx -fullname -quiet -args C:/Users/TT/CodeBlocks/OJI_2020_A6-A_forta/bin/Debug/OJI_2020_A6-A_forta.exe
[debug]Working dir : C:\Users\TT\CodeBlocks\OJI_2020_A6-A_forta
Starting debugger: C:\Program Files\CodeBlocks\MINGW\bin\gdb.exe -nx -fullname -quiet -args C:/Users/TT/CodeBlocks/OJI_2020_A6-A_forta/bin/Debug/OJI_2020_A6-A_forta.exe
done
[debug]Reading symbols from C:/Users/TT/CodeBlocks/OJI_2020_A6-A_forta/bin/Debug/OJI_2020_A6-A_forta.exe...
[debug]done.
[debug](gdb)
[debug]> set prompt >>>>>>cb_gdb:
Setting breakpoints
[debug]>>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 8.1
[debug]Copyright (C) 2018 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law. Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "x86_64-w64-mingw32".
[debug]Type "show configuration" for configuration details.
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]Find the GDB manual and other documentation resources online at:
[debug]<http://www.gnu.org/software/gdb/documentation/>.
[debug]For help, type "help".
[debug]Type "apropos word" to search for commands related to "word".
[debug]>>>>>>cb_gdb:
[debug]> set confirm off
Debugger name and version: GNU gdb (GDB) 8.1
[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 200
[debug]>>>>>>cb_gdb:
[debug]> set new-console on
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor att
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> directory C:/Users/TT/CodeBlocks/OJI_2020_A6-A_forta/
[debug]Source directories searched: C:/Users/Tudor/CodeBlocks/OJI_2020_A6-A_forta;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> break "C:/Users/TT/CodeBlocks/OJI_2020_A6-A_forta/main2.cpp:54"
[debug]Breakpoint 2 at 0x401925: file C:\Users\TT\CodeBlocks\OJI_2020_A6-A_forta\main2.cpp, line 54.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: C:\Users\TT\CodeBlocks\OJI_2020_A6-A_forta\bin\Debug\OJI_2020_A6-A_forta.exe
Child process PID: 6060
[debug][New Thread 6060.0x1624]
Related
I am doing Unit Testing in QT test for c++, I am getting Fatal error?
The detailed problem is given here void HostManagerTesting::TestAstmIsrGet() { cout<<"\n//*** "<<__func__<<" func called ***//\n"<<endl; int iReturn; cout<<"\n________________Case_1________________\n"<<endl; Astm_obj.ut_set_AstmIsrGet(100); iReturn=Astm_obj.AstmIsrGet(10,EOT); QCOMPARE(iReturn,0); cout<<"\n//*** "<<__func__<<" func Done ***//\n"<<endl; } I am testing this function , Astm_obj is an class object ,ut_set_AstmIsrGet(100) is function created by me for seting a global variable void Astm::ut_set_AstmIsrGet(int m) { IsrStatus=m; } The Actual function I am testing is this int Astm::AstmIsrGet ( int a, UCHAR uc ) { SHORT sReport; sReport = 0; if (IsrStatus == ISR_IDLE) { if (uc == EOT || uc == ACK || uc == NAK || uc == ENQ) { IsrBufIn [0] = uc; IsrBufInPos = 1; sReport = 1; cout<<"uc=eot"; goto EXIT; } } EXIT: if (sReport) { IsrBufInData = IsrBufInPos; IsrStatus = ISR_WAIT; /* Warns the ASTM automaton of the end of the rx */ sem_post ( &AstmSemRxEnded ); } return( 0); } It should return 0 , But all I get is fatal error . This is the error I am getting **________________Case_1________________ === Received signal at function time: 1ms, total time: 24ms, dumping stack === GNU gdb (Ubuntu 12.0.90-0ubuntu1) 12.0.90 Copyright (C) 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <https://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word". Attaching to process 24482 (gdb) QFATAL : HostManagerTesting::TestAstmIsrGet() Received signal 11 Function time: 0ms Total time: 24ms FAIL! : HostManagerTesting::TestAstmIsrGet() Received a fatal error. Loc: [Unknown file(0)] Totals: 1 passed, 1 failed, 0 skipped, 0 blacklisted, 152ms ********* Finished testing of HostManagerTesting ********* === End of stack trace === 16:29:54: /home/chaithanya/Documents/QT/build-HostManagerTesting-Desktop-Debug/HostManagerTesting crashed.** I feel that the problem exists in passing the arguments, am I passed it correctly , is there any other way to pass arguments ?
Calls to LAPACK drivers from C++ crashes without error code
I'm having problems calling LAPACK drivers from C++. The following is a simple piece of code that calls dgesv, taken from: http://www.cs.rochester.edu/~bh/cs400/using_lapack.html with minor tweaks. The code compiles without any warnings/errors but crashes without reporting any errors when I run it. Of note, if I comment out the call to dgesv, the code runs to completion. I've tried a few pre-compiled LAPACK & BLAS libraries for Windows 64-bit and I'm getting the same behavior. I've also tried compiling the libraries from source and I got the same behavior. I'm compiling this using MinGW64's g++ in Eclipse on a Windows 10 64bit machine. Please help! #include <cstdio> typedef int custom_int; extern "C" void dgesv_(const custom_int *N, const custom_int *nrhs, double *A, const custom_int *lda, custom_int* ipiv, double *b, const custom_int *ldb, custom_int *info); int main () { // ********************************************************* // Testing basic linear algebra operations... // ********************************************************* /* 3x3 matrix A * 76 25 11 * 27 89 51 * 18 60 32 */ double A[9] = {76, 27, 18, 25, 89, 60, 11, 51, 32}; double b[3] = {10, 7, 43}; custom_int N = 3; custom_int num_rhs = 1; custom_int lda = 3; custom_int ipiv[3]; custom_int ldb = 3; custom_int info; // call lapack linear systems of equation solver... dgesv_(&N, &num_rhs, A, &lda, ipiv, b, &ldb, &info); //print results printf("\n"); if(info == 0) /* succeed */ printf("The solution is %lf %lf %lf\n", b[0], b[1], b[2]); else printf("dgesv fails %d\n", info); return 0; } Here's what i'm seeing from the debugger console: GNU gdb (GDB) 7.11.1 Copyright (C) 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-w64-mingw32". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word". No symbol table is loaded. Use the "file" command. No symbol table is loaded. Use the "file" command. [New Thread 8748.0x19cc] [New Thread 8748.0x12b4] [New Thread 8748.0x17a0] [New Thread 8748.0x1568] [Thread 8748.0x12b4 exited with code 3221225781] [Thread 8748.0x1568 exited with code 3221225781]
c++ recursion with object as function parameter
I'm trying to find all paths through a given network of activities and thought that I could do so using recursion. It is much like traversing through a network drive with different folders and sub-folders. I have defined an activity class (for storing each activity's properties) and a network class (for storing the network's activities). I'm passing the network object as a parameter to the recursive function call. The recursive function does not work as expected. It gives a segmentation fault and seems not to be able to access the network object properly. Can someone point me in the right direction on how to solve this (and how I could also store the found paths in a 2 dimensional array). Here is the code: #include <iostream> using namespace std; class Activity { public: int id; double duration; int successors[10]; }; class Network { public: Activity activities[]; }; int traverse(int, Network); int main() { // define the set of successors for each activity // a value of -1 indicates that no more successors are present const int successorset[][5] = { { 1,2,3,-1 }, { 5,-1 }, { 4,-1 }, { 4,-1 }, { 5,-1 }, { -1}, }; // two dimensional array where for each path the activity ids are stored int pathset [10][10]; // declare activities Activity Activity0, Activity1, Activity2, Activity3, Activity4, Activity5; // declare network Network NetworkMain; // define activity 0 Activity0.id = 0; Activity0.duration = 0; Activity0.successors[0] = successorset[0][0]; Activity0.successors[1] = successorset[0][1]; Activity0.successors[2] = successorset[0][2]; Activity0.successors[3] = successorset[0][3]; NetworkMain.activities[0] = Activity0; // define activity 1 Activity1.id = 1; Activity1.duration = 3; Activity1.successors[0] = successorset[1][0]; Activity1.successors[1] = successorset[1][1]; NetworkMain.activities[1] = Activity1; // define activity 2 Activity2.id = 2; Activity2.duration = 1; Activity2.successors[0] = successorset[2][0]; Activity2.successors[1] = successorset[2][1]; NetworkMain.activities[2] = Activity2; // define activity 3 Activity3.id = 3; Activity3.duration = 2; Activity3.successors[0] = successorset[3][0]; Activity3.successors[1] = successorset[3][1]; NetworkMain.activities[3] = Activity3; // define activity 4 Activity4.id = 4; Activity4.duration = 4; Activity4.successors[0] = successorset[4][0]; Activity4.successors[1] = successorset[4][1]; NetworkMain.activities[4] = Activity4; // define activity 5 Activity5.id = 5; Activity5.duration = 0; Activity5.successors[0] = successorset[5][0]; NetworkMain.activities[5] = Activity5; // print info on all activities to check whether they are defined correctly for( int a = 0; a < 6; a++ ) { cout << "id of activity = " << NetworkMain.activities[a].id << endl; cout << "duration of activity = " << NetworkMain.activities[a].duration << endl; int s = 0; while (NetworkMain.activities[a].successors[s]!=-1) { cout << "successor of activity " << a << " = " << NetworkMain.activities[a].successors[s] << endl; s++; } } // call recursive function to traverse through all paths of the network traverse(0, NetworkMain); return 0; } int traverse(int id, Network net) { if (net.activities[id].successors[0]==-1) // reached finish activity { cout << "reached finish " << endl; return 1; } else { cout << "id of activity under investigation " << net.activities[id].id << endl; int t = 0; while (net.activities[id].successors[t]!=-1) { cout << "going to investigate successor " << t << endl; traverse(net.activities[id].successors[t], net); t++; } } } Here is the output: id of activity = 0 duration of activity = 0 successor of activity 0 = 1 successor of activity 0 = 2 successor of activity 0 = 3 id of activity = 1 duration of activity = 3 successor of activity 1 = 5 id of activity = 2 duration of activity = 1 successor of activity 2 = 4 id of activity = 3 duration of activity = 2 successor of activity 3 = 4 id of activity = 4 duration of activity = 4 successor of activity 4 = 5 id of activity = 5 duration of activity = 0 id of activity under investigation -578861888 going to investigate successor 0 id of activity under investigation 0 going to investigate successor 0 id of activity under investigation -581127744 going to investigate successor 0 Segmentation fault (core dumped) Process returned 139 (0x8B) execution time : 0.087 s Press ENTER to continue. Edit: should have added the newbie alert, below is the debugger output. Active debugger config: GDB/CDB debugger:Default Building to ensure sources are up-to-date Selecting target: Debug Adding source dir: /home/home/Desktop/recursion/ Adding source dir: /home/home/Desktop/recursion/ Adding file: /home/home/Desktop/recursion/bin/Debug/recursion Changing directory to: /home/home/Desktop/recursion/. Set variable: LD_LIBRARY_PATH=.: [debug]Command-line: /usr/bin/gdb -nx -fullname -quiet -args /home/home/Desktop/recursion/bin/Debug/recursion [debug]Working dir : /home/home/Desktop/recursion Starting debugger: /usr/bin/gdb -nx -fullname -quiet -args /home/home/Desktop/recursion/bin/Debug/recursion done [debug]Reading symbols from /home/home/Desktop/recursion/bin/Debug/recursion...done. [debug](gdb) [debug]> set prompt >>>>>>cb_gdb: Registered new type: wxString Registered new type: STL String Registered new type: STL Vector Setting breakpoints [debug]>>>>>>cb_gdb: [debug]> show version [debug]GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1 [debug]Copyright (C) 2016 Free Software Foundation, Inc. [debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> [debug]This is free software: you are free to change and redistribute it. [debug]There is NO WARRANTY, to the extent permitted by law. Type "show copying" [debug]and "show warranty" for details. [debug]This GDB was configured as "x86_64-linux-gnu". [debug]Type "show configuration" for configuration details. [debug]For bug reporting instructions, please see: [debug]<http://www.gnu.org/software/gdb/bugs/>. [debug]Find the GDB manual and other documentation resources online at: [debug]<http://www.gnu.org/software/gdb/documentation/>. [debug]For help, type "help". [debug]Type "apropos word" to search for commands related to "word". [debug]>>>>>>cb_gdb: [debug]> set confirm off Debugger name and version: GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1 [debug]>>>>>>cb_gdb: [debug]> set width 0 [debug]>>>>>>cb_gdb: [debug]> set height 0 [debug]>>>>>>cb_gdb: [debug]> set breakpoint pending on [debug]>>>>>>cb_gdb: [debug]> set print asm-demangle on [debug]>>>>>>cb_gdb: [debug]> set unwindonsignal on [debug]>>>>>>cb_gdb: [debug]> set print elements 0 [debug]>>>>>>cb_gdb: [debug]> set disassembly-flavor intel [debug]>>>>>>cb_gdb: [debug]> catch throw [debug]Catchpoint 1 (throw) [debug]>>>>>>cb_gdb: [debug]> source /usr/share/codeblocks/scripts/stl-views-1.0.3.gdb [debug]>>>>>>cb_gdb: [debug]> directory /home/home/Desktop/recursion/ [debug]Source directories searched: /home/home/Desktop/recursion:$cdir:$cwd [debug]>>>>>>cb_gdb: [debug]Using terminal's PID as console PID 13148, TTY /dev/pts/1 [debug]> tty /dev/pts/1 [debug]Queued:[tty /dev/pts/1] [debug]>>>>>>cb_gdb: [debug]> run [debug]Starting program: /home/home/Desktop/recursion/bin/Debug/recursion [debug]Program received signal SIGSEGV, Segmentation fault. [debug]0x0000000000400ee9 in traverse (id=-140179936, net=...) at /home/home/Desktop/recursion/main.cpp:103 [debug]/home/home/Desktop/recursion/main.cpp:103:2808:beg:0x400ee9 [debug]>>>>>>cb_gdb: Program received signal SIGSEGV, Segmentation fault. At /home/home/Desktop/recursion/main.cpp:103 [debug]> bt 30 [debug]#0 0x0000000000400ee9 in traverse (id=-140179936, net=...) at /home/home/Desktop/recursion/main.cpp:103 [debug]#1 0x0000000000400ff1 in traverse (id=0, net=...) at /home/home/Desktop/recursion/main.cpp:114 [debug]#2 0x0000000000400ff1 in traverse (id=6, net=...) at /home/home/Desktop/recursion/main.cpp:114 [debug]#3 0x0000000000400ff1 in traverse (id=0, net=...) at /home/home/Desktop/recursion/main.cpp:114 [debug]#4 0x0000000000400e91 in main () at /home/home/Desktop/recursion/main.cpp:96 [debug]>>>>>>cb_gdb:
Seemingly a newbie mistake, I had to declare the size of the activities array to make room for it in the computer's memory. Incorrect: class Network { public: Activity activities[]; }; Correct: class Network { public: Activity activities[6]; // given 6 activities }; Thanks all for your help.
cygwin exception when assigning value to vector of strings
I am having following exception during the course of the run of program: 0 [main] myFunction 5560 cygwin_exception::open_stackdumpfile: Dumping stack trace to myFunction.exe.stackdump The contents of stackdump file are as follows: Stack trace: Frame Function Args 00000223800 0018006FB93 (0060007AE38, 00600083EC8, 00600083EF8, 00600083F28) 00000000006 0018007105A (0060007BB78, 00600000000, 0000000014C, 00000000000) 000002239E0 0018011C6A7 (00600083048, 00600083078, 006000830A8, 006000830D8) 00000000041 001801198DE (0060007DCB8, 0060007DCE8, 00000000000, 0060007DD48) 0060008F2B0 00180119DAB (0060007E1F8, 0060007E228, 0060007E258, 00000000006) 0060008F2B0 00180119F7C (0060007CB38, 0060007CB68, 0060007CB98, 0060007CBC8) 0060008F2B0 0018011A23F (00180115A0B, 0060007CCE8, 006000885B0, 00000000000) 0060008F2B0 00180148A65 (003FC4AA93D, 00600083900, 00100439102, 0060007B080) 0060008F2B0 001800C1DB3 (00000000000, 00000223EE0, 0010042A2BC, 00000223E90) 0060008F2B0 00180115A0B (00000223EE0, 0010042A2BC, 00000223E90, 00000000017) 0060008F2B0 00600000001 (00000223EE0, 0010042A2BC, 00000223E90, 00000000017) End of stack trace Let me describe in detail the peculiar problem which happens at runtime. I am not able to describe the problem with just words, so I am listing scenario when the program works and when it fails. I have created a vector of string in my header file and initialised them in the constructor as follows : std::vector <std::string> symbolMap,localSymbolMap; for(int i=0;i<100;i++){ symbolMap.push_back(" "); localSymbolMap.push_back(" "); } I have defined a function to assign appropriate value to these variables later in the program as follows : void TestClient::setTickerMap(int j, std::string symbol, std::string localSymbol){ symbolMap[j] = symbol; localSymbolMap[j]=localSymbol; } Now, in the main program, I call this function as follows: TestClient client; for(int j=0;j<27;j++){ std::cout<<j<<" "<<realTimeSymbols[j]<<" "<<getLocalSymbol(realTimeSymbols[j],date)<<std::endl; client.setTickerMap(j,realTimeSymbols[j],getLocalSymbol(realTimeSymbols[j],date)); } // Here, I have checked for each j, that values of realTimeSymbols and getLocalSymbol are proper. When I run the program, I get the error described above. The program always crashed when j is equal to 24. Now the following workaround is working as of now: void TestClient ::setTickerMap(int j, std::string symbol, std::string localSymbol){ if(j==24){ // symbolMap[j]="SYNDIBANK"; // localSymbolMap[j]="SYNDIBANK15MARFUT"; } else{ symbolMap[j] = symbol; localSymbolMap[j]=localSymbol; } if(j==1){ symbolMap[24]="SYNDIBANK"; localSymbolMap[24]="SYNDIBANK15MARFUT"; } } Following 3 variations of the code are above workaround are not working and they result in the original error: Variation 1: void TestClient ::setTickerMap(int j, std::string symbol, std::string localSymbol){ if(j==24){ // symbolMap[j]="SYNDIBANK"; // localSymbolMap[j]="SYNDIBANK15MARFUT"; } else{ symbolMap[j] = symbol; localSymbolMap[j]=localSymbol; } if(j==25){ symbolMap[24]="SYNDIBANK"; localSymbolMap[24]="SYNDIBANK15MARFUT"; } } Variation 2: void TestClient ::setTickerMap(int j, std::string symbol, std::string localSymbol){ if(j==24){ symbolMap[j]="SYNDIBANK"; localSymbolMap[j]="SYNDIBANK15MARFUT"; } else{ symbolMap[j] = symbol; localSymbolMap[j]=localSymbol; } } Variation 3: void TestClient ::setTickerMap(int j, std::string symbol, std::string localSymbol){ if(j==24){ symbolMap[j]="AB"; localSymbolMap[j]="SYNDIBANK15MARFUT"; } else{ symbolMap[j] = symbol; localSymbolMap[j]=localSymbol; } } Now, if I assign a single character to symbolMap in variation 3 as follows : symbolMap[j]="A"; then the code is able to run(although is the result is not correct). I am not able to figure what exactly is causing this runtime error. I have checked the related question (Cygwin Exception : open stack dump file) and I do not have a separate session of cygwin running. I have restarted my PC just be extra sure. Still the problem persists. Any suggestions as to why this behaviour is seen on my PC. UPDATE: To be sure that the error is not related to out-of-index, the following call from main program works fine: TestClient client; for(int j=25;j<27;j++){ std::cout<<j<<" "<<realTimeSymbols[j]<<" "<<getLocalSymbol(realTimeSymbols[j],date)<<std::endl; client.setTickerMap(j,realTimeSymbols[j],getLocalSymbol(realTimeSymbols[j],date)); } The program also works fine when j is iterated from 24 to 27. But fails when the loop is iterated from any number before 24 to 27. GDB OUTPUT I do not have much experience with gdb but following is the output of the gdb if it helps: GNU gdb (GDB) 7.8 Copyright (C) 2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-pc-cygwin". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from order_trading2632_limit.exe...done. (gdb) run Starting program: /cygdrive/e/eclipse_workspace/testClient/Debug/testClient.exe [New Thread 4832.0x11e4] [New Thread 4832.0x1798] Attempt 1 of 10000 [New Thread 4832.0x1020] Connection successful Program received signal SIGABRT, Aborted. 0x00000003fc4ab0e3 in cygstdc++-6!_ZNSs6assignERKSs () from /usr/bin/cygstdc++-6.dll (gdb) bt #0 0x00000003fc4ab0e3 in cygstdc++-6!_ZNSs6assignERKSs () from /usr/bin/cygstdc++-6.dll #1 0x0000000000000000 in ?? () Backtrace stopped: previous frame inner to this frame (corrupt stack?) (gdb) set $pc=*(void **)$rsp (gdb) set $rsp=$rsp+8 (gdb) bt #0 0x000007fefd3110ac in WaitForSingleObjectEx () from /cygdrive/c/Windows/system32/KERNELBASE.dll #1 0x000000018011c639 in sig_send(_pinfo*, siginfo_t&, _cygtls*) () from /usr/bin/cygwin1.dll #2 0x00000001801198de in _pinfo::kill(siginfo_t&) () from /usr/bin/cygwin1.dll #3 0x0000000180119dab in kill0(int, siginfo_t&) () from /usr/bin/cygwin1.dll #4 0x0000000180119f7c in raise () from /usr/bin/cygwin1.dll #5 0x000000018011a23f in abort () from /usr/bin/cygwin1.dll #6 0x0000000180148a65 in dlfree () from /usr/bin/cygwin1.dll #7 0x00000001800c1db3 in free () from /usr/bin/cygwin1.dll #8 0x0000000180115a0b in _sigfe () from /usr/bin/cygwin1.dll #9 0x0000000000000000 in ?? () Backtrace stopped: previous frame inner to this frame (corrupt stack?) Note that stack trace is corrupted and I have used trick from following question to print the stacktrace (GDB corrupted stack frame - How to debug?). Please help me in debugging the program further. UPDATE It is not the case that the error happens only when index is 24. Before calling the said loop, I initialize various arrays of int, double and string. Changing the number of initialization affects the index when this error happens. Today, I initialised vectors of length 24 before running this loop, this time the error happened at index 3. This is really frustrating to implement the workaround. I do not that if there are some other memory issues I am overlooking because of this. Please offer suggestions. CODE int main(int argc, char** argv) { unsigned int port = 7900; const char* host = ""; int clientId = 6; int attempt = 0; int MAX_ATTEMPTS=10000; int NUMREALTIMESYMBOLS=37; std::string realTimeSymbolsArr[]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","aa","bb","cc","dd","ee","ff","gg","hh","ii","jj","kk"}; std::vector <std::string> realTimeSymbols(realTimeSymbolsArr,realTimeSymbolsArr+NUMREALTIMESYMBOLS); int isTradeable[]={1,0,0,0,1,0,1,1,1,1,1,0,0,1,0,1,1,0,0,0,0,1,0,0,0,0,0,1,1,1,0,1,0,1,1,0,1}; int numSubscriptions[]={2,2,1,4,1,1,2,6,3,1,1,1,2,1,3,1,1,2,1,3,1,1,1,10,4,1,6,1,1,9,4,2,1,3,1,1,2}; int subscriptionList[NUMREALTIMESYMBOLS][100]; int subscriptionIndex[NUMREALTIMESYMBOLS][100]; subscriptionList[0][0]=0;subscriptionIndex[0][0]=0; subscriptionList[0][1]=2;subscriptionIndex[0][1]=2; subscriptionList[1][0]=2;subscriptionIndex[1][0]=1; subscriptionList[1][1]=0;subscriptionIndex[1][1]=3; subscriptionList[2][0]=2;subscriptionIndex[2][0]=0; subscriptionList[3][0]=4;subscriptionIndex[3][0]=2; subscriptionList[3][1]=31;subscriptionIndex[3][1]=2; subscriptionList[3][2]=13;subscriptionIndex[3][2]=3; subscriptionList[3][3]=34;subscriptionIndex[3][3]=3; subscriptionList[4][0]=4;subscriptionIndex[4][0]=0; subscriptionList[5][0]=9;subscriptionIndex[5][0]=2; subscriptionList[6][0]=6;subscriptionIndex[6][0]=0; subscriptionList[6][1]=8;subscriptionIndex[6][1]=2; subscriptionList[7][0]=7;subscriptionIndex[7][0]=0; subscriptionList[7][1]=8;subscriptionIndex[7][1]=1; subscriptionList[7][2]=31;subscriptionIndex[7][2]=1; subscriptionList[7][3]=36;subscriptionIndex[7][3]=1; subscriptionList[7][4]=13;subscriptionIndex[7][4]=2; subscriptionList[7][5]=34;subscriptionIndex[7][5]=2; subscriptionList[8][0]=8;subscriptionIndex[8][0]=0; subscriptionList[8][1]=7;subscriptionIndex[8][1]=1; subscriptionList[8][2]=21;subscriptionIndex[8][2]=3; subscriptionList[9][0]=9;subscriptionIndex[9][0]=0; subscriptionList[10][0]=10;subscriptionIndex[10][0]=0; subscriptionList[11][0]=11;subscriptionIndex[11][0]=0; subscriptionList[12][0]=28;subscriptionIndex[12][0]=3; subscriptionList[12][1]=33;subscriptionIndex[12][1]=3; subscriptionList[13][0]=13;subscriptionIndex[13][0]=0; subscriptionList[14][0]=33;subscriptionIndex[14][0]=1; subscriptionList[14][1]=28;subscriptionIndex[14][1]=2; subscriptionList[14][2]=15;subscriptionIndex[14][2]=3; subscriptionList[15][0]=15;subscriptionIndex[15][0]=0; subscriptionList[16][0]=16;subscriptionIndex[16][0]=0; subscriptionList[17][0]=0;subscriptionIndex[17][0]=1; subscriptionList[17][1]=11;subscriptionIndex[17][1]=2; subscriptionList[18][0]=7;subscriptionIndex[18][0]=2; subscriptionList[19][0]=6;subscriptionIndex[19][0]=3; subscriptionList[19][1]=8;subscriptionIndex[19][1]=3; subscriptionList[19][2]=16;subscriptionIndex[19][2]=3; subscriptionList[20][0]=9;subscriptionIndex[20][0]=1; subscriptionList[21][0]=21;subscriptionIndex[21][0]=0; subscriptionList[22][0]=9;subscriptionIndex[22][0]=3; subscriptionList[23][0]=6;subscriptionIndex[23][0]=1; subscriptionList[23][1]=10;subscriptionIndex[23][1]=1; subscriptionList[23][2]=27;subscriptionIndex[23][2]=1; subscriptionList[23][3]=29;subscriptionIndex[23][3]=1; subscriptionList[23][4]=16;subscriptionIndex[23][4]=2; subscriptionList[23][5]=21;subscriptionIndex[23][5]=2; subscriptionList[23][6]=2;subscriptionIndex[23][6]=3; subscriptionList[23][7]=4;subscriptionIndex[23][7]=3; subscriptionList[23][8]=7;subscriptionIndex[23][8]=3; subscriptionList[23][9]=36;subscriptionIndex[23][9]=3; subscriptionList[24][0]=24;subscriptionIndex[24][0]=0; subscriptionList[24][1]=24;subscriptionIndex[24][1]=1; subscriptionList[24][2]=24;subscriptionIndex[24][2]=2; subscriptionList[24][3]=24;subscriptionIndex[24][3]=3; subscriptionList[25][0]=29;subscriptionIndex[25][0]=3; subscriptionList[26][0]=21;subscriptionIndex[26][0]=1; subscriptionList[26][1]=0;subscriptionIndex[26][1]=2; subscriptionList[26][2]=10;subscriptionIndex[26][2]=2; subscriptionList[26][3]=15;subscriptionIndex[26][3]=2; subscriptionList[26][4]=27;subscriptionIndex[26][4]=2; subscriptionList[26][5]=33;subscriptionIndex[26][5]=2; subscriptionList[27][0]=27;subscriptionIndex[27][0]=0; subscriptionList[28][0]=28;subscriptionIndex[28][0]=0; subscriptionList[29][0]=29;subscriptionIndex[29][0]=0; subscriptionList[29][1]=4;subscriptionIndex[29][1]=1; subscriptionList[29][2]=13;subscriptionIndex[29][2]=1; subscriptionList[29][3]=16;subscriptionIndex[29][3]=1; subscriptionList[29][4]=34;subscriptionIndex[29][4]=1; subscriptionList[29][5]=6;subscriptionIndex[29][5]=2; subscriptionList[29][6]=36;subscriptionIndex[29][6]=2; subscriptionList[29][7]=27;subscriptionIndex[29][7]=3; subscriptionList[29][8]=31;subscriptionIndex[29][8]=3; subscriptionList[30][0]=30;subscriptionIndex[30][0]=0; subscriptionList[30][1]=30;subscriptionIndex[30][1]=1; subscriptionList[30][2]=30;subscriptionIndex[30][2]=2; subscriptionList[30][3]=30;subscriptionIndex[30][3]=3; subscriptionList[31][0]=31;subscriptionIndex[31][0]=0; subscriptionList[31][1]=29;subscriptionIndex[31][1]=2; subscriptionList[32][0]=11;subscriptionIndex[32][0]=3; subscriptionList[33][0]=33;subscriptionIndex[33][0]=0; subscriptionList[33][1]=15;subscriptionIndex[33][1]=1; subscriptionList[33][2]=28;subscriptionIndex[33][2]=1; subscriptionList[34][0]=34;subscriptionIndex[34][0]=0; subscriptionList[35][0]=11;subscriptionIndex[35][0]=1; subscriptionList[36][0]=36;subscriptionIndex[36][0]=0; subscriptionList[36][1]=10;subscriptionIndex[36][1]=3; double a1[]={720,0.0,750,0.0,900,0.0,760,360,120,390,600,360,0.0,760,0.0,140,660,0.0,0.0,0.0,0.0,720,0.0,0.0,100,0.0,0.0,120,320,40,100,500,0.0,630,570,0.0,100}; double a2[]={0.5,0.0,1.3,0.0,0.6,0.0,0.45,0.15,0.45,0.4,0.25,1.4,0.0,0.55,0.0,0.2,0.8,0.0,0.0,0.0,0.0,0.6,0.0,0.0,0.4,0.0,0.0,0.25,0.4,0.25,0.4,0.35,0.0,0.4,0.5,0.0,0.4}; double a3[]={1350,0.0,1250,0.0,300,0.0,1150,1400,900,1200,850,900,0.0,600,0.0,1450,1450,0.0,0.0,0.0,0.0,1000,0.0,0.0,1200,0.0,0.0,1150,350,1400,1200,1350,0.0,1500,300,0.0,1200}; double a4[]={0.6,0.0,0.7,0.0,0.2,0.0,0.3,0.55,0.4,0.8,0.25,0.7,0.0,0.25,0.0,0.55,0.5,0.0,0.0,0.0,0.0,0.4,0.0,0.0,0.7,0.0,0.0,0.65,0.55,0.45,0.7,0.6,0.0,0.4,0.4,0.0,0.7}; double a5[]={300,0.0,1300,0.0,1350,0.0,200,1100,1200,650,1500,1350,0.0,1050,0.0,1300,550,0.0,0.0,0.0,0.0,250,0.0,0.0,150,0.0,0.0,1250,700,1150,150,1250,0.0,1500,1500,0.0,150}; double a6[]={0.3,0.0,0.8,0.0,0.6,0.0,0.5,0.6,0.6,0.3,0.35,0.7,0.0,0.55,0.0,0.45,0.35,0.0,0.0,0.0,0.0,0.3,0.0,0.0,0.5,0.0,0.0,0.55,0.3,0.35,0.5,0.75,0.0,0.2,0.5,0.0,0.5}; double a7[]={1500,0.0,1500,0.0,1050,0.0,750,1100,1350,1350,100,1350,0.0,550,0.0,1400,1000,0.0,0.0,0.0,0.0,1000,0.0,0.0,1350,0.0,0.0,350,550,350,1350,500,0.0,1350,1250,0.0,1350}; double a8[]={0.9,0.0,0.9,0.0,0.8,0.0,0.6,0.35,0.7,0.2,0.15,0.7,0.0,0.3,0.0,0.55,0.5,0.0,0.0,0.0,0.0,0,0.0,0.0,0.3,0.0,0.0,0.4,0.3,0.5,0.3,0.35,0.0,0.5,0.5,0.0,0.3}; double a9[]={0.008,0.0,0.009,0.0,0.01,0.0,0.01,0.009,0.009,0.007,0.009,0.01,0.0,0.009,0.0,0.01,0.008,0.0,0.0,0.0,0.0,0.01,0.0,0.0,0.006,0.0,0.0,0.008,0.009,0.01,0.006,0.009,0.0,0.008,0.009,0.0,0.006}; double a10[]={0.008,0.0,0.009,0.0,0.008,0.0,0.008,0.008,0.009,0.008,0.008,0.006,0.0,0.009,0.0,0.01,0.008,0.0,0.0,0.0,0.0,0.005,0.0,0.0,0.009,0.0,0.0,0.01,0.008,0.009,0.009,0.009,0.0,0.008,0.01,0.0,0.009}; double a11[]={0.4,0.0,0.2,0.0,0.1,0.0,0.3,0.4,0.2,0.1,0.7,0.2,0.0,0,0.0,0.1,0,0.0,0.0,0.0,0.0,0.1,0.0,0.0,0.2,0.0,0.0,0.3,0,0.2,0.2,0,0.0,0.7,0.1,0.0,0.2}; int a12[]={500,1000,8000,2000,4000,1000,1250,1000,1000,500,1000,125,2000,4000,1000,250,2000,250,1000,1250,500,2000,1000,500,0,250,500,4000,4000,1250,0,2000,500,500,4000,125,1000}; double a13[]={0.0013406,0.0020022,0.0018709,0.0018948,0.0017975,0.0014687,0.0011068,0.001355,0.0010891,0.00088151,0.0014294,0.0012989,0.0014205,0.0019711,0.0015365,0.0020505,0.0018961,0.00078672,0.0023114,0.0012203,0.0012849,0.0015674,0.0012844,0.0014197,0.0,0.00074657,0.00096164,0.0017109,0.0015385,0.00068178,0.0,0.0021815,0.00087359,0.00074349,0.0021645,0.001595,0.0014573}; int a14[]={14850,0,16500,0,13740,0,13740,24750,13740,14100,13740,30750,0,14400,0,13740,13740,0,0,0,0,14100,0,0,13500,0,0,13740,13740,25200,13500,13740,0,13740,13740,0,13740}; int a15[]={30750,0,35900,0,34950,0,35900,35900,35900,35900,30000,34950,0,26250,0,34000,35900,0,0,0,0,34500,0,0,13500,0,0,35900,34650,35900,13500,32700,0,35900,35900,0,33300}; Client client; for (int i = 0; i < MAX_ATTEMPTS; i++) { client.connect(host, port, clientId); ++attempt; std::cout << "Attempt " << attempt << " of " << MAX_ATTEMPTS<< std::endl; for (int j=0;j<NUMREALTIMESYMBOLS;j++){ if(j==24 || j==30) continue; std::cout<<j<<" "<<realTimeSymbols[j]<<" "<<getLocalSymbol(realTimeSymbols[j],date)<<std::endl; client.setTickerMap(j,realTimeSymbols[j],getLocalSymbol(realTimeSymbols[j],date)); } } } Constructor of Client: Client::Client(){ for(int i=0;i<50;i++){ symbolMap.push_back(" "); localSymbolMap.push_back(" "); } } The above code fails at 24 and 30. Hence, the loop to continue when j is 24 or 30 as workaround.
std::string realTimeSymbolsArr[]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","aa","bb","cc","dd","ee","ff","gg","hh","ii","jj","kk"}; subscriptionList[24][1]=24;subscriptionIndex[24][1]=1; subscriptionList[24][2]=24;subscriptionIndex[24][2]=2; subscriptionList[24][3]=24;subscriptionIndex[24][3]=3; subscriptionList[30][1]=30;subscriptionIndex[30][1]=1; subscriptionList[30][2]=30;subscriptionIndex[30][2]=2; subscriptionList[30][3]=30;subscriptionIndex[30][3]=3; You have not posted the source for getLocalSymbol, but I must assume that it also uses the same data and has a flow of the following form: getLocalSymbol(a, b) { int i, j, old_i, old_j; std::string value; // Derive i and j from the parameters // ... // And build the String do { old_i = i; old_j = j; i = subscriptionList[old_i][old_j]; j = subscriptionIndex[old_i][old_j]; value += realTimeSymbolsArr[i]; } while(j > 0); return value; } Got it right? That control flow, or something equivalent, appears to be part of it, either way. This goes well for almost all values of i and j - except for the aforementioned values of 24 and 30 for i, and 1 to 3 for j. With these values, i and j remain the same in every iteration and value becomes longer and longer, until eventually something breaks on the stack which overwrites both j (and thereby causes the loop to terminate) and corrupts value. Either way, the std::string you returned is now corrupted as you exceeded some limit during that endless loop. As for how to solve it, fix that infinite loop and fix your data. For fixing the loop, limit the iteration count. For fixing your data, well, now that you know why the data is causing the bug, you should be able to figure yourself how to fix it. Remember, you have to fix BOTH. If you don't fix the data, you will get an unreasonable long return value. And if you don't fix the iteration limit, it will crash again as soon as someone repeats a similar mistake when updating the data.
boost::program_options hangs on the arm "sometimes"
Currently I am using boost::program_options to parse a configuration file on the BeagleBoard (ARM-based processor). My program is multi-threaded and linked against the boost 1.45 multithreaded libraries. My program just seems to hang when parsing the configuration file though namespace po = boost::program_options; po::options_description desc("Options"); uint32_t option1=0; std::vector<std::string> optionsString; std::cout<<"Before adding options"<<std::endl; desc.add_options() ("option1", po::value<uint32_t>(&option1), "...") ("finaloption", po::value<std::vector<std::string> >(&optionsString)->multitoken(), "string of options"); //Never gets here std::cout<<"After adding options"<<std::endl; po::variables_map vm; std::cout<<"Starting program"<<std::endl; The program hangs before printing out "After adding options". If I run the program through gdb stop it and do a back trace it just shows that it was on the line before the "Never gets here" comment. The top of the backtrace just has it at #0 ?? #1 __lll_lock_wait lowlevellock.c:47 #2 __pthread_mutex_lock pthread_mutex_lock.c:61 #3 in boost::shared_ptr<boost::program_options::option_description>* std::__uninitialized_move_a<boost::shared_ptr<boost::program_options::option_description>*, boost::shared_ptr<boost::program_options::option_description>*, std::allocator<boost::shared_ptr<boost::program_option::option_description> > >(boost::shared_ptr<boost::program_optionns::option_description>*, boost::shared_ptr<boost::program_options::option_description>*, std::allocator<boost::shared_ptr<boost::program_options::option_description> >&) () from /usr/local/lib/libboost_program_options-mt.so.1.45.0 #4 in std::vector<boost::shared_ptr<boost::program_options::option_description>, std::allocator<boost::shared_ptr<boost::program_options::option_description> > >::_M_insert_aux(__gnu_cxx::__normal_iterator<boost::shared_ptr<boost::program_options::option_description>, std::vector<boost::shared_ptr<boost::program_options::option_description>, std::allocator<boost::shared_ptr<boost::program_options::option_description> const&)() from /usr/local/lib/libboost_program_options-mt.so.1.45.0 #5 in boost::program_options::options_description::add(boost::shared_ptr<boost::program_options::option_description>) () from /usr/local/lib/libboost_program_options-mt.so.1.45.0 ...(let me know if you want more) Any thoughts? This program works fine on an x86 machine Edit: Further information, this does not seem to happen with optimizations off (compiled with -O2 this will fairly consistently occur). Edit2: Further analysis reveals that this still happens with optimizations off, -O0.
This could be a problem related to how you build boost and your application. The mutex lock implementations are different if you compile for thumb and without thumb. Make sure you compile both the application and the boost library with the same thumb settings. Here's an example user-config.jam I use to compile boost: if [ os.name ] = CYGWIN || [ os.name ] = NT { HOST_TAG = windows ; } else if [ os.name ] = LINUX { HOST_TAG = linux-x86 ; } else if [ os.name ] = MACOSX { HOST_TAG = darwin-x86 ; } modules.poke : NO_BZIP2 : 1 ; modules.poke : NO_GZIP : 1 ; LIB_ROOT = /home/user/lib ; NDK_ROOT = $(LIB_ROOT)/android-ndk-r8c ; LLVM_VERSION = 3.1 ; LLVM_NAME = llvm-$(LLVM_VERSION) ; LLVM_TOOLCHAIN_ROOT = $(NDK_ROOT)/toolchains/$(LLVM_NAME) ; LLVM_TOOLCHAIN_PREBUILT_ROOT = $(LLVM_TOOLCHAIN_ROOT)/prebuilt/$(HOST_TAG) ; LLVM_TOOLCHAIN_PREFIX = $(LLVM_TOOLCHAIN_PREBUILT_ROOT)/bin/ ; TOOLCHAIN_VERSION = 4.6 ; TOOLCHAIN_NAME = arm-linux-androideabi-$(TOOLCHAIN_VERSION) ; TOOLCHAIN_ROOT = $(NDK_ROOT)/toolchains/$(TOOLCHAIN_NAME) ; TOOLCHAIN_PREBUILT_ROOT = $(TOOLCHAIN_ROOT)/prebuilt/$(HOST_TAG) ; TOOLCHAIN_PREFIX = $(TOOLCHAIN_PREBUILT_ROOT)/bin/arm-linux-androideabi- ; using clang : $(TOOLCHAIN_VERSION) : $(LLVM_TOOLCHAIN_PREFIX)clang : <compileflags>"-gcc-toolchain $(TOOLCHAIN_PREBUILT_ROOT)" <compileflags>"-isystem $(LLVM_TOOLCHAIN_PREBUILT_ROOT)/lib/clang/$(LLVM_VERSION)/include" <compileflags>"-isysroot $(NDK_ROOT)/platforms/android-9/arch-arm/usr/include" <compileflags>-std=gnu++11 <compileflags>-stdlib=libc++ <compileflags>-fomit-frame-pointer <compileflags>-ffast-math <compileflags>"-target armv7-none-linux-androideabi" <compileflags>-march=armv7-a <compileflags>-mfloat-abi=softfp <compileflags>-mfpu=neon <compileflags>-DPAGE_SIZE=sysconf\\(_SC_PAGESIZE\\) <compileflags>-I$(NDK_ROOT)/boost/include <compileflags>-I$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/include <compileflags>-I$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/libs//armeabi-v7a/include <compileflags>-I$(NDK_ROOT)/platforms/android-9/arch-arm/usr/include <linkflags>-s <archiver>$(TOOLCHAIN_PREFIX)ar <ranlib>$(TOOLCHAIN_PREFIX)ranlib ; Note, that in this example, I did not compile with thumb enabled.