Operating System - HP-UX
1827757 Members
3068 Online
109969 Solutions
New Discussion

Re: Wierd Error when compiled Proc code with +Ofast compiler option

 
K!rn Kumr
Frequent Advisor

Wierd Error when compiled Proc code with +Ofast compiler option

Hi

Today I have faced really a wierd error. I have a Pro C code which is first converted to c file and then I compiled it with aCC compiler using +Ofast compiler option. Then the code behaves in way different from when it is compiled without Ofast option. And later behaviour is the expected one.

I have debug statement immediately after the END-EXEC; statement in the file, which is the end of the pl/sql block. This debug statement is making the difference. It works fine if i remove the debug statement or remove Ofast from the compiler option or when i run the debug_binary.

Can anyone throw some lite on why this is happening??

Thanks in advance
25 REPLIES 25
OldSchool
Honored Contributor

Re: Wierd Error when compiled Proc code with +Ofast compiler option

1) "the code behaves in way different from when it is compiled without Ofast option"
2) "This debug statement is making the difference."
3) "It works fine if i remove the debug statement or remove Ofast from the compiler option or when i run the debug_binary"

Well...depending upon which of the above statements is really the case, then you have 4 (or possibly more) cases.

Knowing nothing of ProC, I think the first step would be to capture the .c files emitted by ProC to see what changes occur with and without the referenced debug statement.

Then compile both of them, once with and once without the -Ofast option and see which ones work as expected.
K!rn Kumr
Frequent Advisor

Re: Wierd Error when compiled Proc code with +Ofast compiler option

Yeah as you have said when I precompile the proc to get c file. Then I compile the c file with +ofast option and get the binary.

I have a code which i compile to get a shared library. In that I have a small function which I used in different there code peices by include/linking the correct headers/library. And the function I just logs the statments to a file when debug is on.

Here are my observations

1. When I have the debug statement and I have +Ofast option.

This case does not work fine.

2. When I have the debug statement and I do not use +Ofast option.

This case is good.

And I have tried to look into the c file in both the cases it is the same.

3. With Ofast option if I remove the debug statement the result is good.

Steven Schweda
Honored Contributor

Re: Wierd Error when compiled Proc code with +Ofast compiler option

Here are my observations:

1. I can't see any of the code.

2. I don't have a program that I can test.

3. My psychic powers are very weak.
Dennis Handly
Acclaimed Contributor

Re: Weird Error when compiled Proc code with +Ofast compiler option

What OS are you using? What aC++ version are you using? The latest aCC6 version is A.06.23.
(Previous threads had 11.23 and A.06.15.)

Have you removed +Ofast and replaced by +O2?

K!rn Kumr
Frequent Advisor

Re: Wierd Error when compiled Proc code with +Ofast compiler option

My compiler version is
HP C/aC++ Version A.06.20

My OS is
B.11.23 U ia64

Attached is the code. And the last line is the one which creates the problem.
K!rn Kumr
Frequent Advisor

Re: Wierd Error when compiled Proc code with +Ofast compiler option

When I replace +Ofast with anything it works fine.
Dennis Handly
Acclaimed Contributor

Re: Weird Error when compiled Proc code with +Ofast compiler option

>HP C/aC++ Version A.06.20

You should install the latest patch, PHSS_39823.

>Attached is the code.

That is useless, I would need a .i. And unless you could run it, that wouldn't be that helpful.

K!rn Kumr
Frequent Advisor

Re: Wierd Error when compiled Proc code with +Ofast compiler option

I have observed one more thing. Though in my Pro C code I have not declared any cursors. In the c file I have a macro define for cursor.

#ifndef SQL_CRSR
# define SQL_CRSR
struct sql_cursor
{
unsigned int curocn;
void *ptr1;
void *ptr2;
unsigned int magic;
};
typedef struct sql_cursor sql_cursor;
typedef struct sql_cursor SQL_CURSOR;
#endif /* SQL_CRSR */

This code is generated by the proc compiler.

When I compile the above code with ofasat option my result is invalid cursor

And when I compile it without ofast option I get the data.
Dennis Handly
Acclaimed Contributor

Re: Weird Error when compiled Proc code with +Ofast compiler option

>result is invalid cursor

You could print out struct sql_cursor in gdb and compare the good and bad.

K!rn Kumr
Frequent Advisor

Re: Wierd Error when compiled Proc code with +Ofast compiler option

I get this problem when I use non-debug version of the binary. I am not sure if I can debug this version.

And is it possible to compare the object files by any chance
K!rn Kumr
Frequent Advisor

Re: Wierd Error when compiled Proc code with +Ofast compiler option

i gave gdb exe pid

then i have set a breakpoint at the oracle part of the code by giving

activate function name in file

then I have run the test case..the test case hangs but there is no info displayed in gdb console.

