<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[*** glibc detected *** .&#x2F;NIS: double free or corruption]]></title><description><![CDATA[<p>Werft doch mal bitte einen Blick auf diesen kurzen Code:</p>
<p>NIS.cpp</p>
<pre><code class="language-cpp">#include &quot;NIS_1D.h&quot;
#include &lt;iostream&gt;
#include &lt;string.h&gt;

using namespace std;

int main(int argc, char** argv)
{
	const int N = 3;
	double* Xtrain = new double[N];
	Xtrain[0] = 1.0;
	Xtrain[1] = 2.0;
	Xtrain[2] = 3.0;

	const int M = 3;
	double* Xtest = new double[M];
	Xtest[0] = 5.5;
	Xtest[1] = 6.5;
	Xtest[2] = 7.5;

	int K = 10;
	double T = 2.1;
	double mu1 = 2.9;
	double mu2 = 2.1;
	double sigma1 = 7.4;
	double sigma2 = 8.3;

	double* XTrainCpy = new double[N];
	double* XTestCpy = new double[M];
	memcpy( XTrainCpy, Xtrain, sizeof(double)*N );
	memcpy( XTestCpy, Xtest, sizeof(double)*M );

	NIS_1D nis( XTrainCpy, N, XTestCpy, M, K, T, mu1, mu2, sigma1, sigma2 );

}
</code></pre>
<p>NIS_1D.h</p>
<pre><code class="language-cpp">#ifndef NIS_1D_H_
#define NIS_1D_H_

#include &lt;iostream&gt;
#include &lt;complex&gt;
#include &lt;cmath&gt;

using namespace std;

class NIS_1D {
public:

	double* Xtrain;
	int N; 
	double* Xtest;
	int M; 
	int K; 
	double T; 
	double mu1,mu2,sigma1,sigma2;
	complex&lt;double&gt;* pExpTR;
	complex&lt;double&gt;* nExpTR;
	complex&lt;double&gt;* nExpTE;

	NIS_1D( double* Xtrain, int N, double* Xtest, int M, int K, double T, double mu1, double mu2, double sigma1, double sigma2 );
	virtual ~NIS_1D();

	void preCalculateStuff();

	//Hilfsfunktionen
	complex&lt;double&gt; complexEuler( double r, double phi );
};

#endif /* NIS_1D_H_ */
</code></pre>
<p>NIS_1D.cpp</p>
<pre><code class="language-cpp">#include &quot;NIS_1D.h&quot;

NIS_1D::NIS_1D( double* Xtrain_, int N_, double* Xtest_, int M_, int K_, double T_, double mu1_, double mu2_, double sigma1_, double sigma2_ ) {
	cout &lt;&lt; &quot;Konstruktor 1&quot; &lt;&lt; endl;
	Xtrain = Xtrain_;
	N = N_;
	Xtest = Xtest_;
	M = M_;
	K = K_;
	T = T_;
	mu1 = mu1_;
	mu2 = mu2_;
	sigma1 = sigma1_;
	sigma2 = sigma2_;

	preCalculateStuff();
	cout &lt;&lt; &quot;Konstruktor 2&quot; &lt;&lt; endl;
}

NIS_1D::~NIS_1D() {
	cout &lt;&lt; &quot;Destruktor 1&quot; &lt;&lt; endl;
	delete[] Xtrain;
	cout &lt;&lt; &quot;Destruktor 2&quot; &lt;&lt; endl;
	delete[] Xtest;
	cout &lt;&lt; &quot;Destruktor 3&quot; &lt;&lt; endl;
	delete[] pExpTR;
	cout &lt;&lt; &quot;Destruktor 4&quot; &lt;&lt; endl;
	delete[] nExpTR;
	cout &lt;&lt; &quot;Destruktor 5&quot; &lt;&lt; endl;
	delete[] nExpTE;
	cout &lt;&lt; &quot;Destruktor 6&quot; &lt;&lt; endl;
}

void NIS_1D::preCalculateStuff() {

	int KLength = 2*K+1;

	pExpTR = new complex&lt;double&gt;[KLength*N];
	nExpTR = new complex&lt;double&gt;[KLength*N];
	nExpTE = new complex&lt;double&gt;[KLength*M];
	for( int k = -K; k &lt;= K; ++k ) {
		for( int i = 0; i &lt; N; ++i ) {
			int index = k+i*KLength;
			pExpTR[index] = complexEuler( 1,  2*M_PI*k/T*Xtrain[i] );
			nExpTR[index] = complexEuler( 1, -2*M_PI*k/T*Xtrain[i] );
		}

		for( int i = 0; i &lt; M; ++i ) {
			int index = k+i*KLength;
			nExpTE[index] = complexEuler( 1, -2*M_PI*k/T*Xtest[i] );
		}
	}

}

//Hilfsfuntkionen
complex&lt;double&gt; NIS_1D::complexEuler( double r, double phi ) {
	return complex&lt;double&gt;( r*cos( phi ),r*sin( phi ) );
}
</code></pre>
<p>Wenn ich das ausführe erhalte ich folgenden Fehler:</p>
<blockquote>
<p>NIS_Fkt&gt; ./NIS<br />
Konstruktor 1<br />
Konstruktor 2<br />
Destruktor 1<br />
*** glibc detected *** ./NIS: double free or corruption (out): 0x000000000060acc0 ***<br />
======= Backtrace: =========<br />
/lib64/libc.so.6(+0x73226)[0x2aef840fc226]<br />
/lib64/libc.so.6(cfree+0x6c)[0x2aef84100fcc]<br />
./NIS[0x400f2c]<br />
./NIS[0x400d7c]<br />
/lib64/libc.so.6(__libc_start_main+0xfd)[0x2aef840a7b7d]<br />
./NIS[0x400b19]<br />
======= Memory map: ========<br />
00400000-00402000 r-xp 00000000 00:15 893738069 /homes/numerik/user/C++/NIS_Fkt/NIS<br />
00601000-00602000 r--p 00001000 00:15 893738069 /homes/numerik/user/C++/NIS_Fkt/NIS<br />
00602000-00603000 rw-p 00002000 00:15 893738069 /homes/numerik/user/C++/NIS_Fkt/NIS<br />
00603000-00624000 rw-p 00000000 00:00 0 [heap]<br />
2aef82381000-2aef823a0000 r-xp 00000000 fd:02 10282 /lib64/ld-2.11.2.so</p>
</blockquote>
<p>Was mach ich hier falsch?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/291357/glibc-detected-nis-double-free-or-corruption</link><generator>RSS for Node</generator><lastBuildDate>Mon, 17 Aug 2026 19:35:16 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/291357.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 16 Aug 2011 13:22:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to *** glibc detected *** .&#x2F;NIS: double free or corruption on Tue, 16 Aug 2011 13:22:29 GMT]]></title><description><![CDATA[<p>Werft doch mal bitte einen Blick auf diesen kurzen Code:</p>
<p>NIS.cpp</p>
<pre><code class="language-cpp">#include &quot;NIS_1D.h&quot;
#include &lt;iostream&gt;
#include &lt;string.h&gt;

using namespace std;

int main(int argc, char** argv)
{
	const int N = 3;
	double* Xtrain = new double[N];
	Xtrain[0] = 1.0;
	Xtrain[1] = 2.0;
	Xtrain[2] = 3.0;

	const int M = 3;
	double* Xtest = new double[M];
	Xtest[0] = 5.5;
	Xtest[1] = 6.5;
	Xtest[2] = 7.5;

	int K = 10;
	double T = 2.1;
	double mu1 = 2.9;
	double mu2 = 2.1;
	double sigma1 = 7.4;
	double sigma2 = 8.3;

	double* XTrainCpy = new double[N];
	double* XTestCpy = new double[M];
	memcpy( XTrainCpy, Xtrain, sizeof(double)*N );
	memcpy( XTestCpy, Xtest, sizeof(double)*M );

	NIS_1D nis( XTrainCpy, N, XTestCpy, M, K, T, mu1, mu2, sigma1, sigma2 );

}
</code></pre>
<p>NIS_1D.h</p>
<pre><code class="language-cpp">#ifndef NIS_1D_H_
#define NIS_1D_H_

#include &lt;iostream&gt;
#include &lt;complex&gt;
#include &lt;cmath&gt;

using namespace std;

class NIS_1D {
public:

	double* Xtrain;
	int N; 
	double* Xtest;
	int M; 
	int K; 
	double T; 
	double mu1,mu2,sigma1,sigma2;
	complex&lt;double&gt;* pExpTR;
	complex&lt;double&gt;* nExpTR;
	complex&lt;double&gt;* nExpTE;

	NIS_1D( double* Xtrain, int N, double* Xtest, int M, int K, double T, double mu1, double mu2, double sigma1, double sigma2 );
	virtual ~NIS_1D();

	void preCalculateStuff();

	//Hilfsfunktionen
	complex&lt;double&gt; complexEuler( double r, double phi );
};

#endif /* NIS_1D_H_ */
</code></pre>
<p>NIS_1D.cpp</p>
<pre><code class="language-cpp">#include &quot;NIS_1D.h&quot;

NIS_1D::NIS_1D( double* Xtrain_, int N_, double* Xtest_, int M_, int K_, double T_, double mu1_, double mu2_, double sigma1_, double sigma2_ ) {
	cout &lt;&lt; &quot;Konstruktor 1&quot; &lt;&lt; endl;
	Xtrain = Xtrain_;
	N = N_;
	Xtest = Xtest_;
	M = M_;
	K = K_;
	T = T_;
	mu1 = mu1_;
	mu2 = mu2_;
	sigma1 = sigma1_;
	sigma2 = sigma2_;

	preCalculateStuff();
	cout &lt;&lt; &quot;Konstruktor 2&quot; &lt;&lt; endl;
}

NIS_1D::~NIS_1D() {
	cout &lt;&lt; &quot;Destruktor 1&quot; &lt;&lt; endl;
	delete[] Xtrain;
	cout &lt;&lt; &quot;Destruktor 2&quot; &lt;&lt; endl;
	delete[] Xtest;
	cout &lt;&lt; &quot;Destruktor 3&quot; &lt;&lt; endl;
	delete[] pExpTR;
	cout &lt;&lt; &quot;Destruktor 4&quot; &lt;&lt; endl;
	delete[] nExpTR;
	cout &lt;&lt; &quot;Destruktor 5&quot; &lt;&lt; endl;
	delete[] nExpTE;
	cout &lt;&lt; &quot;Destruktor 6&quot; &lt;&lt; endl;
}

void NIS_1D::preCalculateStuff() {

	int KLength = 2*K+1;

	pExpTR = new complex&lt;double&gt;[KLength*N];
	nExpTR = new complex&lt;double&gt;[KLength*N];
	nExpTE = new complex&lt;double&gt;[KLength*M];
	for( int k = -K; k &lt;= K; ++k ) {
		for( int i = 0; i &lt; N; ++i ) {
			int index = k+i*KLength;
			pExpTR[index] = complexEuler( 1,  2*M_PI*k/T*Xtrain[i] );
			nExpTR[index] = complexEuler( 1, -2*M_PI*k/T*Xtrain[i] );
		}

		for( int i = 0; i &lt; M; ++i ) {
			int index = k+i*KLength;
			nExpTE[index] = complexEuler( 1, -2*M_PI*k/T*Xtest[i] );
		}
	}

}

//Hilfsfuntkionen
complex&lt;double&gt; NIS_1D::complexEuler( double r, double phi ) {
	return complex&lt;double&gt;( r*cos( phi ),r*sin( phi ) );
}
</code></pre>
<p>Wenn ich das ausführe erhalte ich folgenden Fehler:</p>
<blockquote>
<p>NIS_Fkt&gt; ./NIS<br />
Konstruktor 1<br />
Konstruktor 2<br />
Destruktor 1<br />
*** glibc detected *** ./NIS: double free or corruption (out): 0x000000000060acc0 ***<br />
======= Backtrace: =========<br />
/lib64/libc.so.6(+0x73226)[0x2aef840fc226]<br />
/lib64/libc.so.6(cfree+0x6c)[0x2aef84100fcc]<br />
./NIS[0x400f2c]<br />
./NIS[0x400d7c]<br />
/lib64/libc.so.6(__libc_start_main+0xfd)[0x2aef840a7b7d]<br />
./NIS[0x400b19]<br />
======= Memory map: ========<br />
00400000-00402000 r-xp 00000000 00:15 893738069 /homes/numerik/user/C++/NIS_Fkt/NIS<br />
00601000-00602000 r--p 00001000 00:15 893738069 /homes/numerik/user/C++/NIS_Fkt/NIS<br />
00602000-00603000 rw-p 00002000 00:15 893738069 /homes/numerik/user/C++/NIS_Fkt/NIS<br />
00603000-00624000 rw-p 00000000 00:00 0 [heap]<br />
2aef82381000-2aef823a0000 r-xp 00000000 fd:02 10282 /lib64/ld-2.11.2.so</p>
</blockquote>
<p>Was mach ich hier falsch?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2106773</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106773</guid><dc:creator><![CDATA[HändyÄndy]]></dc:creator><pubDate>Tue, 16 Aug 2011 13:22:29 GMT</pubDate></item><item><title><![CDATA[Reply to *** glibc detected *** .&#x2F;NIS: double free or corruption on Tue, 16 Aug 2011 13:33:32 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;string.h&gt; 

...

const int N = 3;
double* Xtrain = new double[N];
</code></pre>
<p>Warum sollte ich da noch weiter lesen? Wenn du dich entgegen besserem Wissen (du hast oft genug hier im Forum gute Tipps bekommen, wie das besser geht), weiterhin selber quälen willst, ist das deine Sache. Aber lass uns da raus.</p>
<p>edit: Oh sdfs-Gott! Memcpy auf nicht-POD-Klassen! Flache Pointerkopien! Das kann doch nicht dein ernst sein. Soll das eine Art Testaufgabe für das Forum sein?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2106776</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106776</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 16 Aug 2011 13:33:32 GMT</pubDate></item><item><title><![CDATA[Reply to *** glibc detected *** .&#x2F;NIS: double free or corruption on Tue, 16 Aug 2011 13:42:02 GMT]]></title><description><![CDATA[<p>Schmeiß alle news raus und probier nochmal.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2106783</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106783</guid><dc:creator><![CDATA[Ethon]]></dc:creator><pubDate>Tue, 16 Aug 2011 13:42:02 GMT</pubDate></item><item><title><![CDATA[Reply to *** glibc detected *** .&#x2F;NIS: double free or corruption on Tue, 16 Aug 2011 13:51:13 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>...(du hast oft genug hier im Forum gute Tipps bekommen, wie das besser geht)...</p>
</blockquote>
<p>Also mir sagt der Name nichts, wer ist es?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2106788</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106788</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Tue, 16 Aug 2011 13:51:13 GMT</pubDate></item><item><title><![CDATA[Reply to *** glibc detected *** .&#x2F;NIS: double free or corruption on Tue, 16 Aug 2011 13:59:11 GMT]]></title><description><![CDATA[<p>314159265358979 schrieb:</p>
<blockquote>
<p>SeppJ schrieb:</p>
<blockquote>
<p>...(du hast oft genug hier im Forum gute Tipps bekommen, wie das besser geht)...</p>
</blockquote>
<p>Also mir sagt der Name nichts, wer ist es?</p>
</blockquote>
<p>Keine Ahnung wer er ist. Apple-Nutzer und kommt von Java, das weiß ich. Mir ist der Name nur schon öfters aufgefallen, weil er immer mal wieder mit ähnlichen Problemen ankommt, die auf &quot;ungewöhnliche&quot; Programmierstrukturen zurückzuführen sind und anscheinend wenig aus den Antworten lernt.</p>
<p>Da man nicht nach Unregistrierten suchen kann:<br />
<a href="https://www.google.de/search?&amp;q=H%C3%A4ndy%C3%84ndy%20site%3Awww.c-plusplus.net" rel="nofollow">Google: HändyÄndy site:www.c-plusplus.net</a><br />
Man lese sich zum Beispiel seinen Thread zu Speicherlöchern durch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2106791</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106791</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 16 Aug 2011 13:59:11 GMT</pubDate></item><item><title><![CDATA[Reply to *** glibc detected *** .&#x2F;NIS: double free or corruption on Tue, 16 Aug 2011 14:04:27 GMT]]></title><description><![CDATA[<p>Oder den hier: <a href="http://www.c-plusplus.net/forum/272695" rel="nofollow">http://www.c-plusplus.net/forum/272695</a> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2106794</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106794</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Tue, 16 Aug 2011 14:04:27 GMT</pubDate></item><item><title><![CDATA[Reply to *** glibc detected *** .&#x2F;NIS: double free or corruption on Tue, 16 Aug 2011 14:13:41 GMT]]></title><description><![CDATA[<p>Tja, leider beschäftige ich mich nicht den ganzen Tag mit C++ und bin im Gegensatz zu Euch auch kein Experte, daher kann es vorkommen, dass ich gelegentlich dasselbe Frage. Finde ich persönlich jetzt aber auch nicht wirklich schlimm. Über eine Antwort würde ich mich dennoch freuen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2106799</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106799</guid><dc:creator><![CDATA[HändyÄndy]]></dc:creator><pubDate>Tue, 16 Aug 2011 14:13:41 GMT</pubDate></item><item><title><![CDATA[Reply to *** glibc detected *** .&#x2F;NIS: double free or corruption on Tue, 16 Aug 2011 14:26:29 GMT]]></title><description><![CDATA[<p>Die Antwort ist einfach, und wurde von SeppJ ja schon angedeutet. Deine Verwendung von new ist hier völlig fehl am Platz.</p>
<p>Abgesehen davon ist bei dir 0 Kapselung zu sehen, aber das dürfte nicht das primäre Problem sein. Der Sinn deines virtuellen Destruktors erschließt sich mir ebenfalls nicht (und ich bezweifle auch, dass du den brauchst, geschweige denn überhaupt verstanden hast.)<br />
(Das sind übrigens nur 3 Kritikpunkte, da lässt sich noch viel mehr finden, als Beispiel string.h)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2106804</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106804</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Tue, 16 Aug 2011 14:26:29 GMT</pubDate></item><item><title><![CDATA[Reply to *** glibc detected *** .&#x2F;NIS: double free or corruption on Tue, 16 Aug 2011 14:27:39 GMT]]></title><description><![CDATA[<p>Danke. Warum soll ich new rausnehmen, wegen &quot;const int&quot;? Ursprünglich war das nur &quot;int&quot;, dann sollte man doch afiak ein new verwenden? Der virtual Konstruktor wurde automatisch von der Entwicklungsumgebung erzeugt, da hab ich nicht weiter drauf geachtet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2106805</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106805</guid><dc:creator><![CDATA[HändyÄndy]]></dc:creator><pubDate>Tue, 16 Aug 2011 14:27:39 GMT</pubDate></item><item><title><![CDATA[Reply to *** glibc detected *** .&#x2F;NIS: double free or corruption on Tue, 16 Aug 2011 14:32:58 GMT]]></title><description><![CDATA[<p>new verwendet man, wenn man dynamischen Speicher braucht und ein RAII Container zu Performance-lastig wäre - also nie. (Selbes gilt übrigens für delete)</p>
<p>Wenn du eine fixe Anzahl an ints brauchst, dann nimm std::array:</p>
<pre><code class="language-cpp">std::array&lt;int, 42&gt; myints;
</code></pre>
<p>Diese anzahl musst du aber schon beim Programmieren (auch Compilezeit genannt) wissen. Wenn erst zur Laufzeit (Zum Beispiel einen User fragen, wie viele Zahlen er eingeben möchte) feststeht, wie viele Zahlen du brauchst, dann nimmt man normalerweise std::vector.</p>
<pre><code class="language-cpp">std::vector&lt;int&gt; myints;
v.push_back(a);
v.push_back(b);
</code></pre>
<p>Bei beiden kann man mit dem Index-Operator [] auf die Elemente zugreifen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2106809</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106809</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Tue, 16 Aug 2011 14:32:58 GMT</pubDate></item><item><title><![CDATA[Reply to *** glibc detected *** .&#x2F;NIS: double free or corruption on Tue, 16 Aug 2011 14:57:30 GMT]]></title><description><![CDATA[<p>Okay, ich habe alle Arrays durch Vektoren ersetzt:</p>
<pre><code>#ifndef NIS_1D_H_
#define NIS_1D_H_

#include &lt;iostream&gt;
#include &lt;complex&gt;
#include &lt;cmath&gt;
#include &lt;vector&gt;

using namespace std;

class NIS_1D {
public:

	vector&lt;double&gt; Xtrain;
	int N;
	vector&lt;double&gt; Xtest;
	int M;
	int K;
	double T;
	double mu1,mu2,sigma1,sigma2;
	vector&lt;complex&lt;double&gt; &gt; pExpTR;
	vector&lt;complex&lt;double&gt; &gt; nExpTR;
	vector&lt;complex&lt;double&gt; &gt; nExpTE;

	NIS_1D( vector&lt;double&gt;&amp; Xtrain, int N, vector&lt;double&gt;&amp; Xtest, int M, int K, double T, double mu1, double mu2, double sigma1, double sigma2 );

	void preCalculateStuff();

	//Hilfsfunktionen
	complex&lt;double&gt; complexEuler( double r, double phi );
};

#endif /* NIS_1D_H_ */
</code></pre>
<pre><code>#include &quot;NIS_1D.h&quot;

NIS_1D::NIS_1D( vector&lt;double&gt;&amp; Xtrain_, int N_, vector&lt;double&gt;&amp; Xtest_, int M_, int K_, double T_,
		        double mu1_, double mu2_, double sigma1_, double sigma2_ ) : Xtrain(Xtrain_), Xtest(Xtest_) {
	N = N_;
	M = M_;
	K = K_;
	T = T_;
	mu1 = mu1_;
	mu2 = mu2_;
	sigma1 = sigma1_;
	sigma2 = sigma2_;

	preCalculateStuff();
}

void NIS_1D::preCalculateStuff() {

	int KLength = 2*K+1;

	pExpTR.resize( sizeof(double), KLength*N );
	nExpTR.resize( sizeof(double), KLength*N );
	nExpTE.resize( sizeof(double), KLength*M );

	//Bei 1D wird kein Hyperbolisches Kreuz benötigt. Was soll das auch schon sein?
	for( int k = -K; k &lt;= K; ++k ) {
		for( int i = 0; i &lt; N; ++i ) {
			int index = k+i*KLength;
			pExpTR[index] = complexEuler( 1,  2*M_PI*k/T*Xtrain[i] );
			nExpTR[index] = complexEuler( 1, -2*M_PI*k/T*Xtrain[i] );
		}

		for( int i = 0; i &lt; M; ++i ) {
			int index = k+i*KLength;
			nExpTE[index] = complexEuler( 1, -2*M_PI*k/T*Xtest[i] );
		}
	}

}

//Hilfsfuntkionen
complex&lt;double&gt; NIS_1D::complexEuler( double r, double phi ) {
	return complex&lt;double&gt;( r*cos( phi ),r*sin( phi ) );
}
</code></pre>
<p>und NIS.cpp</p>
<pre><code>#include &quot;NIS_1D.h&quot;

#include &lt;iostream&gt;
#include &lt;vector&gt;

using namespace std;

int main(int argc, char** argv)
{
	vector&lt;double&gt; Xtrain;
	Xtrain.push_back( 1.0 );
	Xtrain.push_back( 2.0 );
	Xtrain.push_back( 3.0 );
	int N = Xtrain.size();

	vector&lt;double&gt; Xtest;
	Xtest.push_back( 5.5 );
	Xtest.push_back( 6.5 );
	Xtest.push_back( 7.5 );
	int M = Xtest.size();

	int K = 10;
	double T = 2.1;
	double mu1 = 2.9;
	double mu2 = 2.1;
	double sigma1 = 7.4;
	double sigma2 = 8.3;

	NIS_1D nis( Xtrain, N, Xtest, M, K, T, mu1, mu2, sigma1, sigma2 );
	cout &lt;&lt; &quot;done&quot; &lt;&lt; endl;
}
</code></pre>
<p>Ich erhalte nach wie vor denselben Fehler:</p>
<blockquote>
<p>NIS_Fkt&gt; ./NIS<br />
done<br />
*** glibc detected *** ./NIS: double free or corruption (out): 0x000000000060ee40 ***<br />
======= Backtrace: =========<br />
/lib64/libc.so.6(+0x73226)[0x2aeb02ebe226]<br />
/lib64/libc.so.6(cfree+0x6c)[0x2aeb02ec2fcc]<br />
./NIS[0x401d4c]<br />
./NIS[0x401b72]<br />
./NIS[0x4017d5]<br />
./NIS[0x401330]<br />
./NIS[0x40112f]<br />
./NIS[0x401037]<br />
/lib64/libc.so.6(__libc_start_main+0xfd)[0x2aeb02e69b7d]<br />
./NIS[0x400d89]<br />
======= Memory map: ========<br />
usw. ...</p>
</blockquote>
<p>Woran kann es jetzt noch liegen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2106827</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106827</guid><dc:creator><![CDATA[HändyÄndy]]></dc:creator><pubDate>Tue, 16 Aug 2011 14:57:30 GMT</pubDate></item><item><title><![CDATA[Reply to *** glibc detected *** .&#x2F;NIS: double free or corruption on Tue, 16 Aug 2011 14:58:36 GMT]]></title><description><![CDATA[<p>Wenn du's so machst wie Pi (und andere) hier vorschlagen, sollten schon einmal eine Menge Probleme verschwinden. Dann werden deine Objekte nämlich auf einmal auf &quot;magische&quot; Weise vernünftig kopier- und zuweisungsfähig. Das Problem derzeit ist vermutlich da drauf zurück zu führen, dass du die Regel der großen Drei massivst verletzt.</p>
<p>Was aber auch noch ein großes Problem sein könnte ist das memcpy. Das ist auch eine Todsünde auf Klassen mit komplexen Konstruktoren. Wenn du es wie oben machst, sollte diese Komplexität zwar wegfallen und es &quot;sollte&quot; funktionieren, aber es gibt keinen Grund etwas zu riskieren. Wer weiß schon, wie complex intern genau aufgebaut ist? Ein normales copy macht genau das gleiche und ist dabei aber sicher.</p>
<p>Das sind erst einmal die schlimmsten Fehler, vermutlich wird's auch funktionieren, wenn du das umsetzt. Und wenn du noch ein bisschen an deinem Stil arbeitest und Variablen möglichst lokal und mit sprechenden Namen deklarierst, kann man sich den Code sogar durchlesen und verstehen, falls du doch noch Fehler haben solltest.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2106830</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106830</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 16 Aug 2011 14:58:36 GMT</pubDate></item><item><title><![CDATA[Reply to *** glibc detected *** .&#x2F;NIS: double free or corruption on Tue, 16 Aug 2011 14:59:25 GMT]]></title><description><![CDATA[<p>Erstell ein neues Projekt oder wenn du weisst wie man das Projekt leert, dann leere es.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2106831</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106831</guid><dc:creator><![CDATA[ItsAnOldExecutable]]></dc:creator><pubDate>Tue, 16 Aug 2011 14:59:25 GMT</pubDate></item><item><title><![CDATA[Reply to *** glibc detected *** .&#x2F;NIS: double free or corruption on Tue, 16 Aug 2011 15:03:04 GMT]]></title><description><![CDATA[<p>HändyÄndy schrieb:</p>
<blockquote>
<pre><code>NIS_Fkt&gt; ./NIS
done
*** glibc detected *** ./NIS: double free or corruption (out): 0x000000000060ee40 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x73226)[0x2aeb02ebe226]
/lib64/libc.so.6(cfree+0x6c)[0x2aeb02ec2fcc]
./NIS[0x401d4c]
./NIS[0x401b72]
./NIS[0x4017d5]
./NIS[0x401330]
./NIS[0x40112f]
./NIS[0x401037]
/lib64/libc.so.6(__libc_start_main+0xfd)[0x2aeb02e69b7d]
./NIS[0x400d89]
======= Memory map: ========
usw. ...
</code></pre>
<p>Woran kann es jetzt noch liegen?</p>
</blockquote>
<p>Ein Stacktrace aus einem Programm ohne Debuginformationen ist reichlich nutzlos. Compilier mal mit Debuginforamtionen, dann sieht man wenigstens, wo der Fehler ist. Und wenn du das schon hast, dann schmeiß auch mal den Debugger an und versuch herauszufinden, was da los ist. Der Debugger ist das wohl wichtigste Werkzeug eines Programmierers (wichtiger als Editor und Compiler würde ich sagen), du solltest unbedingt damit umgehen können. Im Internet kannst du Tutorials zum Debugger in deiner Toolchain finden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2106835</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106835</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 16 Aug 2011 15:03:04 GMT</pubDate></item><item><title><![CDATA[Reply to *** glibc detected *** .&#x2F;NIS: double free or corruption on Tue, 16 Aug 2011 15:33:52 GMT]]></title><description><![CDATA[<p>Ich habe den Fehler gefunden, er entstand dadurch, dass bei der for-Schleife</p>
<p>for( int k = -K; k &lt;= K; ++k )</p>
<p>der Index k negativ sein konnte, dadurch habe ich im Vektor auf ein negativ indiziertes Element, das es ja nicht gibt, zugegriffen und es kam zu einem Fehler.<br />
Außerdem war das hier auch noch falsch:</p>
<p>pExpTR.resize( sizeof(double), KLength<em>N );<br />
nExpTR.resize( sizeof(double), KLength</em>N );<br />
nExpTE.resize( sizeof(double), KLength*M );</p>
<p>Ich habe es ersetzt durch</p>
<p>complex&lt;double&gt; zero(0,0);<br />
pExpTR.resize( KLength<em>N, zero );<br />
nExpTR.resize( KLength</em>N, zero );<br />
nExpTE.resize( KLength*M, zero );</p>
<p>Ich habe die for-Schleife entsprechend repariert:</p>
<p>for( int k = 0; k &lt; KLength; ++k )</p>
<p>Vielen Dank für die Unterstützung und Hinweise!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2106851</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2106851</guid><dc:creator><![CDATA[HändyÄndy]]></dc:creator><pubDate>Tue, 16 Aug 2011 15:33:52 GMT</pubDate></item></channel></rss>