GIN FailedAssertions on Itanium2 with Intel compiler

Lists: pgsql-hackers
From: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
To: pgsql-hackers(at)postgresql(dot)org, teodor(at)sigaev(dot)ru
Subject: GIN FailedAssertions on Itanium2 with Intel compiler
Date: 2006-08-30 23:40:53
Message-ID: Pine.LNX.4.64.0608310310220.19010@lnfm1.sai.msu.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello -hackers,

I see a make check failures on Itanium2 platform with Intel Compiler
with CVS HEAD. A failure is coming for GIN.

The problem is coming at the assertion at ginbulk.c:62
TRAP: FailedAssertion("!(res != 0)", File: "ginbulk.c", Line: 62)

during the index creation from the regr. tests
CREATE INDEX ii on array_index_op_test using gin(i);

The backtraces before the assertion (unfortunately from intel debugger...):

(idb) bt
#0 0x400000000014d370 in ginChooseElem (accum=0x3, heapptr=0x18000000002, entries=0x1200000012, nentry=16384, low=2, high=16, offset=8192) at ginbulk.c:62
#1 0x400000000014cd00 in ginChooseElem (accum=0x3, heapptr=0x18000000002, entries=0x1200000012, nentry=16384, low=2, high=16, offset=8192) at ginbulk.c:168
#2 0x400000000014c790 in ginInsertRecordBA (accum=0x3, heapptr=0x18000000002, entries=0x1200000012, nentry=16384) at ginbulk.c:192
#3 0x4000000000123380 in ginBuildCallback (index=0x3, htup=0x18000000002, values=0x1200000012, isnull=0x4000 <no value>, tupleIsAlive=2 '\002', state=0x1800000010) at gininsert.c:203
#4 0x4000000000174ee0 in IndexBuildHeapScan (heapRelation=0x3, indexRelation=0x18000000002, indexInfo=0x1200000012, callback=0x4000, callback_state=0x18000000002) at index.c:1534
#5 0x4000000000124ea0 in ginbuild (fcinfo=0x3) at gininsert.c:311
#6 0x40000000006eaf00 in OidFunctionCall3 (functionId=3, arg1=1649267441666, arg2=77309411346, arg3=16384) at fmgr.c:1460
#7 0x4000000000177390 in reindex_relation (relid=3, toast_too=2 '\002') at index.c:1282
#8 0x4000000000172700 in index_create (heapRelationId=3, indexRelationName=0x18000000002 <no value>, indexRelationId=18, indexInfo=0x4000, accessMethodObjectId=2, tableSpaceId=16, classObjectId=0x2000, reloptions=1649267441666, isprimary=0 '\000', isconstraint=0 '\000', allow_system_table_mods=0 '\000', skip_build=0 '\000', concurrent=0 '\000') at index.c:782
---Type <return> to continue, or q <return> to quit---
#9 0x4000000000270df0 in DefineIndex (heapRelation=0x3, indexRelationName=0x18000000002 <no value>, indexRelationId=18, accessMethodName=0x4000 <no value>, tableSpaceName=0x18000000002 <no value>, attributeList=0x1800000010, predicate=0x2000, rangetable=0x18000000002, options=0x0, unique=0 '\000', primary=0 '\000', isconstraint=0 '\000', is_alter_table=0 '\000', check_rights=1 '\001', skip_build=0 '\000', quiet=0 '\000', concurrent=0 '\000') at indexcmds.c:440
#10 0x400000000051b3b0 in ProcessUtility (parsetree=0x3, params=0x18000000002, dest=0x1200000012, completionTag=0x4000 <no value>) at utility.c:789
#11 0x4000000000518100 in PortalRunMulti (portal=0x3, dest=0x18000000002, altdest=0x1200000012, completionTag=0x4000 <no value>) at pquery.c:1062
#12 0x4000000000516f90 in PortalRun (portal=0x3, count=1649267441666, dest=0x1200000012, altdest=0x4000, completionTag=0x18000000002 <no value>) at pquery.c:700
#13 0x400000000050e770 in exec_simple_query (query_string=0x3 <no value>) at postgres.c:1003
#14 0x400000000050bc20 in PostgresMain (argc=3, argv=0x18000000002, username=0x1200000012 <no value>) at postgres.c:3263
#15 0x400000000045fc20 in BackendRun (port=0x3) at postmaster.c:2848
#16 0x400000000045ea80 in ServerLoop () at postmaster.c:2485
#17 0x400000000045c310 in PostmasterMain (argc=3, argv=0x18000000002) at postmaster.c:950
#18 0x400000000035a0b0 in main (argc=3, argv=0x18000000002) at main.c:187

