|
lemonadesweetheart posted:It's pretty hard to determine what the problem is without the source. I know you said you tested for dynamic allocations so the only other place I can thing of is have you checked the type conversions, floats are tricky bitches. Also make sure that the type definitions are correct for the platforms you're using them on. That's the thing. There are no type conversions taking place. It's literally just a line like this returning NaN: double x = atan2(a, b); Where a and b are both valid angles. If I repeat that calculation it doesn't fail, presumably because I've changed the program enough to bump it away from whatever odd luck caused it. I'm not sure if anyone here can solve it. I was just hoping that someone would say "that's a weird problem; maybe it's X?" and then I'd have a starting point. It's the sort of hard-to-repeat oddity that makes me immediately think memory corruption but I can't find any. ctz posted:Do you have any code or libraries which are using mmx/sse* functions without issuing emms? Nope. This is all dead simple C. There's nothing the slightest bit more exotic than DLL exports.
|
# ? Sep 25, 2010 11:50 |
|
|
# ? Jun 7, 2024 06:27 |
|
Grazing Occultation posted:I've checked for memory corruption using _CRTDBG_CHECK_ALWAYS_DF because when I have a problem this odd it's usually something along those lines. I've also tested for memory leaks. That ruled out corruption from dynamically allocated memory and there aren't many statically allocated arrays. Rational Purify is a decent "hail mary" option if you have access to it.
|
# ? Sep 25, 2010 12:36 |
|
Grazing Occultation posted:That's the thing. There are no type conversions taking place. It's literally just a line like this returning NaN:
|
# ? Sep 25, 2010 17:28 |
|
code:
EDIT: Well I kind of solved it by doing this: code:
Contero fucked around with this message at 08:21 on Sep 26, 2010 |
# ? Sep 26, 2010 07:56 |
|
The Visual Studio C++ ABI's class layout algorithm is really wonky when it comes to empty base classes. I believe it is trying to make sure that the base subobjects have different addresses, even though they don't share any common base types.
|
# ? Sep 26, 2010 10:28 |
|
covener posted:Rational Purify is a decent "hail mary" option if you have access to it. Unfortunately the only copy we have is from 2001 and no one knows where the CD is any more! schnarf posted:You could try making a wrapper function for atan2 that does something like dumping the floating point registers, calls atan2(), and then breaks if it returned an unexpected value, and calling that wrapper instead to debug the problem. This is a good idea. I might give that a shot - even if the problem is somewhere else, maybe it'll give me more clues.
|
# ? Sep 26, 2010 14:04 |
|
Grazing Occultation posted:This is a good idea. I might give that a shot - even if the problem is somewhere else, maybe it'll give me more clues.
|
# ? Sep 26, 2010 18:33 |
|
I'm trying to use the Eclipse IDE for C++ with cygwin and I can't figure out how to make it work. When I try to build the .exe I get this message in the console:code:
I'm using Windows 7 32-bit.
|
# ? Sep 28, 2010 02:18 |
|
schnarf posted:Ahh, one other thought, and sorry for how vague it is. If I remember right, some of my coworkers ran into some mysterious bug that resulted from something to do with calling conventions. It was something like, there was some function that had the wrong calling convention (possibly it was that the prototype didn't have the correct calling convention), and that function was passed/returned floats. As a result, the floating point stack would occasionally end up in a weird state. You could check to see if anything along these [extremely vague] lines applies to your case. I'll try to remember to ask them about that on Monday. It's all using doubles and the default calling convention. The functions in question aren't even DLL-exported. I could handle getting this sort of weird voodoo poo poo if I had the balls to do things like that! I've noticed two really strange things: If I put only one trig call on a line then the problem does not occur. For example: code:
code:
I freely admit to being clueless about assembler (hell, I'm not even a programmer/CS guy) but if I step through the disassembly, one line seems to be doing it code:
|
# ? Sep 28, 2010 18:05 |
|
Grazing Occultation posted:It's all using doubles and the default calling convention. The functions in question aren't even DLL-exported. I could handle getting this sort of weird voodoo poo poo if I had the balls to do things like that! What are the assembly outputs for the one-line vs multi-line snippets?
|
# ? Sep 28, 2010 18:58 |
|
This is a simple question but one I did not find the answer to from quick googling. Is there a difference between declaring a variable as long int myVariable and int long myVariable? And if there is, what is the difference?
|
# ? Sep 28, 2010 19:07 |
|
Jose Cuervo posted:This is a simple question but one I did not find the answer to from quick googling. Is there a difference between declaring a variable as long int myVariable and int long myVariable? And if there is, what is the difference? No. It's also the same as simply "long".
|
# ? Sep 28, 2010 19:15 |
|
I know glibc has backtrace() and backtrace_symbols, but does anyone know of a way to get the current backtrace (even if the symbols are mangled, I don't much care) under Sun CC (Sun Studio's compiler)? Google is proving useless, which doesn't bode well for this question.
|
# ? Sep 28, 2010 19:33 |
|
Ugg boots posted:What are the assembly outputs for the one-line vs multi-line snippets? Two line: code:
code:
code:
|
# ? Sep 28, 2010 19:41 |
|
Objective-C: Are they serious?
|
# ? Sep 28, 2010 20:01 |
|
Serious about what?
|
# ? Sep 28, 2010 20:27 |
|
Grazing Occultation posted:It's all using doubles and the default calling convention. The functions in question aren't even DLL-exported. I could handle getting this sort of weird voodoo poo poo if I had the balls to do things like that! I don't know what's going wrong with your code, but have you tried setting your compiler to use SSE for floating-point math? (Most x86 compilers default to the old x87 instructions for compatibility, but if you don't need to run your code on anything older than an Athlon64 or a Pentium 4 there should be no problem and it might even increase performance). If the problem stops, then hey you've papered over it (but please leave a comment in the code explaining what's up for the next guy who has to try to fix it). If it doesn't, it might give you some more clues as to what's going on. Mr.Radar fucked around with this message at 20:43 on Sep 28, 2010 |
# ? Sep 28, 2010 20:36 |
|
Grazing Occultation posted:
This has nothing to do with the problem you're having but why do you keep recomputing PI/2? You could save a lot of divisions by defining a PI_2 constant or something.
|
# ? Sep 28, 2010 20:41 |
|
MutantBlue posted:This has nothing to do with the problem you're having but why do you keep recomputing PI/2? You could save a lot of divisions by defining a PI_2 constant or something. PI/2 should be calculated at compile-time anyway.
|
# ? Sep 28, 2010 20:57 |
|
MutantBlue posted:This has nothing to do with the problem you're having but why do you keep recomputing PI/2? You could save a lot of divisions by defining a PI_2 constant or something. Already done for you in math.h
|
# ? Sep 28, 2010 21:03 |
|
^^^I'm slow today.That Turkey Story posted:PI/2 should be calculated at compile-time anyway. Or use M_PI_2 from math.h It would avoid those fdiv ops in Grazing Occultation's assembly listing. MutantBlue fucked around with this message at 21:08 on Sep 28, 2010 |
# ? Sep 28, 2010 21:05 |
|
Isn't a compiler supposed to deal with dividing a constant by another constant such that it doesn't end up in the assembler code? (Like the turkey said but the assembly listings don't reflect.) I would have thought that would be the case even in non-optimised builds.
|
# ? Sep 28, 2010 21:15 |
|
roomforthetuna posted:Isn't a compiler supposed to deal with dividing a constant by another constant such that it doesn't end up in the assembler code? Maybe he compiled in debug mode or with optimizations off.
|
# ? Sep 28, 2010 21:18 |
|
Grazing Occultation posted:Two line: 1#IND is generally a division by zero. By any chance do the values at the memory location of the constant 2.0 (0x48E988 in this case) ever get trampled on?
|
# ? Sep 29, 2010 06:09 |
|
Also cos(PI/2-x) = sin(x) (in fact you can get away with just using acos on some polynomial in cos(lat1+lat2) and cos(lat1-lat2)) edit: I know this doesn't shed light on this particular problem, but you should be careful about what you pass to acos, even when the argument is correct in exact arithmetic. For example on my system sin(0.08)^2+cos(0.08)^2 > 1. Pooball fucked around with this message at 12:52 on Sep 29, 2010 |
# ? Sep 29, 2010 11:14 |
|
Ledneh posted:I know glibc has backtrace() and backtrace_symbols, but does anyone know of a way to get the current backtrace (even if the symbols are mangled, I don't much care) under Sun CC (Sun Studio's compiler)? Google is proving useless, which doesn't bode well for this question. comments in a diagnostic module I own says solaris 9 and higher has printstack(fd);
|
# ? Sep 29, 2010 12:34 |
|
Thanks for the help guys. You're keeping me from giving up and heading for the pub!MutantBlue posted:Maybe he compiled in debug mode or with optimizations off. Yep. I'm not gifted enough to navigate this poo poo without a fancy shmancy IDE! ehnus posted:1#IND is generally a division by zero. By any chance do the values at the memory location of the constant 2.0 (0x48E988 in this case) ever get trampled on? That memory location is still valid. The memory storing PI is also valid; it's when it does the fld that it fails. I can see PI in the debugger and I can see it in the memory viewer, but as soon as it tries to push that value onto the FPU stack the top of the stack becomes 1#IND. This happens in preparing for the second trig call, never the first. It loads PI correctly just a few assembly lines before. Is it possible that the first call has corrupted something somehow? Pooball posted:Also cos(PI/2-x) = sin(x) I don't think this function's ever been optimised except to minimise the number of trig calls. I'm trying to avoid changing this function for the moment: it's been hard just finding a place where I can get the bug to happen repeatably.
|
# ? Sep 29, 2010 15:41 |
|
Grazing Occultation posted:That memory location is still valid. The memory storing PI is also valid; it's when it does the fld that it fails. I can see PI in the debugger and I can see it in the memory viewer, but as soon as it tries to push that value onto the FPU stack the top of the stack becomes 1#IND. What's the 64-bit hex value of the value that ends up on the fp-stack?
|
# ? Sep 29, 2010 16:10 |
|
If the floating-point stack is full, then fld will store nan. So this program (using gcc asm):code:
code:
|
# ? Sep 29, 2010 17:23 |
|
covener posted:comments in a diagnostic module I own says solaris 9 and higher has printstack(fd); I tried that, yeah, but it was meant for C, and doesn't give me C++ names in a way that I can easily demangle. I ended up rolling my own stacktrace thingy using something like the following (not showing #includes because I don't remember what they were) [this code is also sort of incorrect, lots of casts and poo poo I'm not retyping from memory] code:
Ciaphas fucked around with this message at 19:10 on Sep 29, 2010 |
# ? Sep 29, 2010 19:07 |
|
Hmm. well, there is whatever addr2line does, too, if you don't mind linking to libbfd (which may be acceptable for purely debug stuff..) Does the compiler in question use the same C++ ABI as gcc, BTW? If it does, abi::__cxa_demangle might be of some use.
|
# ? Sep 29, 2010 19:26 |
|
The compiler in question is Sun CC provided with Sun Studio 12.1. I don't really want to link anything that's going to murder production performance, either, though I want to be able to get the stack trace in production for the sake of more useful exception info.
|
# ? Sep 29, 2010 19:39 |
|
Getting the source file and line number information would require interpreting the DWARF information, which is much more involved than just figuring out which dynamic symbol (probably) contains the address.
|
# ? Sep 29, 2010 19:41 |
|
Ledneh posted:The compiler in question is Sun CC provided with Sun Studio 12.1. I don't really want to link anything that's going to murder production performance, either, though I want to be able to get the stack trace in production for the sake of more useful exception info. Well, the issue is more that libbfd is GPL'd, which is quite likely to be an issue for production stuff. Hmm. An another option: if you have good control over production binaries, it may be possible to do the line number processing off-line, though you'd need to extract the memory map to know which libraries are located where. Sounds like one of those sorta-simple but pretty fiddly kind of tasks (again, addr2line code may be a good starting point for the post-processing tool).
|
# ? Sep 29, 2010 20:02 |
|
libbfd doesn't have an ABI, either, which will make your life difficult when you upgrade. (It exists purely to share code between the various components of binutils, not to provide a public library. Not that that stops people from using it anyway, and causing much suffering.)
|
# ? Sep 29, 2010 20:13 |
|
If I were to have a for loop, and for example have the test expression i < num(), will that function be called every time, or will a new const value be created to substitute it?
|
# ? Sep 30, 2010 09:34 |
|
Optimus Prime Ribs posted:If I were to have a for loop, and for example have the test expression i < num(), will that function be called every time, or will a new const value be created to substitute it? It'll be called every time.
|
# ? Sep 30, 2010 09:46 |
|
Optimus Prime Ribs posted:If I were to have a for loop, and for example have the test expression i < num(), will that function be called every time, or will a new const value be created to substitute it? http://codepad.org/kc4dtWTZ
|
# ? Sep 30, 2010 09:48 |
|
Well that makes sense. Thanks guys.
|
# ? Sep 30, 2010 10:19 |
|
|
# ? Jun 7, 2024 06:27 |
|
http://codepad.org/TuWkRENh
|
# ? Sep 30, 2010 10:19 |