Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 140809 - [4.x/bad-code] sys-libs/db-4.x compiled by gcc-4.x - miscompiles cni/jni code
Summary: [4.x/bad-code] sys-libs/db-4.x compiled by gcc-4.x - miscompiles cni/jni code
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Paul de Vrieze (RETIRED)
Depends on:
Reported: 2006-07-17 11:37 UTC by Hanno Zysik (geki)
Modified: 2007-08-31 09:58 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---

A testcase? (,263 bytes, text/plain)
2006-07-17 17:07 UTC, Hanno Zysik (geki)
emerge --info (,3.18 KB, text/plain)
2006-10-18 08:57 UTC, Peter Humphrey
db_java_wrap.c with -O2 opt. segfaults (db_java_wrap.s.diff.bz2,174.16 KB, application/octet-stream)
2006-12-18 13:05 UTC, Hanno Zysik (geki)
-fstrict-aliasing miscompiles db_java_wrap.c (java-wrapper_no-strict-aliasing.diff,433 bytes, patch)
2006-12-18 14:14 UTC, Hanno Zysik (geki)
Details | Diff
proper testcase (,637 bytes, text/plain)
2006-12-19 04:12 UTC, Hanno Zysik (geki)

Note You need to log in before you can comment on or make changes to this bug.
Description Hanno Zysik (geki) 2006-07-17 11:37:04 UTC
As far as I know does Andreas want to use system db for openoffice in future. He told me to report this.

Now if one compiles sys-libs/db-4.x with gcc-4.x it miscompiles cni/jni code of sys-libs/db.

What happens if the optimization level is higher than -O1 is that HelpLinker (Java) in helpcontent2 module segfaults because of that.

The only thing to get around that is to place 'replace-flags "-O2" "-O1"' and 'replace-flags "-O3" "-O1"' before configure in src_compile.

I tried to get a good backtrace but gdb did not print useful information this time but still segfaults.
Comment 1 Andreas Proschofsky (RETIRED) gentoo-dev 2006-07-17 11:49:54 UTC
(In reply to comment #0)
> As far as I know does Andreas want to use system db for openoffice in future.
> He told me to report this.

Yep that's true, using system-db should solve some problems for us, so I'm quite interested in getting a solution for this.

Comment 2 Paul de Vrieze (RETIRED) gentoo-dev 2006-07-17 12:34:55 UTC
Do you have any idea which of the flags enabled by -O2 causes it? Or a small testcase? Which openoffice source file fails? (Could you give me the specific gcc command?) I prefer to fix the sourcecode. Otherwise I could try to fix it.
Comment 3 Hanno Zysik (geki) 2006-07-17 16:28:40 UTC
Well, I just found these links:

They say to replace it by -O. I can say that -O1 does just fine, too. So I prefer -O1. ;)

@ Paul
If you want to dig into gcc and/or db hacking you may contact sleepycat. They know about it.
Sorry, I cannot be of more help here.
Comment 4 Hanno Zysik (geki) 2006-07-17 17:07:17 UTC
Created attachment 92037 [details]
A testcase?

From the first link.
- create new Database

It does not segfault here but runs forever.
Comment 5 Hanno Zysik (geki) 2006-08-21 14:48:07 UTC
Any news here, Paul?

Could be cool to have a check for gcc4.x to reset the optimization level in the ebuild.
Comment 6 Peter Humphrey 2006-10-18 08:55:57 UTC
Here, after switching GCC from 3.4.6 to 4.1.1 I cannot compile db-4.3.29-r2. I get this:

/bin/sh ./libtool --mode=compile x86_64-pc-linux-gnu-g++ -c -I. -I../dist/..  -D_GNU_SOURCE -D_REENTRANT -O1 -march=opteron -pipe ../dist/../cxx/cxx_db.cpp
 x86_64-pc-linux-gnu-g++ -c -I. -I../dist/.. -D_GNU_SOURCE -D_REENTRANT -O1 -march=opteron -pipe ../dist/../cxx/cxx_db.cpp  -fPIC -DPIC -o .libs/cxx_db.o
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/include/g++-v4/backward/iostream.h:31,
                 from ./db_cxx.h:60,
                 from ../dist/../cxx/cxx_db.cpp:15:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/include/g++-v4/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
In file included from ../dist/../cxx/cxx_db.cpp:15:
./db_cxx.h:61:23: error: exception.h: No such file or directory

I tried setting the optimisation level down, thus:

$ cat /etc/portage/env/sys-libs/db
CFLAGS="-O1 -march=opteron -pipe"

... but I still get the same error. Not sure what else to try.
Comment 7 Peter Humphrey 2006-10-18 08:57:17 UTC
Created attachment 99945 [details]
emerge --info
Comment 8 Hanno Zysik (geki) 2006-12-18 13:05:53 UTC
Created attachment 104309 [details]
db_java_wrap.c with -O2 opt. segfaults

... db_java_wrap.c with -O1 is fine.

It segfaults in: Java_com_sleepycat_db_internal_db_1javaJNI_DbEnv_1set_1errcall
This is the assembly code diff.bz2 between -O1 and -O2 opt.
I hope it helps.
Comment 9 Hanno Zysik (geki) 2006-12-18 14:14:30 UTC
Created attachment 104321 [details, diff]
-fstrict-aliasing miscompiles db_java_wrap.c
Comment 10 Hanno Zysik (geki) 2006-12-19 04:12:13 UTC
Created attachment 104352 [details]
proper testcase
Comment 11 Hanno Zysik (geki) 2006-12-23 04:37:26 UTC
May be it is also good to inform upstream to update their FAQ. See:
Comment 12 Andreas Proschofsky (RETIRED) gentoo-dev 2007-01-12 12:14:33 UTC
the fix is not necessary anymore to build OOo with system-db, still would be good to get it in /me thinks
Comment 13 Hanno Zysik (geki) 2007-04-17 09:44:39 UTC
I sent my patch upstream and Oracle included it. So upcoming releases will be fine hopefully.
Comment 14 Hanno Zysik (geki) 2007-08-31 09:57:51 UTC
berkeley db 4.6.19 has the fix → closing.