(idb) bt full
#0 0x400000000014d370 in ginChooseElem (accum=0x3, heapptr=0x18000000002, entries=0x1200000012, nentry=16384, low=2, high=16, offset=8192) at ginbulk.c:62
middle=Info: symbol middle is defined but not allocated (optimized away)
<no value>
pos=Info: symbol pos is defined but not allocated (optimized away)
<no value>
#1 0x400000000014cd00 in ginChooseElem (accum=0x3, heapptr=0x18000000002, entries=0x1200000012, nentry=16384, low=2, high=16, offset=8192) at ginbulk.c:168
middle=Info: symbol middle is defined but not allocated (optimized away)
<no value>
pos=Info: symbol pos is defined but not allocated (optimized away)
<no value>
#2 0x400000000014c790 in ginInsertRecordBA (accum=0x3, heapptr=0x18000000002, entries=0x1200000012, nentry=16384) at ginbulk.c:192
i=Info: symbol i is defined but not allocated (optimized away)
<no value>
nbit=Info: symbol nbit is defined but not allocated (optimized away)
<no value>
offset=Info: symbol offset is defined but not allocated (optimized away)
<no value>
#3 0x4000000000123380 in ginBuildCallback (index=0x3, htup=0x18000000002, values=0x1200000012, isnull=0x4000 <no value>, tupleIsAlive=2 '\002', state=0x1800000010) at gininsert.c:203
---Type <return> to continue, or q <return> to quit---
buildstate=Info: symbol buildstate is defined but not allocated (optimized away)
<no value>
oldCtx=Info: symbol oldCtx is defined but not allocated (optimized away)
<no value>
#4 0x4000000000174ee0 in IndexBuildHeapScan (heapRelation=0x3, indexRelation=0x18000000002, indexInfo=0x1200000012, callback=0x4000, callback_state=0x18000000002) at index.c:1534
OldestXmin=Info: symbol OldestXmin is defined but not allocated (optimized away)
<no value>
econtext=Info: symbol econtext is defined but not allocated (optimized away)
<no value>
estate=Info: symbol estate is defined but not allocated (optimized away)
<no value>
heapTuple=Info: symbol heapTuple is defined but not allocated (optimized away)
<no value>
isnull={0 '\000', -6 '\372', 3 '\003', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 96 '', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 96 '', 66 'B', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 0 '\000', 48 '0', -57 '\307', 65 'A', 0 '\000'}
predicate=Info: symbol predicate is defined but not allocated (optimized away)
<no value>
reltuples=Info: symbol reltuples is defined but not allocated (optimized away)
<no value>
---Type <return> to continue, or q <return> to quit---
scan=Info: symbol scan is defined but not allocated (optimized away)
<no value>
slot=Info: symbol slot is defined but not allocated (optimized away)
<no value>
snapshot=Info: symbol snapshot is defined but not allocated (optimized away)
<no value>
values={2305843009223818252, 6917529027642707624, 6917529027642654720, 0, 6917529027642679968, 0, 0, 4294967295, 2742, 2742, 2742, 1, 6917546619819731008, 2305843009220667000, 0, 12884901968, 0, 0, 18682901579169792, 6917546619819729920, 18714993574805504, 51539607576, 1, 6917546619819725504, 6917546619819729976, 6917529027642707624, 6917529027641342608, 10814, 46445776340607, 49152, 0, 0}
#5 0x4000000000124ea0 in ginbuild (fcinfo=0x3) at gininsert.c:311
buffer=Info: symbol buffer is defined but not allocated (optimized away)
<no value>
entry=6917546615532235008
heap=Info: symbol heap is defined but not allocated (optimized away)
<no value>
index=Info: symbol index is defined but not allocated (optimized away)
<no value>
indexInfo=Info: symbol indexInfo is defined but not allocated (optimized away)
<no value>
list=Info: symbol list is defined but not allocated (optimized away)
<no value>
---Type <return> to continue, or q <return> to quit---
nlist=1624648
oldCtx=Info: symbol oldCtx is defined but not allocated (optimized away)
<no value>
reltuples=Info: symbol reltuples is defined but not allocated (optimized away)
<no value>
result=Info: symbol result is defined but not allocated (optimized away)
<no value>
#6 0x40000000006eaf00 in OidFunctionCall3 (functionId=3, arg1=1649267441666, arg2=77309411346, arg3=16384) at fmgr.c:1460
result=Info: symbol result is defined but not allocated (optimized away)
<no value>
#7 0x4000000000177390 in reindex_relation (relid=3, toast_too=2 '\002') at index.c:1282
doneIndexes=Info: symbol doneIndexes is defined but not allocated (optimized away)
<no value>
indexId=Info: symbol indexId is defined but not allocated (optimized away)
<no value>
indexIds=Info: symbol indexIds is defined but not allocated (optimized away)
<no value>
is_pg_class=Info: symbol is_pg_class is defined but not allocated (optimized away)
<no value>
rel=Info: symbol rel is defined but not allocated (optimized away)
<no value>
---Type <return> to continue, or q <return> to quit---
result=Info: symbol result is defined but not allocated (optimized away)
<no value>
toast_relid=Info: symbol toast_relid is defined but not allocated (optimized away)
<no value>
#8 0x4000000000172700 in index_create (heapRelationId=3, indexRelationName=0x18000000002 <no value>, indexRelationId=18, indexInfo=0x4000, accessMethodObjectId=2, tableSpaceId=16, classObjectId=0x2000, reloptions=1649267441666, isprimary=0 '\000', isconstraint=0 '\000', allow_system_table_mods=0 '\000', skip_build=0 '\000', concurrent=0 '\000') at index.c:782
heapRelation=Info: symbol heapRelation is defined but not allocated (optimized away)
<no value>
i=Info: symbol i is defined but not allocated (optimized away)
<no value>
indexRelation=Info: symbol indexRelation is defined but not allocated (optimized away)
<no value>
indexTupDesc=Info: symbol indexTupDesc is defined but not allocated (optimized away)
<no value>
namespaceId=Info: symbol namespaceId is defined but not allocated (optimized away)
<no value>
pg_class=Info: symbol pg_class is defined but not allocated (optimized away)
<no value>
---Type <return> to continue, or q <return> to quit---
shared_relation=Info: symbol shared_relation is defined but not allocated (optimized away)
<no value>
#9 0x4000000000270df0 in DefineIndex (heapRelation=0x3, indexRelationName=0x18000000002 <no value>, indexRelationId=18, accessMethodName=0x4000 <no value>, tableSpaceName=0x18000000002 <no value>, attributeList=0x1800000010, predicate=0x2000, rangetable=0x18000000002, options=0x0, unique=0 '\000', primary=0 '\000', isconstraint=0 '\000', is_alter_table=0 '\000', check_rights=1 '\001', skip_build=0 '\000', quiet=0 '\000', concurrent=0 '\000') at indexcmds.c:440
accessMethodForm=Info: symbol accessMethodForm is defined but not allocated (optimized away)
<no value>
accessMethodId=Info: symbol accessMethodId is defined but not allocated (optimized away)
<no value>
amoptions=Info: symbol amoptions is defined but not allocated (optimized away)
<no value>
classObjectId=Info: symbol classObjectId is defined but not allocated (optimized away)
<no value>
heaprelid={relId = 0, dbId = 0}
indexForm=Info: symbol indexForm is defined but not allocated (optimized away)
<no value>
---Type <return> to continue, or q <return> to quit---
indexInfo=Info: symbol indexInfo is defined but not allocated (optimized away)
<no value>
indexTuple=Info: symbol indexTuple is defined but not allocated (optimized away)
<no value>
ixcnt=Info: symbol ixcnt is defined but not allocated (optimized away)
<no value>
lc=Info: symbol lc is defined but not allocated (optimized away)
<no value>
namespaceId=Info: symbol namespaceId is defined but not allocated (optimized away)
<no value>
numberOfAttributes=Info: symbol numberOfAttributes is defined but not allocated (optimized away)
<no value>
old_xact_list=Info: symbol old_xact_list is defined but not allocated (optimized away)
<no value>
pg_index=Info: symbol pg_index is defined but not allocated (optimized away)
<no value>
rel=Info: symbol rel is defined but not allocated (optimized away)
<no value>
relationId=Info: symbol relationId is defined but not allocated (optimized away)
<no value>
reloptions=Info: symbol reloptions is defined but not allocated (optimized away)
---Type <return> to continue, or q <return> to quit---
<no value>
snapshot=Info: symbol snapshot is defined but not allocated (optimized away)
<no value>
tablespaceId=Info: symbol tablespaceId is defined but not allocated (optimized away)
<no value>
tuple=Info: symbol tuple is defined but not allocated (optimized away)
<no value>
#10 0x400000000051b3b0 in ProcessUtility (parsetree=0x3, params=0x18000000002, dest=0x1200000012, completionTag=0x4000 <no value>) at utility.c:789
No locals.
#11 0x4000000000518100 in PortalRunMulti (portal=0x3, dest=0x18000000002, altdest=0x1200000012, completionTag=0x4000 <no value>) at pquery.c:1062
planlist_item=Info: symbol planlist_item is defined but not allocated (optimized away)
<no value>
querylist_item=Info: symbol querylist_item is defined but not allocated (optimized away)
<no value>
#12 0x4000000000516f90 in PortalRun (portal=0x3, count=1649267441666, dest=0x1200000012, altdest=0x4000, completionTag=0x18000000002 <no value>) at pquery.c:700
result=Info: symbol result is defined but not allocated (optimized away)
<no value>
saveActivePortal=Info: symbol saveActivePortal is defined but not allocated (optimized away)
---Type <return> to continue, or q <return> to quit---
<no value>
saveActiveSnapshot=Info: symbol saveActiveSnapshot is defined but not allocated (optimized away)
<no value>
saveMemoryContext=Info: symbol saveMemoryContext is defined but not allocated (optimized away)
<no value>
savePortalContext=Info: symbol savePortalContext is defined but not allocated (optimized away)
<no value>
saveQueryContext=Info: symbol saveQueryContext is defined but not allocated (optimized away)
<no value>
saveResourceOwner=Info: symbol saveResourceOwner is defined but not allocated (optimized away)
<no value>
saveTopTransactionContext=Info: symbol saveTopTransactionContext is defined but not allocated (optimized away)
<no value>
saveTopTransactionResourceOwner=Info: symbol saveTopTransactionResourceOwner is defined but not allocated (optimized away)
<no value>
---Type <return> to continue, or q <return> to quit---
#13 0x400000000050e770 in exec_simple_query (query_string=0x3 <no value>) at postgres.c:1003
dest=Info: symbol dest is defined but not allocated (optimized away)
<no value>
oldcontext=Info: symbol oldcontext is defined but not allocated (optimized away)
<no value>
parsetree_item=Info: symbol parsetree_item is defined but not allocated (optimized away)
<no value>
parsetree_list=Info: symbol parsetree_list is defined but not allocated (optimized away)
<no value>
prepare_string=Info: symbol prepare_string is defined but not allocated (optimized away)
<no value>
save_log_statement_stats=Info: symbol save_log_statement_stats is defined but not allocated (optimized away)
<no value>
was_logged=Info: symbol was_logged is defined but not allocated (optimized away)
<no value>
#14 0x400000000050bc20 in PostgresMain (argc=3, argv=0x18000000002, username=0x1200000012 <no value>) at postgres.c:3263
am_superuser=Info: symbol am_superuser is defined but not allocated (optimized away)
---Type <return> to continue, or q <return> to quit---
<no value>
ctx=Info: symbol ctx is defined but not allocated (optimized away)
<no value>
dbname=Info: symbol dbname is defined but not allocated (optimized away)
<no value>
debug_flag=Info: symbol debug_flag is defined but not allocated (optimized away)
<no value>
errs=Info: symbol errs is defined but not allocated (optimized away)
<no value>
firstchar=Info: symbol firstchar is defined but not allocated (optimized away)
<no value>
flag=Info: symbol flag is defined but not allocated (optimized away)
<no value>
guc_names=Info: symbol guc_names is defined but not allocated (optimized away)
<no value>
guc_values=Info: symbol guc_values is defined but not allocated (optimized away)
<no value>
gucsource=Info: symbol gucsource is defined but not allocated (optimized away)
<no value>
input_message={data = 0x6000000000157908 "CREATE INDEX ii on array_index_op_test using gin(i);", len = 53, maxlen = 256, cursor = 53}
local_sigjmp_buf={{__jmpbuf = {6917546619819733104, 2305843009220182528, 0, 2674341019124543, 0, 0, 0, 0, 4611686018432675632, 0, 0, 0, 0, 0, -4611686018427380546, 0, 5832833, 6917537823734097288, 0, 6917546619819733120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 691754661981---Type <return> to continue, or q <return> to quit---
9733935, 0, 0, 0, 0, 0, 2852126720, 65528, 0, 0}, __mask_was_saved = 1, __saved_mask = {__val = {18446744066192964099, 9223372036854775808, 4294967295, 9223372036854775808, 65553, 9223372036854775808, 65552, 9223372036854775808, 2305843009220667000, 0, 65598, 9223372036854775808, 65511, 0, 0, 0}}}}
secure=Info: symbol secure is defined but not allocated (optimized away)
<no value>
send_ready_for_query=0 '\000'
stack_base=0 '\000'
userDoption=Info: symbol userDoption is defined but not allocated (optimized away)
<no value>
#15 0x400000000045fc20 in BackendRun (port=0x3) at postmaster.c:2848
ac=Info: symbol ac is defined but not allocated (optimized away)
<no value>
av=Info: symbol av is defined but not allocated (optimized away)
<no value>
i=Info: symbol i is defined but not allocated (optimized away)
<no value>
maxac=Info: symbol maxac is defined but not allocated (optimized away)
<no value>
protobuf="-v196608"
secs=210294493
usecs=148189
#16 0x400000000045ea80 in ServerLoop () at postmaster.c:2485
---Type <return> to continue, or q <return> to quit---
last_touch_time=Info: symbol last_touch_time is defined but not allocated (optimized away)
<no value>
later={tv_sec = 1156978893, tv_usec = 522831}
nSockets=Info: symbol nSockets is defined but not allocated (optimized away)
<no value>
now=Info: symbol now is defined but not allocated (optimized away)
<no value>
readmask={fds_bits = {24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}
#17 0x400000000045c310 in PostmasterMain (argc=3, argv=0x18000000002) at postmaster.c:950
i=Info: symbol i is defined but not allocated (optimized away)
<no value>
opt=Info: symbol opt is defined but not allocated (optimized away)
<no value>
status=Info: symbol status is defined but not allocated (optimized away)
<no value>
userDoption=Info: symbol userDoption is defined but not allocated (optimized away)
<no value>
#18 0x400000000035a0b0 in main (argc=3, argv=0x18000000002) at main.c:187
No locals.

PG was configured with
./configure --enable-cassert --enable-debug --prefix=$PWD/install CC='icc'

Intel compiler version l_cc_c_9.1.042 or l_cc_c_9.0.030.

I didn't succeed to get the error for the compilation without '-O2' flag
for the compiler (when I set CFLAGS to '-g' for example).

Regards,
Sergey

*******************************************************************
Sergey E. Koposov
Max Planck Institute for Astronomy/Sternberg Astronomical Institute
Tel: +49-6221-528-349
Web: http://lnfm1.sai.msu.ru/~math
E-mail: math(at)sai(dot)msu(dot)ru


From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
To: pgsql-hackers(at)postgresql(dot)org
Cc: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
Subject: Re: GIN FailedAssertions on Itanium2 with Intel compiler
Date: 2006-08-31 09:48:09
Message-ID: 44F6B059.2040701@sigaev.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Huh, it's a over-optimization by icc on Itanium. With -00 or -02 there is no any
problem, only -O2 produces such effect. The problem is in code at lines 125-172
in ginutils.c:

static bool needUnique = false;

int cmpFunc(...) {
...
if (...) needUnique = true;
...
}
...
needUnique = false;
qsort(...., cmpFunc);
if (needUnique) ....

And, needUnique was setted to true in last call of cmpFunc (by accident, in
fact), so between last call and checking of needUnique there isn't any call of
function. Insertion after qsort() any call (elog, for example) solves the problem.

If needUnique is marked as "volatile", all is ok too. But this way doesn't seem
to me as reasonable, because there is a lot of places with potentially the same
problem... and thats may cause unpredictable failures. May be, better way is
limiting optimization level on Itanium with icc.

--
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/


From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
To: pgsql-hackers(at)postgresql(dot)org
Cc: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
Subject: Re: GIN FailedAssertions on Itanium2 with Intel compiler
Date: 2006-08-31 12:46:23
Message-ID: 44F6DA1F.4090002@sigaev.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Simple illustration:

#include <stdio.h>
#include <stdlib.h>

static char SI = 0;

static int
cmp(const void *a, const void *b) {
puts("CALL cmp");
if ( *(int*)a == *(int*)b ) {
puts("SET SI = 1");
SI = 1;
return 0;
}
return ( *(int*)a > *(int*)b ) ? 1 : -1;
}

int
main(int argn, char *argv[]) {
int a[]={43,43};

SI = 0;
qsort(a, sizeof(a)/sizeof(int), sizeof(int), cmp);

if ( SI )
puts("OK");
else
puts("BUG: SI==0");

return 0;
}

% icc -O2 -o 1 1.c && ./1
CALL cmp
SET SI = 1
BUG: SI==0
% icc -O1 -o 1 1.c && ./1
CALL cmp
SET SI = 1
OK

--
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/


From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
To: pgsql-hackers(at)postgresql(dot)org
Cc: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
Subject: Re: GIN FailedAssertions on Itanium2 with Intel compiler
Date: 2006-09-01 09:01:35
Message-ID: 44F7F6EF.3090606@sigaev.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> Huh, it's a over-optimization by icc on Itanium. With -00 or -02 there
> is no any problem, only -O2 produces such effect. The problem is in code

Sorry, right "With -00 or -01 there is no any problem"

--
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/


From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Teodor Sigaev <teodor(at)sigaev(dot)ru>, "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
Subject: Re: GIN FailedAssertions on Itanium2 with Intel compiler
Date: 2006-09-01 11:10:44
Message-ID: 44F81534.7000009@sigaev.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> % icc -O2 -o 1 1.c && ./1
> CALL cmp
> SET SI = 1
> BUG: SI==0
> % icc -O1 -o 1 1.c && ./1
> CALL cmp
> SET SI = 1
> OK

BTW, this example works correct with -nolib-inline
(http://www.intel.com/software/products/compilers/clin/docs/main_cls/mergedprojects/copts_cls/ccpp_options/option_nolib_inline.htm):
% icc -O2 -nolib_inline -o 1 1.c&& ./1
CALL cmp
SET SI = 1
OK

PS Have anybody any thoughts about workaround?
--
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/


From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Teodor Sigaev <teodor(at)sigaev(dot)ru>
Cc: pgsql-hackers(at)postgresql(dot)org, "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
Subject: Re: GIN FailedAssertions on Itanium2 with Intel compiler
Date: 2006-09-01 11:27:57
Message-ID: 20060901112757.GO12644@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Sep 01, 2006 at 03:10:44PM +0400, Teodor Sigaev wrote:
> BTW, this example works correct with -nolib-inline
> (http://www.intel.com/software/products/compilers/clin/docs/main_cls/mergedprojects/copts_cls/ccpp_options/option_nolib_inline.htm):
> % icc -O2 -nolib_inline -o 1 1.c&& ./1
> CALL cmp
> SET SI = 1
> OK
>
> PS Have anybody any thoughts about workaround?

What does that option do? Is it practical to enable it for the entire
backend?

And isn't this a straightforward compiler bug they should be notified
about?

Sounds like the -fno-strict-aliasing option for gcc, the compiler is
making some assumptions about the code that arn't true, so we tell the
compiler not to do that.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.


From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org, "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
Subject: Re: GIN FailedAssertions on Itanium2 with Intel compiler
Date: 2006-09-01 11:48:40
Message-ID: 44F81E18.7090909@sigaev.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> What does that option do? Is it practical to enable it for the entire
> backend?
From docs:
Disables inline expansion of standard library or intrinsic functions.

> And isn't this a straightforward compiler bug they should be notified
> about?
What's a choice? Now I see 3:
1) -O1
2) "volatile"
3) -nolib_inline

