Bug 145829 - Statically linked GCJ-produced executables segfault immediately upon running
Statically linked GCJ-produced executables segfault immediately upon running
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
3
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-01-21 17:51 EST by Vesselin Peev
Modified: 2007-11-30 17:10 EST (History)
2 users (show)

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


Attachments (Terms of Use)

  None (edit)
Description Vesselin Peev 2005-01-21 17:51:05 EST
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
--host=i386-redhat-linux
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 12:27:54 EST
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 12:33:30 EST
We should reject -static as an option to gcj.
Comment 3 Jakub Jelinek 2005-01-24 13:11:45 EST
Well, already not including libgcj.a will effectively mean rejection of -static.

http://people.redhat.com/drepper/no_static_linking.html
Comment 4 Jakub Jelinek 2005-01-26 04:02:02 EST
-static is now rejected in gcj and no Java .a included in rawhide gcc.
Comment 5 Tim Powers 2005-06-09 06:57:28 EDT
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.

http://rhn.redhat.com/errata/RHBA-2005-257.html

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