Bug 145829 - Statically linked GCJ-produced executables segfault immediately upon running
Summary: Statically linked GCJ-produced executables segfault immediately upon running
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
(Show other bugs)
Version: 3
Hardware: i386 Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2005-01-21 22:51 UTC by Vesselin Peev
Modified: 2007-11-30 22:10 UTC (History)
2 users (show)

Fixed In Version: gcc-3.4.3-17
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-01-26 09:02:02 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2005:257 normal SHIPPED_LIVE gcc bug fix update 2005-06-09 04:00:00 UTC

Description Vesselin Peev 2005-01-21 22:51:05 UTC
Description of problem:

A simple hello world program compiled with "gcj -static" under a fully
updated (as of Jan 22, 2005) Fedora Core 3 i386 installation gives out
"Segmentation fault" immediately upon running.

Version-Release number of selected component (if applicable):

#gcj -v

Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk
Thread model: posix
gcc version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)

How reproducible:

Write a simple hello world-type program and save as HelloWorld.java --
just main and a System.out.println. Compile with "gcj
--main=HelloWorld HelloWorld.java". Verify that running a.out prints
"Hello, world!" :). Now do it with "gcj -static --main=HelloWorld
HelloWorld.java" and run the new multi-megabyte a.out to confirm the
"Segmentation fault".

Comment 1 Jakub Jelinek 2005-01-24 17:27:54 UTC
Well, static linking is almost always a bad idea and in the Java case even more.
Guess I'll just remove the .a libs for FC4.

The problem is, at link time you don't know what all classes you'll need, and
if you miss one that will be needed (as in this case at least
gnu.gcj.convert.Output_UTF8), it will die miserably.

You can add -Wl,--whole-archive -lgcj -Wl,--no-whole-archive to the link
line and it will work just fine then, just beware that e.g. on x86_64 where
I was trying this even stripped HelloWorld program has 8MB+.

Comment 2 Andrew Haley 2005-01-24 17:33:30 UTC
We should reject -static as an option to gcj.

Comment 3 Jakub Jelinek 2005-01-24 18:11:45 UTC
Well, already not including libgcj.a will effectively mean rejection of -static.


Comment 4 Jakub Jelinek 2005-01-26 09:02:02 UTC
-static is now rejected in gcj and no Java .a included in rawhide gcc.

Comment 5 Tim Powers 2005-06-09 10:57:28 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.


Note You need to log in before you can comment on or make changes to this bug.