IMHO, only -O1 is guarantee for other possible places... But I'm not familiar
enough with such kinds of bugs.

--
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Teodor Sigaev <teodor(at)sigaev(dot)ru>
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, pgsql-hackers(at)postgresql(dot)org, "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
Subject: Re: GIN FailedAssertions on Itanium2 with Intel
Date: 2006-09-03 01:54:33
Message-ID: 200609030154.k831sXK00200@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Teodor Sigaev wrote:
> > What does that option do? Is it practical to enable it for the entire
> > backend?
> From docs:
> Disables inline expansion of standard library or intrinsic functions.
>
> > And isn't this a straightforward compiler bug they should be notified
> > about?
> What's a choice? Now I see 3:
> 1) -O1
> 2) "volatile"
> 3) -nolib_inline
>
> IMHO, only -O1 is guarantee for other possible places... But I'm not familiar
> enough with such kinds of bugs.

My guess is that the compiler writers saw you calling a libc function,
and assumed that library could not modify the file static variable,
forgetting that the libc function can call back into the original file.

Can you detect the Itanium compiler and optimization levels via
preprocessor symbols, and test for that, and throw an #error?

--
Bruce Momjian bruce(at)momjian(dot)us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Teodor Sigaev <teodor(at)sigaev(dot)ru>, Martijn van Oosterhout <kleptog(at)svana(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: GIN FailedAssertions on Itanium2 with Intel compiler
Date: 2006-09-03 15:44:32
Message-ID: Pine.LNX.4.64.0609031937050.18490@lnfm1.sai.msu.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, 2 Sep 2006, Bruce Momjian wrote:

> Teodor Sigaev wrote:
>>> What does that option do? Is it practical to enable it for the entire
>>> backend?
>> From docs:
>> Disables inline expansion of standard library or intrinsic functions.
>>
>>> And isn't this a straightforward compiler bug they should be notified
>>> about?
>> What's a choice? Now I see 3:
>> 1) -O1
>> 2) "volatile"
>> 3) -nolib_inline
>>
>> IMHO, only -O1 is guarantee for other possible places... But I'm not familiar
>> enough with such kinds of bugs.
>
> My guess is that the compiler writers saw you calling a libc function,
> and assumed that library could not modify the file static variable,
> forgetting that the libc function can call back into the original file.
>
> Can you detect the Itanium compiler and optimization levels via
> preprocessor symbols, and test for that, and throw an #error?

