[Bug ada/19526] New: Windows errorcodes wrong in Ada when tasking
b201 at passagen dot se
gcc-bugzilla@gcc.gnu.org
Wed Jan 19 08:39:00 GMT 2005
BUG REPORTS HAVE TO CONTAIN AT LEAST THE FOLLOWING INFORMATION IN ORDER TO BE
USEFUL:
the exact version of GCC, as shown by "gcc -v";
gcc -v
Reading specs from C:/languages/MinGW/bin/../lib/gcc/mingw32/3.4.2/specs
Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as --
host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --
enable-languages=c,c++,f77,ada,objc,java --disable-win32-registry --disable-
shared --enable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x -
-enable-java-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-
synchronization --enable-libstdcxx-debug
Thread model: win32
gcc version 3.4.2 (mingw-special)
THE SYSTEM TYPE;
Windows 2000 Professional, Windows 2000 Server, Windows 2003
THE OPTIONS WHEN GCC WAS CONFIGURED/BUILT;
Binaries used from minGW containing
MinGW version 3.2.0 contains the following list of packages:
gcc-ada-3.4.2.tar.gz
gcc-core-3.4.2.tar.gz
gcc-g++-3.4.2.tar.gz
gcc-g77-3.4.2.tar.gz
gcc-java-3.4.2.tar.gz
gcc-objc-3.4.2.tar.gz
binutils-2.15.91-20040904-1
mingw-runtime-3.6
w32api-3.2
gdb-5.2.1-1
mingw32-make-3.80.0-3
mingw-utils-0.3.tar.gz
But this bug also applies to the 'official' gnat 3.15p from ACT
THE EXACT COMMAND LINE PASSED TO THE GCC PROGRAM TRIGGERING THE BUG
(not just the flags passed to gnatmake, but gnatmake prints the parameters it
passed to gcc)
C:\Temp>gnatmake socket_connect.adb
gcc -c socket_connect.adb
socket_connect.adb:3:18: warning: "Gnat.Sockets.Thin" is an internal GNAT unit
socket_connect.adb:3:18: warning: use of this unit is non-portable and
version-d
ependent
gnatbind -x socket_connect.ali
gnatlink socket_connect.ali
A COLLECTION OF SOURCE FILES FOR REPRODUCING THE BUG, PREFERABLY A MINIMAL SET
(SEE BELOW);
with Text_Io;
with Gnat.Sockets;
with Gnat.Sockets.Thin;
with Ada.Exceptions;
procedure Socket_Connect is
Socket : Gnat.Sockets.Socket_Type;
Address : Gnat.Sockets.Sock_Addr_Type;
Error : Integer := 0;
--------------------------------------------------
task type Run_Once is
entry Execute;
end Run_Once;
--------------------------------------------------
task body Run_Once is
begin
select
accept Execute do
text_io.put_line("Task running, Execute!");
end Execute;
or
terminate;
end select;
end Run_Once;
--------------------------------------------------
begin
declare
TmpTask : Run_Once;
begin
TmpTask.Execute;
end;
text_io.put_line("Startup sockets");
Gnat.Sockets.Initialize;
text_io.put_line("Get a socket");
Gnat.Sockets.Create_Socket (Socket);
text_io.put_line("Try to connect!");
Address.Addr := Gnat.Sockets.Inet_Addr("127.0.0.1");
Address.Port := 8000;
Gnat.Sockets.Connect_Socket (Socket, Address);
text_io.put_line("Connected!");
text_io.put_line("Close socket!");
Gnat.Sockets.Close_Socket (Socket);
text_io.put_line("Shutdown sockets!");
Gnat.Sockets.Finalize;
text_io.put_line("Done!");
exception
when E: others =>
Text_IO.Put_Line(Ada.Exceptions.Exception_Name (E) & ": " &
Ada.Exceptions.Exception_Message (E));
Error := Gnat.Sockets.Thin.Socket_Errno;
Text_IO.Put_Line(Integer'Image(Error) & " - " ) ; --&
-- Gnat.Sockets.Thin.Socket_Error_Message (Error));
Text_IO.Put_Line("Resolve_Exception" & " - " &
Gnat.Sockets.Error_Type'Image(Gnat.Sockets.Resolve_Exception(E)));
Gnat.Sockets.Finalize;
end Socket_Connect;
A DESCRIPTION OF THE EXPECTED BEHAVIOR;
I'd like an output like this:
C:\Temp>socket_connect
Task running, Execute!
Startup sockets
Get a socket
Try to connect!
GNAT.SOCKETS.SOCKET_ERROR: [10061] Connection refused
10061 -
Resolve_Exception - CONNECTION_REFUSED
Note the second last line, printed by a call to
Gnat.Sockets.Thin.Socket_Errno.
I get the behavior when I comment out the task type.
(well not the 'Task running, Execute' of course)
A DESCRIPTION OF ACTUAL BEHAVIOR.
C:\Temp>socket_connect
Task running, Execute!
Startup sockets
Get a socket
Try to connect!
GNAT.SOCKETS.SOCKET_ERROR: [10061] Connection refused
0 -
Resolve_Exception - CONNECTION_REFUSED
Note the second last line, printed by a call to
Gnat.Sockets.Thin.Socket_Errno.
This time there's no error!
This behavior occurs when any task at all is involved. If I write my
own socket biding, and call WSAGetLastError
(as Gnat.Sockets.Thin.Socket_Errno does)
I still have this behavior. So I can recognize a socketerror,
via the fact that c-socket function return -1 on error but
NOT find the reason, unless I use Gnat.sockets, and mask the error out from
the exception, which breaks socket code not written unsing Gnat.Sockets
/Björn
--
Summary: Windows errorcodes wrong in Ada when tasking
Product: gcc
Version: 3.4.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: ada
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: b201 at passagen dot se
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19526
More information about the Gcc-bugs
mailing list