Note that there are some explanatory texts on larger screens.

plurals
  1. POStrange backtrace - where is the error?
    primarykey
    data
    text
    <p>I'm developing an image processing application in C++. I've seen a lot of compiler errors and backtraces, but this one is new to me. </p> <pre><code>#0 0xb80c5430 in __kernel_vsyscall () #1 0xb7d1b6d0 in raise () from /lib/tls/i686/cmov/libc.so.6 #2 0xb7d1d098 in abort () from /lib/tls/i686/cmov/libc.so.6 #3 0xb7d5924d in ?? () from /lib/tls/i686/cmov/libc.so.6 #4 0xb7d62276 in ?? () from /lib/tls/i686/cmov/libc.so.6 #5 0xb7d639c5 in malloc () from /lib/tls/i686/cmov/libc.so.6 #6 0xb7f42f47 in operator new () from /usr/lib/libstdc++.so.6 #7 0x0805bd20 in Image&lt;Color&gt;::fft (this=0xb467640) at ../image_processing/image.cpp:545 </code></pre> <p>What's happening here? The operator new is crashing, ok. But why? That's not an out of memory (it tries to allocate about 128Kb, a 128x64 pixel with two floats each). Also, it doesn't seam as it's an error in my own code (the constructor doesn't get touched!). </p> <p>The code in the mentioned line (#7) is:</p> <pre><code>Image&lt;Complex&gt; *result = new Image&lt;Complex&gt;(this-&gt;resX, resY); // this-&gt;resX = 128, resY = 64 (both int), Complex is a typedef for std::complex&lt;float&gt; </code></pre> <p>Almost the same instantiation works on other places in my code. If I comment out this part of the code, it will crash a bit later on a similar part. I don't understand it, I also don't have any ideas, how to debug it. Any help?</p> <p>Compiler is gcc 4.3.3, libc is 2.9 (both from Ubuntu Jaunty) </p> <p><strong>Update:</strong></p> <p>I've included the following lines just above the faulty line in the same method and in main()</p> <pre><code> Image&lt;Complex&gt; *test = new Image&lt;Complex&gt;(128, 64); delete test; </code></pre> <p>The strange thing: in the same method it will crash, in main() it won't. As I mentioned, Complex is a typedef of std::complex&lt;float&gt;. The constructor doesn't get called, I've inserted a cout just before this line and in the constructor itself.</p> <p><strong>Update 2:</strong></p> <p>Thanks to KPexEA for this tip! I tried this:</p> <pre><code>Image&lt;Complex&gt; *test = new Image&lt;Complex&gt;(128, 64); delete test; kiss_fft_cpx *output = (kiss_fft_cpx*) malloc( this-&gt;resX * this-&gt;resY/2 * sizeof(kiss_fft_cpx) ); kiss_fftndr( cfg, input, output ); Image&lt;Complex&gt; *test2 = new Image&lt;Complex&gt;(128, 64); delete test2; </code></pre> <p>It crashes at - you guess? - test2! So the malloc for my kissfft seams to be the faulty one. I'll take a look at it.</p> <p><strong>Final update:</strong></p> <p>Ok, it's done! Thanks to all of you! </p> <p>Actually, I should have noticed it before. Last week, I noticed, that kissfft (a fast fourier transform library) made a 130x64 pixel fft image from a 128x128 pixel source image. Yes, 130 pixel broad, not 128. Don't ask me why, I don't know! So, 130x64x2xsizeof(float) bytes had to be allocated, not 128x64x... as I thought before. Strange, that it didn't crash just after I fixed that bug, but some days later. </p> <p>For the record, my final code is:</p> <pre><code>int resY = (int) ceil(this-&gt;resY/2); kiss_fft_cpx *output = (kiss_fft_cpx*) malloc( (this-&gt;resX+2) * resY * sizeof(kiss_fft_cpx) ); kiss_fftndr( cfg, input, output ); Image&lt;Complex&gt; *result = new Image&lt;Complex&gt;(this-&gt;resX, resY); </code></pre> <p>Thanks!</p> <p>craesh</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload