gdb outputs std error - c++

gdb is giving me the following
Program received signal SIGABRT, Aborted.
0x000001efa0f31eea in kill () at <stdin>:2
2 <stdin>: No such file or directory.
in <stdin>
(gdb) where
#0 0x000001efa0f31eea in kill () at <stdin>:2
#1 0x000001efa0f986ca in abort () at /usr/src/lib/libc/stdlib/abort.c:70
#2 0x000001efa8473e71 in __gnu_cxx::__verbose_terminate_handler () at /usr/obj/gcc-4.7.2/gcc-4.7.2/libstdc++-v3/libsupc++/vterminate.cc:50
#3 0x000001efa8471ba8 in __cxxabiv1::__terminate (handler=Unhandled dwarf expression opcode 0xf3
) at /usr/obj/gcc-4.7.2/gcc-4.7.2/libstdc++-v3/libsupc++/eh_terminate.cc:40
#4 0x000001efa8471bf3 in std::terminate () at /usr/obj/gcc-4.7.2/gcc-4.7.2/libstdc++-v3/libsupc++/eh_terminate.cc:50
Die: DW_TAG_unspecified_type (abbrev = 23, offset = 133635)
has children: FALSE
attributes:
DW_AT_name (DW_FORM_strp) string: "decltype(nullptr)"
Dwarf Error: Cannot find type of die [in module /usr/local/lib/libestdc++.so.15.0]
I am working on openbsd 5.3 has anyone come across this issue?
#include <iostream>
int main (void) {
try {
throw 10;
}catch (...) {
std::cout<<"thrown"<<std::endl;
}
return 0;
}
This is enough to cause the problem

Related

How to get original stack trace for unhandled exception in C++?

