delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/06/30/07:42:36

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-3.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,SARE_FREE_WEBM_RuMail,SPF_SOFTFAIL,T_TO_NO_BRKTS_FREEMAIL
X-Spam-Check-By: sourceware.org
From: Dmitry Katsubo <dma_k AT mail DOT ru>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.9) Gecko/20100502 Shredder/3.0.5pre
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Exception handling: cannot correctly catch the exception
Message-ID: <4C2B2D99.7020203@mail.ru>
Date: Wed, 30 Jun 2010 13:42:17 +0200
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

--------------030405030704020707070703
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=windows-1251

Dear CygWin users & developers!

Please, give me a hint, how to deal with the following problem
correctly. I have some code, that calls GraphicsMagick function and I
want to catch the exception thrown. Unfortunately, this does not happen,
when I compile the code with CygWin:

C:\test\bugs\cygwin_exception_test> cygwin_exception_test.exe
terminate called after throwing an instance of 'Magick::ErrorFileOpen'
  what():  Magick: Unable to open file (aaaa) reported by
/pub/cygports/graphicksmagick/GraphicsMagick-1.3.7-2/src/GraphicsMagick-1.3.7/magick/constitute.c:8268
(ReadImage)
      1 [sig] cygwin_exception_test 9488 open_stackdumpfile: Dumping
stack trace to cygwin_exception_test.exe.stackdump

For Debian it works as expected:

root AT debian:~/test/bugs/cygwin_exception_test# ./cygwin_exception_test
Cannot open file 'aaaa'

Or is it a GCC-specific problem? Any workarounds?

Additional information:
* Cygwin setup v2.697, gcc-g++-3.4.4-999, libGraphicsMagick3-1.3.7-2
* Debian squeeze, gcc-4.4.4-5, libgraphicsmagick++3-1.3.12-1

-- 
With best regards,
Dmitry

--------------030405030704020707070703
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
 name="Makefile"
Content-Disposition: attachment;
 filename="Makefile"

CXX		:= g++
LD		:= g++
RM		:= /bin/rm

CXXFLAGS	:= -g3 -O2
CPPFLAGS	:= -I/usr/include/GraphicsMagick
LDFLAGS		:= -L/usr/lib -L/usr/lib/X11

LIBS		:= -lGraphicsMagick++ 

.PHONY: all

.SUFFIXES: .c .cpp

OBJ		= cygwin_exception_test.o

all: cygwin_exception_test

cygwin_exception_test: $(OBJ)
	$(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)

clean:
	$(RM) -f *.o cygwin_exception_test

--------------030405030704020707070703
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
 name="cygwin_exception_test.cpp"
Content-Disposition: attachment;
 filename="cygwin_exception_test.cpp"

#include <Magick++.h>

#include <string>
#include <iostream>

using namespace std;

int main(int argc, char **argv) {
	string fileName = "aaaa";
	string type;

	Magick::InitializeMagick(*argv);

	try {
		Magick::Image image;
		image.ping(fileName);
		type = image.magick();
	} catch (...) {
		cerr << "Cannot open file '" << fileName << "'" << endl;
		exit(1);
	}

	cerr << "File type is '" << type << "'" << endl;

	return 0;
}


--------------030405030704020707070703
Content-Type: text/plain; charset=us-ascii

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
--------------030405030704020707070703--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019