gcj 4.2 trunk FormatMessage (with MESSAGE_FROM_SYSTEM flag) doesn't work on network messages on win98. This causes lpMsgBuf to be null, and will cause a seg fault later.
Example code: new Socket("127.0.0.1", 7777); (or some host/port that denies the connection). I believe that one could explicitely try to use MESSAGE_FROM_HANDLE and GetModuleHandle("wininet.dll") in the FORMATMESSAGE call. A quicker option was to get the inevitable 317 (ERROR_MR_MID_NOT_FOUND) from a followup GetLastError() call and fill the lpMsgBuf with that which is what I did to make it work for me. Index: win32.cc =================================================================== --- win32.cc (revision 114200) +++ win32.cc (working copy) @@ -193,7 +193,7 @@ FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; - FormatMessage (dwFlags, + DWORD fRet = FormatMessage (dwFlags, NULL, (DWORD) nErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), @@ -201,6 +201,17 @@ 0, NULL); + if (!fRet) + { + fRet = FormatMessage (dwFlags, + NULL, + (DWORD) GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR) &lpMsgBuf, + 0, + NULL); + } + jstring ret; if (lpszPrologue) { -- Summary: win32.cc: FormatMessage fails on win98 for network messages Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libgcj AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: r_ovidius at eml dot cc http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27797