<?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[unerklärlich -&amp;gt; segfault wegen zu wenig speicher ?]]></title><description><![CDATA[<p>Hallo,<br />
ich kämpfe seit tagen an dem problem...</p>
<p>begonnen hat alles damit dass eine bibliotheksfunktion ein array veränderte welches überhaupt nichts mit ihr zu tun hatte. Ich dachte da an einen Buffer Oveflow in der Bibliotheksfunktion...</p>
<p>Nun wollte ich &quot;auf andere Art&quot; etwas die IMplementierung umschreiben und bekomme einen seltsamen segfault. Er kann meinen vektor einfach nicht füllen...</p>
<pre><code class="language-cpp">std::vector&lt;double&gt; erg;
    for(int i = 0; i &lt; 100; i++)
    {
        std::cout &lt;&lt; &quot;iter: &quot; &lt;&lt;  i &lt;&lt; std::endl;
        erg.push_back(1.0);
    }
</code></pre>
<p>bei iteration 2 hört er auf...</p>
<p>im Debugger angeschmissen...<br />
ich komme kurz bevor der segfault kommt an diese stelle in den bibliotheken:</p>
<pre><code class="language-cpp">push_back(const value_type&amp; __x)
      {
	if (_M_finish != _M_end_of_storage)
	  {
	    _Construct(_M_finish, __x);
	    ++_M_finish;
	  }
</code></pre>
<p>auf einen weiteren step kommt:</p>
<pre><code class="language-cpp">iterator
      end() { return iterator (_M_finish); }
</code></pre>
<p>und dann kommt der segfault....</p>
<p>eine augabe meines top unter linux ergibt im debugger nur noch freien speicher von ca. 3222 kb. also ziemlich voll - obwohl ich an der stelle nicht weiß ob das überhaupt eine aussage ist mit top weil ja evtl. einfach der maximale speicher reserviert wird durch den debugger...keine Ahnung..</p>
<p>Für Jede Hilfe bin ich tausend mal dankbar!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/161247/unerklärlich-gt-segfault-wegen-zu-wenig-speicher</link><generator>RSS for Node</generator><lastBuildDate>Fri, 11 Sep 2026 22:54:31 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/161247.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 04 Oct 2006 19:20:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to unerklärlich -&amp;gt; segfault wegen zu wenig speicher ? on Wed, 04 Oct 2006 19:20:09 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich kämpfe seit tagen an dem problem...</p>
<p>begonnen hat alles damit dass eine bibliotheksfunktion ein array veränderte welches überhaupt nichts mit ihr zu tun hatte. Ich dachte da an einen Buffer Oveflow in der Bibliotheksfunktion...</p>
<p>Nun wollte ich &quot;auf andere Art&quot; etwas die IMplementierung umschreiben und bekomme einen seltsamen segfault. Er kann meinen vektor einfach nicht füllen...</p>
<pre><code class="language-cpp">std::vector&lt;double&gt; erg;
    for(int i = 0; i &lt; 100; i++)
    {
        std::cout &lt;&lt; &quot;iter: &quot; &lt;&lt;  i &lt;&lt; std::endl;
        erg.push_back(1.0);
    }
</code></pre>
<p>bei iteration 2 hört er auf...</p>
<p>im Debugger angeschmissen...<br />
ich komme kurz bevor der segfault kommt an diese stelle in den bibliotheken:</p>
<pre><code class="language-cpp">push_back(const value_type&amp; __x)
      {
	if (_M_finish != _M_end_of_storage)
	  {
	    _Construct(_M_finish, __x);
	    ++_M_finish;
	  }
</code></pre>
<p>auf einen weiteren step kommt:</p>
<pre><code class="language-cpp">iterator
      end() { return iterator (_M_finish); }
</code></pre>
<p>und dann kommt der segfault....</p>
<p>eine augabe meines top unter linux ergibt im debugger nur noch freien speicher von ca. 3222 kb. also ziemlich voll - obwohl ich an der stelle nicht weiß ob das überhaupt eine aussage ist mit top weil ja evtl. einfach der maximale speicher reserviert wird durch den debugger...keine Ahnung..</p>
<p>Für Jede Hilfe bin ich tausend mal dankbar!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149469</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149469</guid><dc:creator><![CDATA[Mati]]></dc:creator><pubDate>Wed, 04 Oct 2006 19:20:09 GMT</pubDate></item><item><title><![CDATA[Reply to unerklärlich -&amp;gt; segfault wegen zu wenig speicher ? on Wed, 04 Oct 2006 20:00:35 GMT]]></title><description><![CDATA[<p>Wo ist denn ganz genau der Segfault? Mach mal einen backtrace. Ein Speicherproblem kann es imho nicht sein (100 * 8 Byte &lt;&lt; 3 MB). Du kannst auch mal probieren, den Speicher direk zu belegen. Die Zeile:</p>
<pre><code class="language-cpp">std::vector&lt;double&gt; erg (100, 1.0);
</code></pre>
<p>entspricht (vom Ergebnis her) genau deinem Code.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149513</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149513</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Wed, 04 Oct 2006 20:00:35 GMT</pubDate></item><item><title><![CDATA[Reply to unerklärlich -&amp;gt; segfault wegen zu wenig speicher ? on Wed, 04 Oct 2006 20:17:48 GMT]]></title><description><![CDATA[<p>eh ist dass das richtige ? ...</p>
<pre><code>Invalid read of size 4
==5899==    at 0x1CE65642: std::__default_alloc_template&lt;true, 0&gt;::allocate(unsigned) (in /usr/lib/libstdc++.so.5.0.7)
==5899==    by 0x8069B59: std::vector&lt;double, std::allocator&lt;double&gt; &gt;::_M_insert_aux(__gnu_cxx::__normal_iterator&lt;double*, std::vector&lt;double, std::allocator&lt;double&gt; &gt; &gt;, double const&amp;) (stl_alloc.h:232)
==5899==    by 0x8067560: Spai::Create_A_Hat_test(std::vector&lt;double, std::allocator&lt;double&gt; &gt;, int&amp;, int&amp;, std::vector&lt;double, std::allocator&lt;double&gt; &gt;, std::vector&lt;double, std::allocator&lt;double&gt; &gt;) (stl_vector.h:371)
==5899==    by 0x806600B: Spai::Spai_Algorithm(std::vector&lt;double, std::allocator&lt;double&gt; &gt; const&amp;, std::vector&lt;double, std::allocator&lt;double&gt; &gt; const&amp;, int) (stl_alloc.h:242)
==5899==    by 0x8065637: Spai::Spai() (Spai.cpp:245)
==5899==    by 0x806B2E9: Caching::Caching() (Caching.cpp:12)
==5899==    by 0x80507BB: UIMainWindow::UIMainWindow() (UIMainWindow.cpp:25)
==5899==    by 0x8050480: main (UIMain.cpp:16)
==5899==  Address 0x74F75AC is not stack'd, malloc'd or (recently) free'd
==5899==
==5899== Process terminating with default action of signal 11 (SIGSEGV)
==5899==  Access not within mapped region at address 0x74F75AC
==5899==    at 0x1CE65642: std::__default_alloc_template&lt;true, 0&gt;::allocate(unsigned) (in /usr/lib/libstdc++.so.5.0.7)
==5899==    by 0x8069B59: std::vector&lt;double, std::allocator&lt;double&gt; &gt;::_M_insert_aux(__gnu_cxx::__normal_iterator&lt;double*, std::vector&lt;double, std::allocator&lt;double&gt; &gt; &gt;, double const&amp;) (stl_alloc.h:232)
==5899==    by 0x8067560: Spai::Create_A_Hat_test(std::vector&lt;double, std::allocator&lt;double&gt; &gt;, int&amp;, int&amp;, std::vector&lt;double, std::allocator&lt;double&gt; &gt;, std::vector&lt;double, std::allocator&lt;double&gt; &gt;) (stl_vector.h:371)
==5899==    by 0x806600B: Spai::Spai_Algorithm(std::vector&lt;double, std::allocator&lt;double&gt; &gt; const&amp;, std::vector&lt;double, std::allocator&lt;double&gt; &gt; const&amp;, int) (stl_alloc.h:242)
==5899==    by 0x8065637: Spai::Spai() (Spai.cpp:245)
==5899==    by 0x806B2E9: Caching::Caching() (Caching.cpp:12)
==5899==    by 0x80507BB: UIMainWindow::UIMainWindow() (UIMainWindow.cpp:25)
==5899==    by 0x8050480: main (UIMain.cpp:16)
</code></pre>
<p>wenn nicht bitte um vergebung <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1149525</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149525</guid><dc:creator><![CDATA[Mati]]></dc:creator><pubDate>Wed, 04 Oct 2006 20:17:48 GMT</pubDate></item><item><title><![CDATA[Reply to unerklärlich -&amp;gt; segfault wegen zu wenig speicher ? on Wed, 04 Oct 2006 21:52:10 GMT]]></title><description><![CDATA[<p>da ich einfach nicht weiter weiss und verzweifelt bin...wenn ich diese methode auskommentiere dann iteriert er weiter als bis 2 aber bricht dann bei 46 ab...</p>
<p>kann es evtl. sein dass die Referenzen irgendwie dafür verantwortlich sind?</p>
<pre><code class="language-cpp">Insert_m_k_hat      (M, 
                                     p_col, 
                                     e_k_hat);

...

void 
Spai::Insert_m_k_hat(std::vector&lt; double &gt;&amp; M, 
                     const std::vector&lt; double &gt;&amp; p_col,
                     const std::vector&lt; double &gt;&amp; e_k_hat)
{
    std::vector&lt; double &gt;::const_iterator el = e_k_hat.begin(); 
    for( std::vector&lt; double &gt;::const_iterator i = p_col.begin(); 
         i != p_col.end(); 
         ++i ) 
    { 
        if( !(fabs(*i - 0.0) &lt;= epsilon) )
            M.push_back(*el++);  
        else 
            M.push_back(0.0);   
    } 
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1149585</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1149585</guid><dc:creator><![CDATA[Mati]]></dc:creator><pubDate>Wed, 04 Oct 2006 21:52:10 GMT</pubDate></item><item><title><![CDATA[Reply to unerklärlich -&amp;gt; segfault wegen zu wenig speicher ? on Thu, 05 Oct 2006 15:39:55 GMT]]></title><description><![CDATA[<p>Kann es sein, dass el zu weit läuft? Füg doch mal &quot;&amp;&amp; (el != e_k_hat.end ())&quot; zu den Abbruchbedingungen hinzu.</p>
<p>/edit Und was soll die Bedingung da? fabs(*i - 0.0) ist doch gleich fabs(*i)?!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1150013</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1150013</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Thu, 05 Oct 2006 15:39:55 GMT</pubDate></item><item><title><![CDATA[Reply to unerklärlich -&amp;gt; segfault wegen zu wenig speicher ? on Thu, 05 Oct 2006 17:25:36 GMT]]></title><description><![CDATA[<p>danke für die Hilfe aber es ist wirklich immer so dass bei mir e_k_hat immer &lt;= p_col ist. Das heißt er schießt nie darüber hinaus. Aber um sicherzugehen habe ich die abfrage auch reingemacht - das ergebnis war aber wie erwartet immer noch der segfault - es hat sich also nichts verändert.</p>
<p>Zum fasb. wenn ich einen float wert vergleichen will z.B a = 4.0 und ich will testen ob er == 0.0 ist dann geht dass so wegen der rechenungenauigkeit nicht....deswegen muss ich doch auf eine untere schranke gehen und mit dem absolutbetrag testen....ein blosses fasb(*i) bringt mir so also net was....</p>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1150064</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1150064</guid><dc:creator><![CDATA[Mati]]></dc:creator><pubDate>Thu, 05 Oct 2006 17:25:36 GMT</pubDate></item><item><title><![CDATA[Reply to unerklärlich -&amp;gt; segfault wegen zu wenig speicher ? on Thu, 05 Oct 2006 17:28:54 GMT]]></title><description><![CDATA[<p>Und was glaubst du was bei einem - 0.0 passiert? Richtig es wird 0 abgezogen und evt. noch ein bischen ganz weit hinterm Komma, falls der double auf deiner Plattform zu ungenau ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1150065</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1150065</guid><dc:creator><![CDATA[lolz]]></dc:creator><pubDate>Thu, 05 Oct 2006 17:28:54 GMT</pubDate></item><item><title><![CDATA[Reply to unerklärlich -&amp;gt; segfault wegen zu wenig speicher ? on Thu, 05 Oct 2006 17:34:56 GMT]]></title><description><![CDATA[<p>Also in meiner Welt ist 4.0 - 0.0 immernoch 4.0 und nicht kleiner-gleich ist größer (-&gt; fabs(*i) &gt; epsilon entspricht deiner Zeile)... ist aber nicht so wichtig, daran sollte es nicht liegen.</p>
<p>/edit: mkay, zu spät.<br />
Welchen Compiler und Debugger benutzt du?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1150069</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1150069</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Thu, 05 Oct 2006 17:34:56 GMT</pubDate></item><item><title><![CDATA[Reply to unerklärlich -&amp;gt; segfault wegen zu wenig speicher ? on Thu, 05 Oct 2006 17:51:42 GMT]]></title><description><![CDATA[<p>hmm...jetzt bin ich ein wenig verwirrt...</p>
<p>folgendes:<br />
float a = 1.0<br />
if (a == 1.0)<br />
...</p>
<p>geht das so?<br />
folgendes aus einem anderen thread:</p>
<blockquote>
<p>Gleitpunktzahl Vergleiche macht man immer mit<br />
|WertA - WertB| &lt; e<br />
Das liegt daran das Gleitpunktzahlen eben recht ungenau werden, je größer der Bertrag vom Exponenten wird.</p>
</blockquote>
<p>deswegen dachte ich auch dass das bei a = 0.0 so sein müsste...</p>
<p>ich lasse mich gern belehren...</p>
<p>hmm aber mein hauptproblem löst das ja nicht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>compiler: g++ 3.3.5<br />
debugger: valgrind</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1150081</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1150081</guid><dc:creator><![CDATA[Mati]]></dc:creator><pubDate>Thu, 05 Oct 2006 17:51:42 GMT</pubDate></item><item><title><![CDATA[Reply to unerklärlich -&amp;gt; segfault wegen zu wenig speicher ? on Thu, 05 Oct 2006 17:57:31 GMT]]></title><description><![CDATA[<p>Es geht eigentlich um das fabs( 4.0 - 0.0 ) &lt; epsilon und nicht um ein 4.0 == 4.0<br />
Das 0.0 in fabs kannst du weglassen nicht den epsilon-test.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1150088</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1150088</guid><dc:creator><![CDATA[lolz]]></dc:creator><pubDate>Thu, 05 Oct 2006 17:57:31 GMT</pubDate></item><item><title><![CDATA[Reply to unerklärlich -&amp;gt; segfault wegen zu wenig speicher ? on Thu, 05 Oct 2006 18:03:01 GMT]]></title><description><![CDATA[<p>hehe ach so ja logisch...hab vor lauter bäumen den wald nimmer gesehen...danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1150097</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1150097</guid><dc:creator><![CDATA[Mati]]></dc:creator><pubDate>Thu, 05 Oct 2006 18:03:01 GMT</pubDate></item><item><title><![CDATA[Reply to unerklärlich -&amp;gt; segfault wegen zu wenig speicher ? on Thu, 05 Oct 2006 22:12:22 GMT]]></title><description><![CDATA[<p>ich habe nun vergeblich versucht mein programm abzuändern...mittlerweile weiß ich einfach nicht weiter....ich habe nun ALLE referenzen aufgelöst und übergebe funktionsargumente nur noch so damit lokale kopien angelegt werden...es hat nichts gebracht...</p>
<p>mittlerweile bekomme ich folgende meldung mit der ich nichts anfangen kann:</p>
<pre><code>Conditional jump or move depends on uninitialised value(s)
==7212==    at 0x1CE65746: std::__default_alloc_template&lt;true, 0&gt;::deallocate(void*, unsigned) (in /usr/lib/libstdc++.so.5.0.7)
==7212==    by 0x8064E3A: Spai::ttt() (Spai.cpp:280)
==7212==    by 0x806B3E9: Caching::Caching() (Caching.cpp:12)
==7212==    by 0x80507BB: UIMainWindow::UIMainWindow() (UIMainWindow.cpp:25)
==7212==    by 0x8050480: main (UIMain.cpp:16)
==7212==
==7212== Conditional jump or move depends on uninitialised value(s)
==7212==    at 0x1B906C5D: operator delete(void*) (vg_replace_malloc.c:155)
==7212==    by 0x1CE6575B: std::__default_alloc_template&lt;true, 0&gt;::deallocate(void*, unsigned) (in /usr/lib/libstdc++.so.5.0.7)
==7212==    by 0x8064E3A: Spai::ttt() (Spai.cpp:280)
==7212==    by 0x806B3E9: Caching::Caching() (Caching.cpp:12)
==7212==    by 0x80507BB: UIMainWindow::UIMainWindow() (UIMainWindow.cpp:25)
==7212==    by 0x8050480: main (UIMain.cpp:16)
==7212==
==7212== Invalid free() / delete / delete[]
==7212==    at 0x1B906CA8: operator delete(void*) (vg_replace_malloc.c:155)
==7212==    by 0x1CE6575B: std::__default_alloc_template&lt;true, 0&gt;::deallocate(void*, unsigned) (in /usr/lib/libstdc++.so.5.0.7)
==7212==    by 0x8064E3A: Spai::ttt() (Spai.cpp:280)
==7212==    by 0x806B3E9: Caching::Caching() (Caching.cpp:12)
==7212==    by 0x80507BB: UIMainWindow::UIMainWindow() (UIMainWindow.cpp:25)
==7212==    by 0x8050480: main (UIMain.cpp:16)
==7212==  Address 0x1CE9C440 is not stack'd, malloc'd or (recently) free'd
</code></pre>
<p>nach 5 tagen würde ich am liebsten den rechner zertrümmern <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1150249</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1150249</guid><dc:creator><![CDATA[Mati]]></dc:creator><pubDate>Thu, 05 Oct 2006 22:12:22 GMT</pubDate></item><item><title><![CDATA[Reply to unerklärlich -&amp;gt; segfault wegen zu wenig speicher ? on Fri, 06 Oct 2006 10:35:13 GMT]]></title><description><![CDATA[<p>da ich nicht mehr weiterweiss post ich mal (dummerweise) die klasse in der der fehler liegen muss...kompilieren werdet ihr es net können weil ich fortran aufrufe drin hab....aber hier mal der teil der dafür verantwortlich sein muss - vielleicht hat jemand ein so geschultes auge dass er den fehler so erkennt...???</p>
<pre><code class="language-cpp">std::vector&lt; double &gt;
Spai::Spai_Algorithm(const std::vector&lt; double &gt;&amp; A, 
                     const std::vector&lt; double &gt;&amp; P,
                     const int dimension
                     )
{   
    int                             m,
                                    n,
                                    lda,
                                    k,
                                    info,
                                    lwork,
                                    one = 1;

    char                            *SIDE=&quot;L&quot;, 
                                    *TRANS=&quot;T&quot;, //from left and transpose
                                    *UPLO=&quot;U&quot;, 
                                    *NCHAR=&quot;N&quot;; // upper triangular matrix not transposed

    std::vector&lt; double &gt;            work,
                                     tau,
                                     M,
                                     A_hat,
                                     e_k_hat,
                                     p_col(dimension);

    std::vector&lt; double &gt;::iterator  iter;

    for(int col = 0; col &lt; dimension; col++)
    {

        Get_Pattern_Column          (p_col, 
                                     P, 
                                     col, 
                                     dimension);

        Create_e_k                  (col, 
                                     dimension, 
                                     e_k_hat);

        Create_A_Hat__e_k_Hat       (A, 
                                     n, 
                                     m, 
                                     p_col, 
                                     A_hat, 
                                     e_k_hat);

        Update_Lapack_Values        (m,
                                     n,
                                     k,
                                     lda,
                                     tau,
                                     lwork,
                                     work);

        get_opt_lwork               (A_hat, 
                                     m, 
                                     n);

        dgeqrf_                     (&amp;m, 
                                     &amp;n, 
                                     &amp;A_hat[0], 
                                     &amp;lda, 
                                     &amp;tau[0], 
                                     &amp;work[0], 
                                     &amp;lwork, 
                                     &amp;info);   

        //Computing :   Q^T * e_k_hat
        dormqr_                     (SIDE,
                                     TRANS,
                                     &amp;m,
                                     &amp;n,
                                     &amp;k,
                                     &amp;A_hat[0],
                                     &amp;lda,
                                     &amp;tau[0],
                                     &amp;e_k_hat[0],
                                     &amp;lda,
                                     &amp;work[0],
                                     &amp;lwork,
                                     &amp;info);

        Ectract_quadratic_content   (A_hat, 
                                     m, 
                                     n);

        dtrtrs_                     (UPLO,
                                     NCHAR,
                                     NCHAR,
                                     &amp;n,
                                     &amp;one,
                                     &amp;A_hat[0],
                                     &amp;n,
                                     &amp;e_k_hat[0],
                                     &amp;n,
                                     &amp;info);

        Insert_m_k_hat              (M, 
                                     p_col, 
                                     e_k_hat);

    }
    return M;
}

void
Spai::Get_Pattern_Column(std::vector&lt; double &gt;&amp; p_col, 
                         const std::vector&lt; double &gt;&amp; P, 
                         const int col, 
                         const int dimension)
{
    p_col.clear();
    p_col.insert(p_col.begin(), 
                 P.begin() + dimension * col, 
                 P.begin() + dimension * ( col + 1 ));
}

void
Spai::Create_e_k(const int col, 
                 const int dimension, 
                 std::vector&lt; double &gt;&amp; e_k_hat)
{
    e_k_hat.clear();
    e_k_hat.resize(dimension, 0.0);
    e_k_hat[col] = 1.0;
}

void
Spai::Create_A_Hat__e_k_Hat(const std::vector&lt; double &gt;&amp; A,
                            int&amp; A_hat_dim_x,
                            int&amp; A_hat_dim_y, 
                            const std::vector&lt; double &gt;&amp; p_col,
                            std::vector&lt; double &gt;&amp; A_hat,
                            std::vector&lt; double &gt;&amp; e_k_hat)
{   
    A_hat_dim_x = 0;
    A_hat_dim_y = p_col.size(); 

    A_hat.clear();
    for(int y = 0; y &lt; p_col.size(); y++)
    {   
        if(fabs(p_col[y] - 1.0) &lt;= epsilon)
        {
            A_hat.insert(A_hat.end(), 
                         A.begin() + p_col.size() * y, 
                         A.begin() + p_col.size() * (y + 1));
            A_hat_dim_x++;
        }
    }
    Erase_Zero_Rows(A_hat, A_hat_dim_x, A_hat_dim_y, e_k_hat);
}

void 
Spai::Erase_Zero_Rows(std::vector&lt; double &gt;&amp; matrix, 
                      int&amp; x_dim, 
                      int&amp; y_dim, 
                      std::vector&lt; double &gt;&amp; vector)
{
    std::vector&lt; bool &gt;     mask( y_dim );

    for ( int y = 0; y &lt; y_dim; ++y )
    {
        mask[ y ] = true;
        if(fabs(vector[ y ] - 1.0) &lt;= epsilon)
            mask[ y ] = false;
        for ( int x = 0; x &lt; x_dim; ++x )
        {
            if ( matrix[ x * y_dim + y ] != 0 )
            {
                mask[ y ] = false;
                break;
            }
        }
    }

    matrix.erase( std::remove_if( matrix.begin(), 
                  matrix.end(), 
                  IS_MASKED( matrix, mask ) ), 
    matrix.end() );
    vector.erase( std::remove_if( vector.begin(), 
                  vector.end(), 
                  IS_MASKED( vector, mask ) ), 
    vector.end() );

    y_dim = matrix.size() / x_dim;    
}

void 
Spai::Update_Lapack_Values(const int m,
                           const int n,
                           int&amp; k,
                           int&amp; lda,
                           std::vector&lt; double &gt;&amp; tau,
                           int&amp; lwork,
                           std::vector&lt; double &gt;&amp; work)
{
    tau.clear();
    work.clear();
    k = std::min(m,n);
    lda = std::max(m,1); 
    lwork = std::max(n,1);            
    tau.resize(k);   
    work.resize(std::max(1,lwork));
}

void 
Spai::Insert_m_k_hat(std::vector&lt; double &gt;&amp; M, 
                     const std::vector&lt; double &gt;&amp; p_col,
                     const std::vector&lt; double &gt;&amp; e_k_hat)
{
    std::vector&lt; double &gt;::const_iterator el = e_k_hat.begin(); 
    for( std::vector&lt; double &gt;::const_iterator i = p_col.begin(); 
         i != p_col.end(); 
         ++i ) 
    { 
        if( !(fabs(*i - 0.0) &lt;= epsilon) )
            M.push_back(*el++);  
        else 
            M.push_back(0.0);   
    } 
}

void 
Spai::Ectract_quadratic_content(std::vector&lt; double &gt;&amp; A_hat, 
                                const int m, 
                                const int n)
{
    if (m &lt;= n)
        A_hat.erase(A_hat.begin() + m * m, A_hat.end());
    else
    {
        std::vector&lt; bool &gt;     mask( m );
        for ( int y = 0; y &lt; m; ++y )
        {
            mask[ y ] = false;
            if(y &gt;= n)
                mask[ y ] = true;
        }

        A_hat.erase( std::remove_if( A_hat.begin(), 
                     A_hat.end(), 
                     IS_MASKED( A_hat, mask ) ), 
                     A_hat.end() );
    }   
}

int 
Spai::get_opt_lwork(std::vector&lt; double &gt;&amp; A_hat,
                    int m,
                    int n)
{
    int                     lw = -1,
    info = 0,
    lwork = 0;

    double                  work = 0.0;

    std::vector&lt; double &gt;   tau;

    dgeqrf_(&amp;m,
            &amp;n,
            &amp;A_hat[0],
            &amp;m,
            &amp;tau[0],
            &amp;work,
            &amp;lw,
            &amp;info);

    lwork = static_cast&lt; int &gt; (work);

    return lwork;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1150465</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1150465</guid><dc:creator><![CDATA[Mati]]></dc:creator><pubDate>Fri, 06 Oct 2006 10:35:13 GMT</pubDate></item><item><title><![CDATA[Reply to unerklärlich -&amp;gt; segfault wegen zu wenig speicher ? on Fri, 06 Oct 2006 16:28:56 GMT]]></title><description><![CDATA[<p>Ich kann mit der Meldung auch nichts anfangen (ich benutze gdb). Kompilier mal mit der Flag -g2 und mach dann mit gdb einen backtrace (&quot;gdb dein_program&quot; -&gt; run -&gt; bt), dann sollte genau die Zeile gezeigt werden, bei der der Segfault fliegt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1150709</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1150709</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Fri, 06 Oct 2006 16:28:56 GMT</pubDate></item><item><title><![CDATA[Reply to unerklärlich -&amp;gt; segfault wegen zu wenig speicher ? on Fri, 06 Oct 2006 22:39:45 GMT]]></title><description><![CDATA[<p>danke für die hilfe filmor...</p>
<p>nach deinen anweisungen hier die meldung:</p>
<pre><code>Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1101404608 (LWP 8201)]
0x4155b642 in std::__default_alloc_template&lt;true, 0&gt;::allocate () from /usr/lib/libstdc++.so.5
(gdb) bt
#0  0x4155b642 in std::__default_alloc_template&lt;true, 0&gt;::allocate () from /usr/lib/libstdc++.so.5
#1  0x080698aa in std::vector&lt;double, std::allocator&lt;double&gt; &gt;::_M_insert_aux (this=0xbffff3b0, __x=@0x814a6f0) at stl_alloc.h:232
#2  0x080669cf in Spai::Create_A_Hat_test (this=0xbffff610, A=
          {&lt;std::_Vector_base&lt;double, std::allocator&lt;double&gt; &gt;&gt; = {&lt;std::_Vector_alloc_base&lt;double, std::allocator&lt;double&gt;, true&gt;&gt; = {_M_start = 0x814a6e0, _M_finish = 0x814a760, _M_end_of_storage = 0x814a760}, &lt;No data fields&gt;}, &lt;No data fields&gt;},
    A_hat_dim_x=@0xbffff31c, A_hat_dim_y=@0x8cf3e715, p_col=
          {&lt;std::_Vector_base&lt;double, std::allocator&lt;double&gt; &gt;&gt; = {&lt;std::_Vector_alloc_base&lt;double, std::allocator&lt;double&gt;, true&gt;&gt; = {_M_start = 0x814a140, _M_finish = 0x814a160, _M_end_of_storage = 0x814a160}, &lt;No data fields&gt;}, &lt;No data fields&gt;}) at stl_vector.h:371
#3  0x08065506 in Spai::Spai_Algorithm (this=0xbffff610, A=@0xbffff5d0, P=@0xbffff5b0, dimension=4) at stl_alloc.h:242
#4  0x08064b60 in Spai::ttt (this=0x0) at Spai.cpp:259
#5  0x0806adea in Caching (this=0xbffff640) at Caching.cpp:12
#6  0x080507bc in UIMainWindow (this=0xbffff690) at UIMainWindow.cpp:25
#7  0x08050481 in main (argc=1, argv=0x0) at UIMain.cpp:16
</code></pre>
<p>ich habe ein wenig rumgespielt und die methode create_A_hat_test aus verzweiflung so (unvorteilhaft) umgeschrieben..sollte aber dasselbe tun...zumindest verstehe ich den fehler net...:</p>
<pre><code class="language-cpp">std::vector&lt;double&gt;
        Spai::Create_A_Hat_test(const std::vector&lt; double &gt; A,
                                    int&amp; A_hat_dim_x,
                                    int&amp; A_hat_dim_y, 
                                    const std::vector&lt; double &gt; p_col,
                                    std::vector&lt; double &gt; e_k_hat2)
{   
    A_hat_dim_x = 0;
    A_hat_dim_y = p_col.size(); 

    std::vector&lt;double&gt; erg;

    for(int y = 0; y &lt; p_col.size(); y++)
    {   
        if(fabs(p_col[y] - 1.0) &lt;= epsilon)
        {
            for(int i = p_col.size() * y; i &lt; (p_col.size() * (y + 1)); i++)
            {
                if(i &gt;= A.size())
                    continue;
                erg.push_back(A[i]);
            }
            A_hat_dim_x++;
        }
    }
    return erg;
}
</code></pre>
<p>danke für hilfe...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1150876</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1150876</guid><dc:creator><![CDATA[Mati]]></dc:creator><pubDate>Fri, 06 Oct 2006 22:39:45 GMT</pubDate></item><item><title><![CDATA[Reply to unerklärlich -&amp;gt; segfault wegen zu wenig speicher ? on Sat, 07 Oct 2006 12:47:24 GMT]]></title><description><![CDATA[<p>hmm seltsam...wenn ich die methode so schreibe läuft er durch...also wenn ich vorher den vektor komplett in seiner grösse alloziiere und erst im nachheinein füllle....also so gehts:</p>
<pre><code class="language-cpp">std::vector&lt;double&gt;
        Spai::Create_A_Hat_test(const std::vector&lt; double &gt; A,
                                    int&amp; A_hat_dim_x,
                                    int&amp; A_hat_dim_y, 
                                    const std::vector&lt; double &gt; p_col,
                                    std::vector&lt; double &gt; e_k_hat2)
{   
    A_hat_dim_x = 0;
    A_hat_dim_y = p_col.size(); 

    int cnt = 0;
    for(int i = 0; i &lt; p_col.size(); i++)
        if(fabs(p_col[i] - 1.0) &lt;= epsilon)
            cnt++;
    std::vector&lt;double&gt; erg(cnt * p_col.size()); 
//    std::vector&lt;double&gt; erg;

    int j = 0;
    for(int y = 0; y &lt; p_col.size(); y++)
    {
        if(fabs(p_col[y] - 1.0) &lt;= epsilon)
        {
            for(int i = p_col.size() * y; i &lt; (p_col.size() * (y + 1)); i++)
            {
                if(i &gt;= A.size())
                    continue;
                erg.push_back(A[i]);
            }
            A_hat_dim_x++;
        }
    }
    return erg;
}
</code></pre>
<p>aber warum geht das so nicht? Sollte doch klappen wegen dynamischer datenstruktur ???</p>
<pre><code class="language-cpp">std::vector&lt;double&gt;
        Spai::Create_A_Hat_test(const std::vector&lt; double &gt; A,
                                    int&amp; A_hat_dim_x,
                                    int&amp; A_hat_dim_y, 
                                    const std::vector&lt; double &gt; p_col,
                                    std::vector&lt; double &gt; e_k_hat2)
{   
    A_hat_dim_x = 0;
    A_hat_dim_y = p_col.size(); 

//     int cnt = 0;
//     for(int i = 0; i &lt; p_col.size(); i++)
//         if(fabs(p_col[i] - 1.0) &lt;= epsilon)
//             cnt++;
//     std::vector&lt;double&gt; erg(cnt * p_col.size());
   std::vector&lt;double&gt; erg;

    int j = 0;
    for(int y = 0; y &lt; p_col.size(); y++)
    {
        if(fabs(p_col[y] - 1.0) &lt;= epsilon)
        {
            for(int i = p_col.size() * y; i &lt; (p_col.size() * (y + 1)); i++)
            {
                if(i &gt;= A.size())
                    continue;
                erg.push_back(A[i]);
            }
            A_hat_dim_x++;
        }
    }
    return erg;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1150998</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1150998</guid><dc:creator><![CDATA[Mati]]></dc:creator><pubDate>Sat, 07 Oct 2006 12:47:24 GMT</pubDate></item><item><title><![CDATA[Reply to unerklärlich -&amp;gt; segfault wegen zu wenig speicher ? on Sat, 07 Oct 2006 18:48:07 GMT]]></title><description><![CDATA[<p>der fehler scheint merkwürdigerweise in der funktion<br />
Create_e_k() zu liegen....</p>
<p>wenn ich statt dieser methode folgende methode implementiere:</p>
<pre><code class="language-cpp">e_k_hat = Create_e_k_test(col, dimension);

...

std::vector&lt;double&gt;
Class::Create_e_k_test(const int col, 
                                   const int dimension)
{
    std::vector&lt; double &gt; erg(dimension, 0.0);
    erg[col] = 1.0;
    return erg;
}
</code></pre>
<p>also mit rückgabewert vector dann läuft alles prima durch....???<br />
ABER WARUM???</p>
<p>Kann es sein dass das irgendwie nur eine adresse hier überschrieben wird in der funktion und die dann den segfault einleitet oder irgendwas und damit die funktion Create_e_k() gar nicht der fehler ist????</p>
<p>ein backtrace und gdb ergibt folgendes bei der segfault methode:</p>
<pre><code>#0  0x4155b642 in std::__default_alloc_template&lt;true, 0&gt;::allocate () from /usr/lib/libstdc++.so.5
#1  0x08066291 in Spai::Create_e_k (this=0xbffff610, e_k_hat=@0xbffff3f0, col=0, dimension=4) at stl_alloc.h:232
#2  0x08065de5 in Spai::Spai_Algorithm (this=0xbffff610, A=@0xbffff5d0, P=@0xbffff5b0, dimension=4) at Spai.cpp:312
#3  0x08065638 in Spai (this=0xbffff610) at Spai.cpp:246
#4  0x08068f9a in Caching (this=0xbffff640) at Caching.cpp:12
#5  0x080507bc in UIMainWindow (this=0xbffff690) at UIMainWindow.cpp:25
#6  0x08050481 in main (argc=1, argv=0x0) at UIMain.cpp:16
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1151153</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1151153</guid><dc:creator><![CDATA[Mati]]></dc:creator><pubDate>Sat, 07 Oct 2006 18:48:07 GMT</pubDate></item><item><title><![CDATA[Reply to unerklärlich -&amp;gt; segfault wegen zu wenig speicher ? on Sat, 07 Oct 2006 20:52:44 GMT]]></title><description><![CDATA[<p>BUG GEFUNDEN:<br />
es ist soweit diesen *!@% thread zu schließen...peinlich wiedermal aber mir ist jetzt alles wurscht...</p>
<p>auf das sich alle lustig machen...(die frage ist nur wie man 5 tage 100 mal drüberlesen kann)...mal schaun obs jemand wenn ich die stelle hergeb auch findet <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /> bestimmt...</p>
<pre><code class="language-cpp">std::vector&lt; double &gt;  e_k_hat;

for(int col = 0; col &lt; dimension; col++)
{
      ...  

       Create_e_k(e_k_hat, col, dimension);
     ...
}

...

void
Spai::Create_e_k(std::vector&lt; double &gt;&amp; e_k_hat,
                 const int col, 
                 const int dimension)
{
    std::vector&lt;double&gt; res(dimension, 0.0); 
    res[col] = 1.0; 
    e_k_hat.swap(res); 
}
</code></pre>
<p>bitte tötet mich wenn ich jetzt schwachsinn laber aber ich denke da ich e_k_hat ohne dimension definiere und dann eine referenz in der methode übergebe muss er ins leere greifen oder nicht? Das seltsame war nur dass er eigentlich korrekt gearbeitet hat bis er irgendwann einfach in irgendwelchen schleifen stecken blieb....</p>
<p>und so läufts jetzt:</p>
<pre><code class="language-cpp">std::vector&lt; double &gt;  e_k_hat(dimension);
</code></pre>
<p>An dieser stelle danke an alle die sich zeit genommen haben zu posten...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1151217</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1151217</guid><dc:creator><![CDATA[Mati]]></dc:creator><pubDate>Sat, 07 Oct 2006 20:52:44 GMT</pubDate></item><item><title><![CDATA[Reply to unerklärlich -&amp;gt; segfault wegen zu wenig speicher ? on Sun, 08 Oct 2006 00:34:37 GMT]]></title><description><![CDATA[<p>lolz schrieb:</p>
<blockquote>
<p>Es geht eigentlich um das fabs( 4.0 - 0.0 ) &lt; epsilon und nicht um ein 4.0 == 4.0<br />
Das 0.0 in fabs kannst du weglassen nicht den epsilon-test.</p>
</blockquote>
<p>Nochmal zu dem fabs().<br />
Du hast schon recht *i == 4.0 geht nicht. Du musst ein Delta bilden.</p>
<pre><code class="language-cpp">fabs(*i - 4.0) &gt;= delta
</code></pre>
<p>so wirds gemacht. Delta ist dabei 0.000000000000000000001 oder sowas, jenach dem wie genau du es nehmen willst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1151259</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1151259</guid><dc:creator><![CDATA[DEvent]]></dc:creator><pubDate>Sun, 08 Oct 2006 00:34:37 GMT</pubDate></item><item><title><![CDATA[Reply to unerklärlich -&amp;gt; segfault wegen zu wenig speicher ? on Mon, 09 Oct 2006 19:40:18 GMT]]></title><description><![CDATA[<p>Mati schrieb:</p>
<blockquote>
<p>BUG GEFUNDEN:<br />
...</p>
<pre><code class="language-cpp">...std::vector&lt; double &gt;  e_k_hat(dimension);
</code></pre>
<p>...</p>
</blockquote>
<p>irgendwie kommt mir das Thema (und der Variablenname) so bekannt vor.... aufch die Erklärung, &quot;e_k_hat ist immer groß genug&quot;.<br />
Gab's da nicht mal einen Thread (finde gerade nichts Derartiges), in dem Du gesagt hast, auch mit Größenüberprüfung von e_k_hat träte der Fehler auf.<br />
Was mich mal interessiert: Hast Du wirklich gegen e_k_hat.size() oder e_k_hat.end() getestet ?</p>
<p>Eigentlich hätte der Dir das richtige liefern sollen.</p>
<p>Ich bin mir bei der ganzen &quot;Vorfüllungstrickserei&quot; nie wirklich sicher , ob das so klappt, wie ich mir das denke - deswegen erlaube ich mir (gerade bei vektoren, die nur einmal geschrieben werden) immer den Luxus, sie per push_back() zu füllen.<br />
&quot;Da weiß man, was man hat, guten Abend&quot; <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /><br />
Wäre vllt. auch was für Dich... ?!?</p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1151803</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1151803</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Mon, 09 Oct 2006 19:40:18 GMT</pubDate></item></channel></rss>