This question has been asked before but the solutions proposed there do not work for me. The issue is when an unhandled exception occurs and std::terminate is invoked the original stack trace where the exception is thrown is gone. How can we get that?
Here is a simple test app where child thread throw an exception and std:: terminated is called. The core file does not show the original stack trace.
I tried below, none of them works --
i) std::set_terminate(myhandler) -- myhandler is called as expected but this does not affect stack unwinding.
ii) compile with -fno-exceptions -- no effect, likely because the exception is thrown from std library.
Any suggestions will be greatly appreciated!
$ cat thread.cpp
#include <utility>
#include <thread>
#include <chrono>
#include <cstdlib>
#include <iostream>
#include <vector>
void f1()
{
for (int i = 0; i < 10; ++i) {
std::cout << "Thread 1 executing\n";
std::this_thread::sleep_for(std::chrono::milliseconds(10));
// !!! create an exception, how to get the stack trace here.
std::vector<int> vec;
vec.reserve(-1);
}
}
int main()
{
std::thread t1(f1);
t1.join();
std::cout << "Done " << '\n';
}
$ g++ -g thread.cpp -pthread
$ ./a.out
Thread 1 executing
terminate called after throwing an instance of 'std::length_error'
what(): vector::reserve
Aborted (core dumped)
$gdb a.out core
...
Core was generated by `./a.out'.
Program terminated with signal SIGABRT, Aborted.
#0 0x00007f7e13084277 in __GI_raise (sig=sig#entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
[Current thread is 1 (Thread 0x7f7e1304d700 (LWP 106036))]
Missing separate debuginfos, use: debuginfo-install libgcc-4.8.5-28.el7_5.1.x86_64 libstdc++-4.8.5-28.el7_5.1.x86_64
(gdb) thread apply all bt
Thread 2 (Thread 0x7f7e14054740 (LWP 106035)):
#0 0x00007f7e13423f97 in pthread_join (threadid=140179461691136, thread_return=0x0) at pthread_join.c:92
#1 0x00007f7e13c03e37 in std::thread::join() () from /lib64/libstdc++.so.6
#2 0x0000000000400f8f in main () at thread.cpp:22
Thread 1 (Thread 0x7f7e1304d700 (LWP 106036)):
#0 0x00007f7e13084277 in __GI_raise (sig=sig#entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 0x00007f7e13085968 in __GI_abort () at abort.c:90
#2 0x00007f7e13baf7d5 in __gnu_cxx::__verbose_terminate_handler() () from /lib64/libstdc++.so.6
#3 0x00007f7e13bad746 in ?? () from /lib64/libstdc++.so.6
#4 0x00007f7e13bad773 in std::terminate() () from /lib64/libstdc++.so.6
#5 0x00000000004023de in execute_native_thread_routine ()
#6 0x00007f7e13422e25 in start_thread (arg=0x7f7e1304d700) at pthread_create.c:308
#7 0x00007f7e1314cbad in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

C++ different threads have the same thread ID on FreeBSD 10

I am using a C++ logging library on a FreeBSD 10 machine and I am running into trouble closing threads when receiving a sigint.
A created a GitHub project for testing purposes (link). If you build it on FreeBSD 10, execute it and press [ctrl+c] it will terminate. You can find the build commands I use below.
$ git clone git#github.com:tijme/free-bsd-thread-bug.git
$ cd free-bsd-thread-bug && mkdir -p cmake-build-debug && cd cmake-build-debug
$ cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER="/usr/local/bin/gcc6" -DCMAKE_CXX_COMPILER="/usr/local/bin/g++6"
$ make -dA
$ ./FreeBSDThreadBug
Code I used (can also be found in the GitHub repository)
/* main.cpp */
#include "Example.h"
#include <iostream>
#include <csignal>
#include <thread>
#include <chrono>
Example* example = new Example();
void onSignal(int signum)
{
delete example;
exit(0);
}
int main() {
signal(SIGINT, onSignal);
std::this_thread::sleep_for(std::chrono::milliseconds(5000));
return 0;
}
/* Example.h */
#ifndef FREEBSDTHREADBUG_EXAMPLE_H
#define FREEBSDTHREADBUG_EXAMPLE_H
#include <thread>
#include <iostream>
#include <chrono>
class Example {
public:
Example();
~Example();
std::thread threadHandle;
void threadFunction();
};
#endif //FREEBSDTHREADBUG_EXAMPLE_H
/* Example.cpp */
#include "Example.h"
#include <thread>
#include <chrono>
Example::Example()
{
std::cout << "Main: starting thread" << std::endl;
threadHandle = std::thread(&Example::threadFunction, this);
std::cout << "Main: thread started" << std::endl;
}
Example::~Example()
{
std::cout << "THIS ID: " << std::this_thread::get_id() << std::endl;
std::cout << "THREAD ID: " << threadHandle.get_id() << std::endl;
std::cout << "Main: joining thread" << std::endl;
threadHandle.join();
std::cout << "Main: thread joined" << std::endl;
}
void Example::threadFunction() {
std::cout << "Thread: starting to sleep" << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(2500));
std::cout << "Thread: sleep finished" << std::endl;
}
Correct output (on e.g. MacOS Sierra):
As you can see the ID's of the threads are different, as expected.
$ ./FreeBSDThreadBug
Main: starting thread
Main: thread started
Thread: starting to sleep
^C
THIS ID: 0x7fffa428a3c0
THREAD ID: 0x70000c044000
Main: joining thread
Thread: sleep finished
Main: thread joined
Wrong output (termination, on FreeBSD 10.3):
The thread ID's are the same here, which is pretty weird.
$ ./FreeBSDThreadBug
Main: starting thread
Main: thread started
Thread: starting to sleep
^C
THIS ID: 0x801c06800
THREAD ID: 0x801c06800
Main: joining thread
terminate called after throwing an instance of 'std::system_error'
what(): Resource deadlock avoided
Abort (core dumped)
Core dump
Core was generated by `FreeBSDThreadBug'.
Program terminated with signal SIGABRT, Aborted.
#0 0x00000008012d335a in thr_kill () from /lib/libc.so.7
[Current thread is 1 (LWP 100146)]
(gdb) bt full
#0 0x00000008012d335a in thr_kill () from /lib/libc.so.7
No symbol table info available.
#1 0x00000008012d3346 in raise () from /lib/libc.so.7
No symbol table info available.
#2 0x00000008012d32c9 in abort () from /lib/libc.so.7
No symbol table info available.
#3 0x0000000800ad8afd in __gnu_cxx::__verbose_terminate_handler () at /wrkdirs/usr/ports/lang/gcc6/work/gcc-6.3.0/libstdc++-v3/libsupc++/vterminate.cc:95
terminating = true
t = <optimized out>
#4 0x0000000800ad5b48 in __cxxabiv1::__terminate (handler=<optimized out>) at /wrkdirs/usr/ports/lang/gcc6/work/gcc-6.3.0/libstdc++-v3/libsupc++/eh_terminate.cc:47
No locals.
#5 0x0000000800ad5bb1 in std::terminate () at /wrkdirs/usr/ports/lang/gcc6/work/gcc-6.3.0/libstdc++-v3/libsupc++/eh_terminate.cc:57
No locals.
#6 0x0000000800ad5dc8 in __cxxabiv1::__cxa_throw (obj=obj#entry=0x80200e0a0, tinfo=0x800dd0bc0 <typeinfo for std::system_error>, dest=0x800b073b0 <std::system_error::~system_error()>)
at /wrkdirs/usr/ports/lang/gcc6/work/gcc-6.3.0/libstdc++-v3/libsupc++/eh_throw.cc:87
globals = <optimized out>
#7 0x0000000800b04cd1 in std::__throw_system_error (__i=11) at /wrkdirs/usr/ports/lang/gcc6/work/gcc-6.3.0/libstdc++-v3/src/c++11/functexcept.cc:130
No locals.
#8 0x0000000800b0792c in std::thread::join (this=0x801c5c058) at /wrkdirs/usr/ports/lang/gcc6/work/gcc-6.3.0/libstdc++-v3/src/c++11/thread.cc:139
__e = <optimized out>
#9 0x00000000004016fc in Example::~Example (this=0x801c5c058, __in_chrg=<optimized out>) at /root/FreeBSDThreadBug/Example.cpp:18
No locals.
#10 0x00000000004010b7 in onSignal (signum=2) at /root/FreeBSDThreadBug/main.cpp:11
No locals.
#11 0x000000080082fb4a in ?? () from /lib/libthr.so.3
No symbol table info available.
#12 0x000000080082f22c in ?? () from /lib/libthr.so.3
No symbol table info available.
#13 <signal handler called>
No symbol table info available.
#14 0x00000008012efb5a in _nanosleep () from /lib/libc.so.7
No symbol table info available.
#15 0x000000080082cc4c in ?? () from /lib/libthr.so.3
No symbol table info available.
#16 0x000000000040155d in std::this_thread::sleep_for<long, std::ratio<1l, 1000l> > (__rtime=...) at /usr/local/lib/gcc6/include/c++/thread:322
__s = {__r = 2}
__ns = {__r = 500000000}
__ts = {tv_sec = 1, tv_nsec = 126917539}
#17 0x000000000040177a in Example::threadFunction (this=0x801c5c058) at /root/FreeBSDThreadBug/Example.cpp:24
No locals.
#18 0x0000000000402432 in std::__invoke_impl<void, void (Example::* const&)(), Example*>(std::__invoke_memfun_deref, void (Example::* const&)(), Example*&&) (
__f=#0x801c5e050: (void (Example::*)(Example * const)) 0x40172c <Example::threadFunction()>, __t=<unknown type in /root/FreeBSDThreadBug/cmake-build-debug/FreeBSDThreadBug, CU 0x552f, DIE 0xb2d7>)
at /usr/local/lib/gcc6/include/c++/functional:227
No locals.
#19 0x00000000004023bf in std::__invoke<void (Example::* const&)(), Example*>(void (Example::* const&)(), Example*&&) (__fn=#0x801c5e050: (void (Example::*)(Example * const)) 0x40172c <Example::threadFunction()>,
__args#0=<unknown type in /root/FreeBSDThreadBug/cmake-build-debug/FreeBSDThreadBug, CU 0x552f, DIE 0xb2d7>) at /usr/local/lib/gcc6/include/c++/functional:251
No locals.
#20 0x0000000000402370 in std::_Mem_fn_base<void (Example::*)(), true>::operator()<Example*>(Example*&&) const (this=0x801c5e050,
__args#0=<unknown type in /root/FreeBSDThreadBug/cmake-build-debug/FreeBSDThreadBug, CU 0x552f, DIE 0xb2d7>) at /usr/local/lib/gcc6/include/c++/functional:604
No locals.
#21 0x000000000040233b in std::_Bind_simple<std::_Mem_fn<void (Example::*)()> (Example*)>::_M_invoke<0ul>(std::_Index_tuple<0ul>) (this=0x801c5e048) at /usr/local/lib/gcc6/include/c++/functional:1391
No locals.
#22 0x0000000000402289 in std::_Bind_simple<std::_Mem_fn<void (Example::*)()> (Example*)>::operator()() (this=0x801c5e048) at /usr/local/lib/gcc6/include/c++/functional:1380
No locals.
#23 0x0000000000402268 in std::thread::_State_impl<std::_Bind_simple<std::_Mem_fn<void (Example::*)()> (Example*)> >::_M_run() (this=0x801c5e040) at /usr/local/lib/gcc6/include/c++/thread:196
No locals.
#24 0x0000000800b0769f in std::execute_native_thread_routine (__p=0x801c5e040) at /wrkdirs/usr/ports/lang/gcc6/work/gcc-6.3.0/libstdc++-v3/src/c++11/thread.cc:83
__t = std::unique_ptr<std::thread::_State> containing 0x801c5e040
#25 0x000000080082a855 in ?? () from /lib/libthr.so.3
No symbol table info available.
#26 0x0000000000000000 in ?? ()
No symbol table info available.
Backtrace stopped: Cannot access memory at address 0x7fffdfffe000
System information
$ freebsd-version
10.3-RELEASE
$ /usr/local/bin/gcc6 --version
gcc6 (FreeBSD Ports Collection) 6.3.0
$ /usr/local/bin/g++6 --version
g++6 (FreeBSD Ports Collection) 6.3.0
$ cmake --version
cmake version 3.7.2
The original issue I created can be found on GitHub (link), however there is no fix yet.
I hope someone will be able to help me fix this issue. Thanks in advance.
That's not a bug, that's a feature.
You don't get a guarantee about where your signal is going to be delivered, and the set of things you're allowed to do in a signal handler is restricted.
See sigaction(3) for details about what you can do (and you can't do anything else). Your program is doing many things that are not allowed in a signal handler.
The correct thing to do is to signal something else in your program and return from the signal handler. An example technique for doing that is the "self pipe trick". Create a pipe and keep a handle to both ends. Read from one end in your normal I/O processing. If you get a signal, in the signal handler, write a byte to the other end of the pipe and return. When the byte is read from the pipe you know the signal has arrived and you can do extended processing safely.
Update:
As Michael Burr has pointed out, you can block particular threads from receiving particular signals using pthread_sigmask(3). However, to fix the underlying problem here you still need to not do the work in the signal handler.

Why mingw+gdb cannot show backtrace correctly from inside a sigsegv handler?

I'm debugging a process that runs really slow when is executed from gdb on Windows (mingw32), so I decided to run it until it crash without gdb, and then to attach the debugger. I've installed a signal handler for sigsegv that shows its pid and waits, so when I see the message I load gdb and use the "attach" command with that pid. The problem is that gdb shows me an useless backtrace at that point. Here's an example:
void my_sigsegv_handler(int) {
std::cerr << "Segmentation fault! pid=" << GetCurrentProcessId();
std::cin.get(); // wait for gdb
}
int main() {
signal(SIGSEGV,my_sigsegv_handler);
int *p = 0;
std::cout << *p; // boom!
}
Compiled with "mingw32-g++ -g -O0", output from gdb's command "bt" (after selecting the proper thread) is:
#0 0x764e73ea in ?? ()
#1 0x7646f489 in ?? ()
#2 0x75edc3b3 in ?? ()
#3 0x75edc2bc in ?? ()
#4 0x75edc472 in ?? ()
#5 0x00415502 in __gnu_cxx::stdio_sync_filebuf<char, std::char_traits<char> >::uflow() ()
#6 0x00434f32 in std::istream::get() ()
#7 0x004016d5 in my_sigsegv_handler () at C:\Users\usuario\zinjai\sin_titulo.cpp:8
#8 0x004010f9 in _gnu_exception_handler (exception_data=0x28fa88) at ../mingwrt-4.0.3-1-mingw32-src/src/libcrt/crt/crt1.c:137
#9 0x76469d57 in ?? ()
#10 0x77100727 in ?? ()
#11 0x770c9d45 in ?? ()
#12 0x00000000 in ?? ()
Notice that this example does not corrupt stack when generating the segfault. Actualy, I can debug it anyway, just continuing execution. If I press enter the signal handler finishes, returns to the place where it was generated (main function), and the problem is not solved, but this time gdb is there to catch it. But I'd like to now how does it really works.
If I use the same method in gnu/linux I can see what I want to see here:
#5 0x00007f6809bf349e in std::istream::get() () from /usr/lib64/libstdc++.so.6
#6 0x00000000004008cd in my_signal_handler () at /home/zaskar/.zinjai/sin_titulo.cpp:6
#7 <signal handler called>
#8 0x00000000004008f9 in main (argc=1, argv=0x7fffa0613108) at /home/zaskar/.zinjai/sin_titulo.cpp:11
So the question is, why gdb cannot show me the correct backtrace from withing the signal handler? Or what am I doing wrong? Is there any better way to solve it?

Thread name not shown in info thread command when using gdb 7.7

In some of the answers to related questions I could see that gdb 7.3 should support displaying thread names atleast with 'info threads' command .
But I am not even getting that luxury. please help me to understand what I am doing wrong.
My sample code used for testing:
#include <stdio.h>
#include <pthread.h>
#include <sys/prctl.h>
static pthread_t ta, tb;
void *
fx (void *param)
{
int i = 0;
prctl (PR_SET_NAME, "Mythread1", 0, 0, 0);
while (i < 1000)
{
i++;
printf ("T1%d ", i);
}
}
void *
fy (void *param)
{
int i = 0;
prctl (PR_SET_NAME, "Mythread2", 0, 0, 0);
while (i < 100)
{
i++;
printf ("T2%d ", i);
}
sleep (10);
/* generating segmentation fault */
int *p;
p = NULL;
printf ("%d\n", *p);
}
int
main ()
{
pthread_create (&ta, NULL, fx, 0);
pthread_create (&tb, NULL, fy, 0);
void *retval;
pthread_join (ta, &retval);
pthread_join (tb, &retval);
return 0;
}
Output( using core dump generated by segmentation fault)
(gdb) core-file core.14001
[New LWP 14003]
[New LWP 14001]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
Core was generated by `./thread_Ex'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x08048614 in fy (param=0x0) at thread_Ex.c:30
30 printf("%d\n",*p);
(gdb) info threads
Id Target Id Frame
2 Thread 0xb77d76c0 (LWP 14001) 0x00b95424 in __kernel_vsyscall ()
* 1 Thread 0xb6dd5b70 (LWP 14003) 0x08048614 in fy (param=0x0) at thread_Ex.c:30
(gdb) bt
#0 0x08048614 in fy (param=0x0) at thread_Ex.c:30
#1 0x006919e9 in start_thread () from /lib/libpthread.so.0
#2 0x005d3f3e in clone () from /lib/libc.so.6
(gdb) thread apply all bt
Thread 2 (Thread 0xb77d76c0 (LWP 14001)):
#0 0x00b95424 in __kernel_vsyscall ()
#1 0x006920ad in pthread_join () from /lib/libpthread.so.0
#2 0x080486a4 in main () at thread_Ex.c:50
Thread 1 (Thread 0xb6dd5b70 (LWP 14003)):
#0 0x08048614 in fy (param=0x0) at thread_Ex.c:30
#1 0x006919e9 in start_thread () from /lib/libpthread.so.0
#2 0x005d3f3e in clone () from /lib/libc.so.6
(gdb) q
As you can see I cant see any thread names that I have set. what could be wrong?
Note:
I am using gdb version 7.7 (Downloaded and compiled using no special options)
commands used to compile & install gdb : ./configure && make && make install
As far as I am aware, thread names are not present in the core dump.
If they are available somehow, please file a gdb bug.
I get thread name displayed on CentOS6.5, but not displayed on CentOS6.4 .

DevIL segfault, issues with png's, bmp's

I am on mingw (gcc version 4.5.2).
I get a segfault when opening certain files, including PNGs and BMPs. It was working fine on a 128x128 PNG but when I started testing with larger files I started getting a segfault. There are no issues with the TGA format, though. I know the library works for the most part, but not knowing whether it will decide to crash and burn like this is not good.
gdb does not give me any hints about what's going on. I am able to compile DevIL from source, and I compiled a debug dll (--enable-debug for configure script) but it doesn't seem to support png (seems like I need to get a png12 library) but it doesn't get me very far.
I am trying to open a ~2MB BMP I made in GIMP. I run it through GDB and it sometimes will segfault but other times it warns of some stuff happening on the heap (lots of stuff i've never seen before). Here's a gdb run dump. All of the lines beginning with %%% are the output that is specific to my program, the rest comes from gdb.
$ gdb ./entropy_unittest_disp.exe loadpngdisplay
GNU gdb (GDB) 7.2
Copyright (C) 2010 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 "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from c:\Users\Steven\Dropbox\Programming\entropy_p5_makefile\cpp
\game/./entropy_unittest_disp.exe...done.
c:\Users\Steven\Dropbox\Programming\entropy_p5_makefile\cpp\game/loadpngdisplay:
No such file or directory.
(gdb) r
Starting program: c:\Users\Steven\Dropbox\Programming\entropy_p5_makefile\cpp\ga
me/./entropy_unittest_disp.exe
[New Thread 23284.0x5bb4]
%%%UNIT TEST BUILD: INTERNAL USE ONLY. DO NOT DISTRIBUTE
%%%Compiled on Sep 11 2011 at 09:45:38
%%%argc = 1: Main.cpp:119
%%%argv:
%%%0: c:\Users\Steven\Dropbox\Programming\entropy_p5_makefile\cpp\game/./entropy_un
%%%ittest_disp.exe
%%%←[36mStarting Test ilWritePng, at Image.cpp:8←[0m
%%%rm: cannot lstat `output_il.png': No such file or directory
%%%ilGetError() = 1292: Image.cpp:25
%%%Completed Test ilWritePng in 0.033 seconds
%%%←[36mStarting Test loadPNGDisplay, at Image.cpp:31←[0m
[New Thread 23284.0x445c]
[New Thread 23284.0x1fd8]
[New Thread 23284.0x1424]
%%%Number of Joysticks detected: 2
%%%Opening Joystick: Harmonix Guitar for Xbox 360 (Controller)
[New Thread 23284.0x526c]
[New Thread 23284.0x5a70]
[New Thread 23284.0x1ae8]
[New Thread 23284.0x5908]
[New Thread 23284.0x5974]
%%%Using GLEW 1.5.8
%%%OpenGL Vendor: NVIDIA Corporation
%%%OpenGL Renderer: GeForce GTX 260/PCI/SSE2
%%%OpenGL Version: 3.3.0
warning: HEAP[entropy_unittest_disp.exe]:
warning: Invalid address specified to RtlFreeHeap( 00350000, 04000000 )
Program received signal SIGTRAP, Trace/breakpoint trap.
0x772e0475 in ntdll!TpWaitForAlpcCompletion ()
from C:\Windows\system32\ntdll.dll
(gdb) where
#0 0x772e0475 in ntdll!TpWaitForAlpcCompletion ()
from C:\Windows\system32\ntdll.dll
#1 0x0028f510 in ?? ()
#2 0x772a29c0 in ntdll!RtlCopyExtendedContext ()
from C:\Windows\system32\ntdll.dll
#3 0x03fffff8 in ?? ()
#4 0x772e14cf in ntdll!TpQueryPoolStackInformation ()
from C:\Windows\system32\ntdll.dll
#5 0x00350000 in ?? ()
#6 0x7729ab3a in ntdll!AlpcMaxAllowedMessageLength ()
from C:\Windows\system32\ntdll.dll
#7 0x00350000 in ?? ()
#8 0x77243472 in ntdll!RtlLargeIntegerShiftRight ()
from C:\Windows\system32\ntdll.dll
#9 0x03fffff8 in ?? ()
#10 0x766398cd in msvcrt!free () from C:\Windows\syswow64\msvcrt.dll
#11 0x00350000 in ?? ()
#12 0x6180129c in _mm_free (aligned_ptr=0x8230020)
at c:/mingw/bin/../lib/gcc/mingw32/4.5.2/include/mm_malloc.h:71
#13 0x61801370 in DefaultFreeFunc (ptr=0x8230020)
at ./../src-IL/src/il_alloc.c:127
#14 0x618012ee in ifree (Ptr=0x8230020) at ./../src-IL/src/il_alloc.c:99
#15 0x618149f8 in iPreCache (Size=592128) at ./../src-IL/src/il_files.c:550
#16 0x618148a2 in iReadFile (Buffer=0x8100017, Size=1, Number=2313)
at ./../src-IL/src/il_files.c:499
#17 0x61808cf5 in ilReadUncompBmp (Header=0x28f829)
at ./../src-IL/src/il_bmp.c:486
#18 0x61808410 in iLoadBitmapInternal () at ./../src-IL/src/il_bmp.c:250
#19 0x618082f3 in ilLoadBmpF (File=0x766d2960) at ./../src-IL/src/il_bmp.c:199
#20 0x618082ba in ilLoadBmp (FileName=0x4c25f1 "folder.bmp")
at ./../src-IL/src/il_bmp.c:184
#21 0x61830bf0 in ilLoadImage (FileName=0x4c25f1 "folder.bmp")
at ./../src-IL/src/il_io.c:1827
#22 0x0040f66c in SDLSystemloadPNGDisplayHelper::RunImpl (this=0x28fc10)
at Image.cpp:40
#23 0x00461e74 in UnitTest::ExecuteTest<SDLSystemloadPNGDisplayHelper> (
testObject=..., details=...) at ../include/UnitTest++/ExecuteTest.h:25
#24 0x0040f2cd in TestSDLSystemloadPNGDisplay::RunImpl (this=0x4e5cf8)
at Image.cpp:31
#25 0x00463023 in UnitTest::ExecuteTest<UnitTest::Test> (testObject=...,
details=...) at src/ExecuteTest.h:25
#26 0x0044198d in UnitTest::Test::Run (this=0x4e5cf8) at src/Test.cpp:34
#27 0x00441d9a in UnitTest::TestRunner::RunTest (this=0x28fedc,
result=0x3517f0, curTest=0x4e5cf8, maxTestTimeInMs=0)
at src/TestRunner.cpp:61
#28 0x00466b7e in UnitTest::TestRunner::RunTestsIf<UnitTest::True> (
this=0x28fedc, list=..., suiteName=0x0, predicate=..., maxTestTimeInMs=0)
at ../include/UnitTest++/TestRunner.h:40
#29 0x004014e3 in UnitTest::RunAllTestsVerbose () at Main.cpp:72
#30 0x0040167d in main (argc=1, argv=0x3531d8) at Main.cpp:126
(gdb) c
Continuing.
warning: HEAP[entropy_unittest_disp.exe]:
warning: Invalid address specified to RtlFreeHeap( 00350000, 04000000 )
Program received signal SIGTRAP, Trace/breakpoint trap.
0x772e0475 in ntdll!TpWaitForAlpcCompletion ()
from C:\Windows\system32\ntdll.dll
(gdb) c
Continuing.
warning: HEAP[entropy_unittest_disp.exe]:
warning: Invalid address specified to RtlFreeHeap( 00350000, 04000000 )
Program received signal SIGTRAP, Trace/breakpoint trap.
0x772e0475 in ntdll!TpWaitForAlpcCompletion ()
from C:\Windows\system32\ntdll.dll
(gdb)
Continuing.
warning: HEAP[entropy_unittest_disp.exe]:
warning: Invalid address specified to RtlFreeHeap( 00350000, 04000000 )
Program received signal SIGTRAP, Trace/breakpoint trap.
0x772e0475 in ntdll!TpWaitForAlpcCompletion ()
from C:\Windows\system32\ntdll.dll
(gdb)
Continuing.
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 23284.0x5974]
0x05064225 in nvoglv32!DrvGetProcAddress ()
from C:\Windows\SysWOW64\nvoglv32.dll
(gdb)
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x05064225 in nvoglv32!DrvGetProcAddress ()
from C:\Windows\SysWOW64\nvoglv32.dll
(gdb)
Continuing.
Program exited with code 030000000005.
(gdb)
The program is not being run.
(gdb) r
Starting program: c:\Users\Steven\Dropbox\Programming\entropy_p5_makefile\cpp\ga
me/./entropy_unittest_disp.exe
[New Thread 23428.0x49b8]
%%%UNIT TEST BUILD: INTERNAL USE ONLY. DO NOT DISTRIBUTE
%%%Compiled on Sep 11 2011 at 09:45:38
%%%argc = 1: Main.cpp:119
%%%argv:
%%%0: c:\Users\Steven\Dropbox\Programming\entropy_p5_makefile\cpp\game/./entropy_un
%%%ittest_disp.exe
%%%←[36mStarting Test ilWritePng, at Image.cpp:8←[0m
Program received signal SIGSEGV, Segmentation fault.
0x7723dfc4 in ntdll!LdrWx86FormatVirtualImage ()
from C:\Windows\system32\ntdll.dll
(gdb) where
#0 0x7723dfc4 in ntdll!LdrWx86FormatVirtualImage ()
from C:\Windows\system32\ntdll.dll
#1 0x1f002150 in ?? ()
#2 0x00000000 in ?? ()
(gdb)
the test ilWritePng is actually just having it write a .tga image file. That test works fine with the release dll (md5 = 59E291838AE2C88F5F71108E4845A84B) but this debug build I compiled has more issues.
I was so happy when I skimmed the doc and got DevIL up and running in like 10 minutes. I figured it was going to save me so much work...
This is making me start to wonder if I should just implement my own image file format (I would use PPM binary and shove it through a compression stream).
edit: source code:
#include "Texture.h" // for Pixel struct
#include "Script.h" // for lua (quick and dirty shell access)
TEST_FIXTURE(ILSystem, ilWritePng) { // ILSystem calls ilInit(), ilShutDown() in ctor, dtor respectively
ILuint image;
ilGenImages(1,&image);
CHECK(ilGetError()==0);
ilBindImage(image);
Pixel pixels[128*128];
for (int i=0;i<128;++i) { for (int j=0;j<128;++j) {
Pixel &p = pixels[i*128+j];
p.b = 0; p.g = i; p.r = j; p.a = 0xff;
}} // neat and simple test image, a greenish purplish gradient type thing.
CHECK(ilTexImage(128,128,1,4,IL_BGRA, IL_UNSIGNED_BYTE,pixels));
CHECK(ilGetError()==0);
{
LuaSystem l;
l.dostring("os.execute(\"rm output_il.tga\")"); // delete that file
}
ilSaveImage("output_il.tga");
PRINT_INT(ilGetError());
}
#ifdef LOAD_DISPLAY
#include "SDLOGL.h"
#include "Texture.h"
TEST_FIXTURE(SDLSystem, loadPNGDisplay) { // takes care of initing SDL and opengl context
ILSystem s; // RAII = peace of mind
// i can't use two fixtures in one unittest. but this does the same thing anyway.
ILuint image;
CHECK(ilGetError()==0);
ilGenImages(1,&image);
CHECK(ilGetError()==0);
ilBindImage(image);
CHECK(ilGetError()==0);
ilLoadImage("folder.bmp");
CHECK(ilGetError()==0);
ILubyte *pixelData = ilGetData(); CHECK(pixelData);
CHECK(ilGetError()==0);
GLuint tex = loadImage32(pixelData,ilGetInteger(IL_IMAGE_WIDTH),ilGetInteger(IL_IMAGE_HEIGHT),0);
// i do not know exactly how its encoded. but it seems like when loading pngs it is in RGBA format
PRINT_INT(ilGetInteger(IL_FORMAT_MODE));
CHECK(ilGetError()==0);
initOrthoRender();
drawTexture(tex);
CHECK(glGetError()==0);
SDL_GL_SwapBuffers();
SLEEP(500);
}
#endif //LOAD_DISPLAY