Segmentation fault with rdtsc, but not in debug mode of gcc 4.7
I was fooling around a bit with getting timing from the TSC using gcc 4.7 on a 1.8GHz system. I wanted to find the overhead for various operations (such as just reading the TSC).
Code: Code:
unsigned long hi, lo; What's really strange is that the segfault occurs two (C++) lines later, in code that looks like this: Code:
std::cerr << "TSC read complete" << std::endl; // <== this is output I'm using gcc 4.7. Any clues? |
is this code multithreaded? is it threadsafe? do you have a coredump? have you tried to analyze it?
|
Quote:
Probably not threadsafe. No coredump file produced, just segfault and abort. I spent some time trying to track down where the exact location of the segfault was, but that's as far as I've gotten so far. I recall seeing a requirement for certain gcc settings being required for using inb_p(), & outb_p(), so I will be revisiting that to see how to set the compiler options in u++/TheIDE. |
inp_b may cause segfault: http://linux.about.com/library/cmd/blcmdl2_inb_p.htm
|
Quote:
The problem I'm having is that the program does *NOT* segfault in debug mode, but will segfault if I compile without debug. I am using TheIDE/Upp for development, and I'm not 100% certain what options are included in non-debug builds. However, the only options that I see that are recommended for use with the I/O instruction are -O and -O2, which I think are turned *OFF* for the debug builds. So the mystery remains. I'm ok for now, but there will come a time when I have to get this to run in a non-debug mode. |
If you can try valgrind it can help you to locate such problems also.
|
All times are GMT -5. The time now is 11:27 PM. |