Can you please help me
K!rn Kumr
Frequent Advisor

Re: Wierd Error when compiled Proc code with +Ofast compiler option

I have another doubt as it is a proc file is it possible to debug on it. or else will it be possible to debug on the c file generated from pro c compiler
Dennis Handly
Acclaimed Contributor

Re: Weird Error when compiled Proc code with +Ofast compiler option

>I get this problem when I use non-debug version of the binary. I am not sure if I can debug this version.

You can use -g with +Ofast. It won't be as accurate.

>And is it possible to compare the object files by any chance

No, the whole purpose of +Ofast is to make the code different/better.

>activate function name in file

Isn't it "break function"?

>the test case hangs but there is no info displayed in gdb console.

Does control-C work?

>I have another question as it is a proc file is it possible to debug on it. or else will it be possible to debug on the C file generated from pro c compiler

It depends on what that foreign devil preprocessor does. Can you create a .i file and look at it?

The simplest way to debug is to set breakpoints on functions, then look at the parms. Is your struct sql_cursor one of those?

Have you tried A.06.23?

K!rn Kumr
Frequent Advisor

Re: Wierd Error when compiled Proc code with +Ofast compiler option

>Isn't it "break function"?

yes i Have used break funtion..but it is of no use...i gave commands like next n that take me to all the thirdparty library functions but not to any one of my code....

>Does control-C work?
when i give c it continues and ends.

>It depends on what that foreign devil preprocessor does. Can you create a .i file and look at it?
pro c compiler compiles .pc file to generate a .c file. I have no idea of what .i file is

>The simplest way to debug is to set breakpoints on functions, then look at the parms. Is your struct sql_cursor one of those?
Yes i have set a breakpoint and tried to debug but i do not have any useful info

>Have you tried A.06.23?
No I dont have admin rights to install
K!rn Kumr
Frequent Advisor

Re: Wierd Error when compiled Proc code with +Ofast compiler option

Can anyone please help me
Dennis Handly
Acclaimed Contributor

Re: Weird Error when compiled Proc code with +Ofast compiler option

>but not to any one of my code.

You have set breakpoints to each function?

>have no idea of what .i file is

Compile with "-E -.i".

>Yes I have set a breakpoint and tried to debug but I do not have any useful info

What do you get? You may have to debug at the assembly level.

>I don't have admin rights to install
>Can anyone please help me?

If you can't try a new compiler, all you can do is workaround the problem.
Have you replaced +Ofast by +O2 and does that work?
Have you compiled with +wlint and +check=bounds +check=uninit to check for user errors?

K!rn Kumr
Frequent Advisor

Re: Wierd Error when compiled Proc code with +Ofast compiler option

I have changed the compiler option to +O2. It works fine. As I have told earlier, if I remove the +Ofast option and replace it with any other optimization option it works fine.

I am not able to debug as the control is never coming into my file but is always in some third party libraries.
K!rn Kumr
Frequent Advisor

Re: Wierd Error when compiled Proc code with +Ofast compiler option

i am have given -E -.i option when I am compiling the .c file(generated from the .pc file). But it does not compile the .o neither i see any .i files created any where.

Could you please be more specific on it.
Dennis Handly
Acclaimed Contributor

Re: Weird Error when compiled Proc code with +Ofast compiler option

>I have changed the compiler option to +O2. It works fine.

Then that is probably what you should do. Unless you have a support contract, it may not be worth your time.
Why do you want +Ofast?

>I am not able to debug as the control is never coming into my file but is always in some third party libraries.

You can always break on hex addresses:
b * hex-add

>I have given -E -.i option when I am compiling the .c file (generated from the .pc file). But it does not compile the .o

Yes, -E -.i produces a .i and not the .o.

>neither I see any .i files created any where.

You may have to preprocess with Pro C, then use aC++ to create a .i file.

K!rn Kumr
Frequent Advisor

Re: Wierd Error when compiled Proc code with +Ofast compiler option

I have compiled with -E -.i option and compared the files in two different scenarios but they both are some. but the behaviour is different.
Dennis Handly
Acclaimed Contributor

Re: Weird Error when compiled Proc code with +Ofast compiler option

>I have compiled with -E -.i option and compared the files in two different scenarios but they both are some. but the behaviour is different.

Of course. A preprocessed .i file is before it is optimized, or even compiled. But that .i file can be used to perform triage.

K!rn Kumr
Frequent Advisor

Re: Wierd Error when compiled Proc code with +Ofast compiler option

I am sorry...I couldnot get what traige is...
Dennis Handly
Acclaimed Contributor

Re: Weird Error when compiled Proc code with +Ofast compiler option

>I could not get what triage is

A process of determining (sorting, sifting) which component has the bug.

K!rn Kumr
Frequent Advisor

Re: Wierd Error when compiled Proc code with +Ofast compiler option

But how do i do it