Watch, Follow, &
Connect with Us

Please visit our new home

Public Report
Report From: Kylix/Compiler/C++/Back-end/Code Generation / Optimization    [ Add a report in this area ]  
Report #:  2606   Status: Open
Array in shared object causes runtime error
Project:  Kylix Build #:  4.186
Version:    3.0 Submitted By:   Felix Edgar Klee
Report Type:  Crash / Data loss / Total failure Date Reported:  10/6/2002 3:43:59 PM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    Kylix C++ IDE Internal Tracking #:   155948
Resolution: None  Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (3 Total Ratings)
4.00 out of 5
Total Votes: 8
When you create a shared object that contains two classes A and B and in B an array A[] is created then an executable linked to that library might return the error message
  FelixB 1
  Fatal runtime error:
Steps to Reproduce:
1. "tar xfj" the attachment
2. Setup the Kylix command line environment:
   source <your-kylix-install-path>/bin/kylixpath
3. Enter the directory "example"
4. Run make
5. Execute felixmain and you will probably receive the following error message:
     FelixB 1
     Fatal runtime error:

The structure of the project is as follows:
o The files felixa.cpp and felixb.cpp form a shared library
  Both files have only a few lines of trivial code.
o The file felixmain.cpp is compiled and linked to to form
  felixmain. felixmain.cpp is also very simple.
The easiest and safest workaround for this problem is probably to use std::vector or std::valarray instead of the array in felixb.cpp.

However, if you need an array that is compatible with an intrinsic array, you can use the workaround in the file felixb-workaround.cpp which is included in the attachment. To build the project with this workaround enabled do "make all-workaround". The resulting executable is felixmain-workaround which should produce the following output:
  FelixB 1
  FelixB 2
Not that some people have noted that this workaround might be problematic under certain circumstances / with certain compilers.

Update: On nntp://borland.public.cppbuilder.language.cpp Chris Uzdavinis [TeamB] posted a modified version of my above workaround which corrects several important fixes. You can download his posting as attachment chris-uzdavinis-posting.txt.

Update 2: According to Thomas Maeder [Team B] the above workaround provided by Chris Uzdavinis may cause alignment problems. His clever solution to the problem is contained in the attachment thomas-maeder-posting.txt.

Rowan Wing at 11/1/2002 10:47:57 AM -
Re: Workaround.
Note that STL may not be stable in a .so built with Kylix. See bug 2569

Server Response from: ETNACODE01