No, it's impossible.
Unfortunately the __OPTIMIZE__ preproc. symbol of icc doesn't allow to
distinguish between different optimization levels. (only between -O0 and
anything else).

Regards,
Sergey

*******************************************************************
Sergey E. Koposov
Max Planck Institute for Astronomy/Sternberg Astronomical Institute
Tel: +49-6221-528-349
Web: http://lnfm1.sai.msu.ru/~math
E-mail: math(at)sai(dot)msu(dot)ru


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
Cc: Teodor Sigaev <teodor(at)sigaev(dot)ru>, Martijn van Oosterhout <kleptog(at)svana(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: GIN FailedAssertions on Itanium2 with Intel
Date: 2006-09-04 23:57:24
Message-ID: 200609042357.k84NvOp28749@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


I suggest you test for the Intel compiler, and if it is there, make the
static variable "volatile", and add a comment about why that is being
done.

---------------------------------------------------------------------------

Sergey E. Koposov wrote:
> On Sat, 2 Sep 2006, Bruce Momjian wrote:
>
> > Teodor Sigaev wrote:
> >>> What does that option do? Is it practical to enable it for the entire
> >>> backend?
> >> From docs:
> >> Disables inline expansion of standard library or intrinsic functions.
> >>
> >>> And isn't this a straightforward compiler bug they should be notified
> >>> about?
> >> What's a choice? Now I see 3:
> >> 1) -O1
> >> 2) "volatile"
> >> 3) -nolib_inline
> >>
> >> IMHO, only -O1 is guarantee for other possible places... But I'm not familiar
> >> enough with such kinds of bugs.
> >
> > My guess is that the compiler writers saw you calling a libc function,
> > and assumed that library could not modify the file static variable,
> > forgetting that the libc function can call back into the original file.
> >
> > Can you detect the Itanium compiler and optimization levels via
> > preprocessor symbols, and test for that, and throw an #error?
>
> No, it's impossible.
> Unfortunately the __OPTIMIZE__ preproc. symbol of icc doesn't allow to
> distinguish between different optimization levels. (only between -O0 and
> anything else).
>
> Regards,
> Sergey
>
> *******************************************************************
> Sergey E. Koposov
> Max Planck Institute for Astronomy/Sternberg Astronomical Institute
> Tel: +49-6221-528-349
> Web: http://lnfm1.sai.msu.ru/~math
> E-mail: math(at)sai(dot)msu(dot)ru
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org

--
Bruce Momjian bruce(at)momjian(dot)us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +