|
Boost Users : |
Subject: Re: [Boost-users] Segmentation fault when throwing exception?
From: Germán Diago (germandiago_at_[hidden])
Date: 2011-05-17 09:11:11
2011/5/17 Germán Diago <germandiago_at_[hidden]>:
>> To see what BOOST_THROW_EXCEPTION does exactly, read the following:
>> http://www.boost.org/doc/libs/1_46_1/libs/exception/doc/BOOST_THROW_EXCEPTION.html
>> http://www.boost.org/doc/libs/1_46_1/libs/exception/doc/throw_exception.html
>
> I already read it. But I can't figure out why it segfaults at all. I
> have no idea.
>
I found the error. It had nothing to do with the macro. But I don't
know wether this is a bug or not in class shared_ptr:
I have a shared_ptr<FILE> f(fopen(file_that_doesnt_exists, "rb"),
&fclose); call.
If fopen returns null I think that the custom deleter is still called
even if the class was constructed with a null pointer.
Maybe I should make sure myself that fopen doesn't return NULL,
because, anyway when you construct a shared_ptr
you are passing a valid resource and it is not checked.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net