[Bug c++/37029] New: Exception from shared library's functions or methods that return float (double, long double) value cannot be caught on HP-UX.

2008-08-05 Thread v dot grikyan at sam-solutions dot net
On HP-UX we clashed with the problem that application falls in coredump if
exception is thrown by the function that returns float (or double) and this
function is placed in shared library.
What is interesting - the same function that returns int (or long, etc) works
correctly.
The example below illustrates it (these sources are also attached).
We are not sure if it's gcc bug and if this bug was already committed but we
can not find it anywhere.
So any help is appreciated.

Sample code:

// -
// File ncelib.hpp
// -
#include 

int lib_func_rInt();
float lib_func_rFloat();


// -
// File ncelib.cpp
// -
#include "ncelib.hpp"

int lib_func_rInt()
{
throw std::exception();
return 0;
}

float lib_func_rFloat()
{
throw std::exception();
return 0.0;
}

// -
// File nceexe.cpp
// -
#include "ncelib.hpp"
#include 

int main()
{

printf("main() {\n");

try 
{
lib_func_rInt();
}
catch (std::exception &) 
{
}

printf("...\n");

try 
{
lib_func_rFloat();
}
catch (std::exception &) 
{
}

printf("}\n");
return 0;
}

// -
// File compile.sh
// -
set -ex

g++ -Wall -save-temps -fPIC -shared -g -D_GLIBCXX_DEBUG -o libncelib.sl
ncelib.cpp
g++ -Wall -save-temps -fPIC -g -D_GLIBCXX_DEBUG -o nceexe nceexe.cpp -L.
-lncelib

// Output sample --
bash-3.2$ gcc -v
Using built-in specs.
Target: hppa2.0w-hp-hpux11.11
Configured with: ../gcc/configure  : (reconfigured) ../gcc/configure  :
(reconfigured) ../gcc/configure
Thread model: posix
gcc version 4.1.2

bash-3.2$ ./compile.sh
++ g++ -Wall -save-temps -fPIC -shared -g -D_GLIBCXX_DEBUG -o libncelib.sl
ncelib.cpp
++ g++ -Wall -save-temps -fPIC -g -D_GLIBCXX_DEBUG -o nceexe nceexe.cpp -L.
-lncelib

bash-3.2$ ./nceexe
main() {
...
terminate called after throwing an instance of 'std::exception'
  what():  St9exception
ABORT instruction (core dumped)


-- 
   Summary: Exception from shared library's functions or methods
that return float (double, long double) value cannot be
caught on HP-UX.
   Product: gcc
   Version: 4.1.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
    AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: v dot grikyan at sam-solutions dot net
GCC target triplet: hppa2.0w-hp-hpux11.11


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37029



[Bug c++/37029] Exception from shared library's functions or methods that return float (double, long double) value cannot be caught on HP-UX.

2008-08-05 Thread v dot grikyan at sam-solutions dot net


--- Comment #1 from v dot grikyan at sam-solutions dot net  2008-08-05 
14:07 ---
Created an attachment (id=16024)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=16024&action=view)
Example that illustrates the problem


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37029



[Bug c++/37029] Exception from shared library's functions or methods that return float (double, long double) value cannot be caught on HP-UX.

2008-08-06 Thread v dot grikyan at sam-solutions dot net


--- Comment #3 from v dot grikyan at sam-solutions dot net  2008-08-06 
09:11 ---
As we understand (looking at gcc sources), sjlj-mechanism can be set only
during building of gcc.
We did not build gcc on our HP-UX system ourselves but looking at output "gcc
-v" it seems it was configured without any parameters

bash-3.2$ gcc -v
Using built-in specs.
Target: hppa2.0w-hp-hpux11.11
Configured with: ../gcc/configure  : (reconfigured) ../gcc/configure  :
(reconfigured) ../gcc/configure
Thread model: posix
gcc version 4.1.2

So gcc build system had to determine configuration automatically.
We found in .../libstdc++-v3/configure

  --enable-sjlj-exceptions
 force use of builtin_setjmp for exceptions
 [default=auto]

Also in .../gcc-4.1.2/libstdc++-v3/libsupc++/eh_throw.cc we see the following
code

#ifdef _GLIBCXX_SJLJ_EXCEPTIONS
  _Unwind_SjLj_RaiseException (&header->unwindHeader);
#else
  _Unwind_RaiseException (&header->unwindHeader);
#endif

and going through debug of our test application we see the call of the function
_Unwind_RaiseException but not _Unwind_SjLj_RaiseException
So we suppose that dwarf2-mechanism is used.

Also we found in the document "Installing GCC"
(http://209.85.135.104/search?q=cache:crNR9x-pALIJ:wwwcdf.pd.infn.it/localdoc/gccinstall.ps.gz+gcc+sjlj+dwarf2+exceptions+option&hl=ru&ct=clnk&cd=28)
the following phrase

"As of GCC 4.1, DWARF2 exception handling is available on HP-UX. It is now the
default.This exposed a bug in the handling of data relocations in the GAS
assembler. The handlingof 64-bit data relocations was seriously broken,
affecting debugging and exception supporton all 'hppa64-*-*' targets. Under
some circumstances, 32-bit data relocations could alsobe handled incorrectly.
This problem is fixed in GAS version 2.16.91 20051125"

In our case 'as --version' prints the following result

bash-3.2$ as --version
GNU assembler (GNU Binutils) 2.18
Copyright 2007 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `hppa2.0w-hp-hpux11.11'.

So it seems GAS version is correct but anyway the test application does not
work...


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37029



[Bug c++/37029] Exception from shared library's functions or methods that return float (double, long double) value cannot be caught on HP-UX.

2008-08-06 Thread v dot grikyan at sam-solutions dot net


--- Comment #5 from v dot grikyan at sam-solutions dot net  2008-08-06 
16:11 ---
Hi Dave,

thank you for your fast reply.
Have we understood correctly - you will try to reproduce this error on your HP
platform?
If yes and if it works on your side - please let us know what patches are
installed on your system.
Thanks in advance.

Valery.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37029



[Bug target/37029] Exception from shared library's functions or methods that return float (double, long double) value cannot be caught on HP-UX.

2008-08-11 Thread v dot grikyan at sam-solutions dot net


--- Comment #7 from v dot grikyan at sam-solutions dot net  2008-08-11 
16:02 ---
Thank you very much for your help.
We'll exploit your advices.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37029