Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Content-Type: text/plain; charset="iso-8859-1" x-gfisavedcharset: Windows-1252 Content-Transfer-Encoding: 7bit X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: From: "Bruce Adams [TEPG Sunbury]" To: Subject: Exception: STATUS_PRIVILEGED_INSTRUCTION occurs before main is executed. Date: Mon, 3 Mar 2003 10:12:00 -0000 MIME-Version: 1.0 X-OriginalArrivalTime: 03 Mar 2003 10:13:09.0875 (UTC) FILETIME=[7DD76C30:01C2E16D] Hi, I have lately been having real problems with vanilla gcc 3.2 generating executables that crash. Its manifestation does not seem to follow an obvious pattern and changing the options to gcc (e.g. -ggdb versus -gstabs or no -g at all) does not make any difference. Does anybody have any idea why this happens? And more importantly what I can do about it. See partial stack trace below: 375 1393032 [main] TestObject 992 fhandler_base::set_flags: filemode set to bi nary 1790 1394822 [main] TestObject 992 fhandler_console::open: opened conin$ 0x7, c onout$ 0x1B 12213 1407035 [main] TestObject 992 fhandler_console::output_tcsetattr: 0 = tcse tattr (,A020018) (ENABLE FLAGS 3) (lflag 107 oflag 9) 309 1407344 [main] TestObject 992 dtable::init_std_file_from_handle: fd 2, han dle 0xB 260 1407604 [main] TestObject 992 dll_crt0_1: user_data->main 0x4010AC 769 1408373 [main] TestObject 992 handle_exceptions: In cygwin_except_handler exc 0xC0000096 at 0x401072 sp 0x22FEBC 311 1408684 [main] TestObject 992 handle_exceptions: In cygwin_except_handler sig = 4 at 0x401072 251 1408935 [main] TestObject 992 handle_exceptions: In cygwin_except_handler calling 0x0 1444909 [main] TestObject 992 handle_exceptions: Exception: STATUS_PRIVILEGED_IN STRUCTION 35974 1444909 [main] TestObject 992 handle_exceptions: Exception: STATUS_PRIVILE GED_INSTRUCTION 2257 1447166 [main] TestObject 992 try_to_debug: debugger_command '' The simplest way to reproduce the problem is to have a main function in a file with a .h of the same name as below. If main is moved to a another file and Compiled separately the exception does not occur. In more complicated programs however, the solution is not obvious. TestObject.h ============ typedef unsigned long tetrabyte; class TestObject { private: tetrabyte oTestData; public: TestObject(void); }; //TestObject TestObject.cpp ============== #include "TestObject.h" TestObject::TestObject(void): oTestData(0) { }; #ifdef LINT #define GCC_UNUSED #else #define GCC_UNUSED __attribute__((unused)) #endif #ifdef MAIN int main(int /*argc*/,char** /*argv*/) { TestObject A GCC_UNUSED; return 0; } //main #endif Test.cpp ======== #include "TestObject.h" #ifdef LINT #define GCC_UNUSED #else #define GCC_UNUSED __attribute__((unused)) #endif int main(int /*argc*/,char** /*argv*/) { TestObject A GCC_UNUSED; return 0; } //main Makefile ======== all: Test TestObject TestObject2.o: TestObject.cpp TestObject.h gcc -c -x c++ $< -o $@ TestObject.o: TestObject.cpp TestObject.h gcc -c -x c++ -DMAIN $< -o $@ TestObject.exe: TestObject.o gcc $< -o$@ -lstdc++ TestObject: TestObject.exe .\TestObject.exe Test.o: Test.cpp gcc -c -x c++ $< -o $@ Test.exe: Test.o TestObject2.o gcc $< TestObject2.o -o$@ -lstdc++ Test: Test.exe .\Test.exe == It seems to me that having main in TestObject.cpp should be perfectly legal so why doesn't it work? How can I prevent this error in the general case? Regards, Bruce A. ============================================================================ Any opinions expressed in this e-mail are those of the individual and not necessarily those of Tyco Safety Products. Any prices for the supply of goods or services are only valid if supported by a formal written quotation. This e-mail and any files transmitted with it, including replies and forwarded copies (which may contain alterations) subsequently transmitted from Tyco Saftey Products are confidential and solely for the use of the intended recipient. If you are not the intended recipient or the person responsible for delivery to the intended recipient, be advised that you have received this e-mail in error and that any use is strictly prohibited. In this event, please notify us via e-mail at 'helpdesk DOT tepg AT tycoint DOT com' or telephone on 0121 255 6499 and then delete the e-mail and any copies of it. ============================================================================ -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/