This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: malloc(0) during exception throw & catch
> > And all memory races detection tools says that there is call of
> > malloc(0) inside it.
>
> Thanks for your bug report. You did not mention what platform you are
> using, so it is hard to reproduce the problem. I could not reproduce
> it on i586-pc-linux-gnu, with gcc 2.95.2.
gcc-2.95.2. i686-linux. 2.2.15.
Exception SHOULD be derived from exception.
#include <stdio.h>
#include <exception>
class ex : public exception {
public:
ex() : exception() {};
};
int main() {
try {
throw ex();
} catch (ex &x) {
fprintf(stderr, "ex catched\n");
}
return 0;
}
Compile it with -g option (this is obligatory. Somehow without debug info all is OK).
And use for example YAMD (http://www3.hmc.edu/~neldredge/yamd/)
run-yamd -l 2 -o a ./ex
And you will get:
YAMD version 0.32
Starting run: ./ex
Executable: /home/dyp/tmp/throw/ex
Virtual program size is 1472 K
Time is Sun May 28 06:10:27 2000
default_alignment = 1
min_log_level = 2
repair_corrupted = 0
die_on_corrupted = 1
check_front = 0
WARNING: Zero-byte allocation
Address 0x2ac23000, size 0
Allocated by malloc at
/lib/libc.so.6(malloc+0x2e)[0x2ab88ede]
/usr/lib/libstdc++-libc6.1-2.so.3(_._13bad_exception+0x46e)[0x2ab04b92]
/usr/lib/libstdc++-libc6.1-2.so.3(_._13bad_exception+0x574)[0x2ab04c98]
/usr/lib/libstdc++-libc6.1-2.so.3(__frame_state_for+0x23)[0x2ab05497]
/usr/lib/libstdc++-libc6.1-2.so.3(__throw+0x67)[0x2ab03bef]
/home/dyp/tmp/throw/ex.cpp:12(main)[0x8048943]
/lib/libc.so.6(__libc_start_main+0x115)[0x2ab4fd69]
??:0(_start)[0x8048811]
WARNING: Zero-byte allocation
Address 0x2ac25000, size 0
Allocated by malloc at
/lib/libc.so.6(malloc+0x2e)[0x2ab88ede]
/usr/lib/libstdc++-libc6.1-2.so.3(_._13bad_exception+0x47a)[0x2ab04b9e]
/usr/lib/libstdc++-libc6.1-2.so.3(_._13bad_exception+0x574)[0x2ab04c98]
/usr/lib/libstdc++-libc6.1-2.so.3(__frame_state_for+0x23)[0x2ab05497]
/usr/lib/libstdc++-libc6.1-2.so.3(__throw+0x67)[0x2ab03bef]
/home/dyp/tmp/throw/ex.cpp:12(main)[0x8048943]
/lib/libc.so.6(__libc_start_main+0x115)[0x2ab4fd69]
??:0(_start)[0x8048811]
*** Finished at Sun May 28 06:10:27 2000
Allocated a grand total of 9104 bytes
8 allocations
Average of 1138 bytes per allocation
Max bytes allocated at one time: 9080
96 K alloced internally / 64 K mapped now / 36 K max
Virtual program size is 1588 K
End.
--
Sincerely Yours,
Denis Perchine
----------------------------------
E-Mail: dyp@perchine.com
HomePage: http://www.perchine.com/dyp/
FidoNet: 2:5000/120.5
----------------------------------