Under what circumstances would closing a istream object (such as
'in.close()') SEGFAULT? 4 1891
On Thu, 22 Jul 2004 15:04:23 -0400 (EDT), Jim Strathmeyer
<no************ @andrew.cmu.edu > wrote: Under what circumstances would closing a istream object (such as 'in.close()') SEGFAULT?
When you have a bug in your program. What else?
All the usual suspects, writing past he end of an array, writing through a
garbage pointer, freeing the same memory twice, etc. etc. All these bugs
can cause anything to happen.
Bugs rarely have any logic. You can rarely say 'well the symptom is this,
therefore the bug must be that', at least that sort of intuition only
comes with much experience.
john
On Thu, 22 Jul 2004, John Harrison wrote: On Thu, 22 Jul 2004 15:04:23 -0400 (EDT), Jim Strathmeyer <no************ @andrew.cmu.edu > wrote:
Under what circumstances would closing a istream object (such as 'in.close()') SEGFAULT?
When you have a bug in your program. What else?
All the usual suspects, writing past he end of an array, writing through a garbage pointer, freeing the same memory twice, etc. etc. All these bugs can cause anything to happen.
Bugs rarely have any logic. You can rarely say 'well the symptom is this, therefore the bug must be that', at least that sort of intuition only comes with much experience.
....right... but why would a SEGFAULT happen inside a library function?
On Thu, 22 Jul 2004 15:24:26 -0400 (EDT) in comp.lang.c++, Jim
Strathmeyer <no************ @andrew.cmu.edu > wrote, ...right... but why would a SEGFAULT happen inside a library function?
Most typical reason... because the structures used by the library to
manage the memory free store had been clobbered by any of the kinds of
activity that John mentioned. When trying to return the released memory
formerly used by your stream, the library encounters a pointer to outer
space.
"Jim Strathmeyer" <no************ @andrew.cmu.edu > wrote in message
news:Pi******** *************** ***********@uni x43.andrew.cmu. edu... On Thu, 22 Jul 2004, John Harrison wrote:
On Thu, 22 Jul 2004 15:04:23 -0400 (EDT), Jim Strathmeyer <no************ @andrew.cmu.edu > wrote:
Under what circumstances would closing a istream object (such as 'in.close()') SEGFAULT?
When you have a bug in your program. What else?
All the usual suspects, writing past he end of an array, writing through
a garbage pointer, freeing the same memory twice, etc. etc. All these bugs can cause anything to happen.
Bugs rarely have any logic. You can rarely say 'well the symptom is
this, therefore the bug must be that', at least that sort of intuition only comes with much experience.
...right... but why would a SEGFAULT happen inside a library function?
If you've done something 'wrong' (such as some of the things
John mentioned) *anywhere* in your program, it could easily
cause corruption anywhere else in your program, including inside
library code. IMO the best way for tracking down a bug whose source
is unknown and/or not easily reprocible is careful, methodical
testing, and selective removal of (relatively large) sections of
code, testing each version. One a large section has been identified
as the culprit, start removing smaller sections of that section.
Good debuggers also help much.
-Mike This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Thomas Matthews |
last post by:
Hi,
In some threads, some people mentioned that variable initialization is
best performed in an initialization list.
Is there a way to initialize a variable from an istream in an
initialization list?
Example:
class My_Class
{
|
by: matthurne |
last post by:
I'm doing a chapter 12 exercise from Accelerated C++ ... writing a
string-like class which stores its data in a low-level way. My class,
called Str, uses a char array and length variable. I've gotten
everything working that I want working so far, except for
std::istream& operator>>(std::istream&, Str&)
The way my Str class manages itself of course requires that the size
of the char array to store is known when it is allocated. The...
|
by: Randy |
last post by:
Is there any way to do this? I've tried tellg() followed by seekg(),
inserting the stream buffer to an ostringstream (ala os << is.rdbuf()),
read(), and having no luck.
The problem is, all of these methods EXTRACT the data at one
point or another. The other problem is there appears to be NO
WAY to get at the actual buffer pointer (char*) of the characters
in the stream. There is a way to get the streambuf object
associated with the...
|
by: Gianni Mariani |
last post by:
What I would like to do is read bytes from a stream, any number and any
time. I would like it to wait until there are any bytes to read.
I want the exact same functionality as cstdio's "fread" but in a
std::istream.
It appeared at first that "readsome" would do exactly what I wanted but
it appears not to work very well at all (at least with gcc!). When
reading from a named pipe on gcc, it returns immediately - no errors,
just...
|
by: KWienhold |
last post by:
I'm currently writing an application (using Visual Studio 2003 SP1 and
C#) that stores files and additional information in a single compound
file using IStorage/IStream.
Since files in a compound file aren't really useful to a user, I use
the IStream::Read function together with a StreamWriter to extract
single files from my compound document.
When I first tested these functions everything seemed to work fine (and
basically, it does),...
| |
by: Colonel |
last post by:
It seems that the problems have something to do with the overloading of
istream operator ">>", but I just can't find the exact problem.
// the declaration
friend std::istream & operator>(std::istream & in, const Complex & a);
// the methods correspond to the friend
std::istream & operator>(std::istream & in, const Complex & a)
{
std::cout << "real: ";
|
by: Kourosh |
last post by:
Hi all,
I'm trying to call a COM function from C#
The function gets a paramter of type IStream in C++. I've found the
type System.Runtime.InteropServices.ComTypes.IStream, however I'm not
sure how to create an instance of it to pass as the parameter. Anyone
can tell me what to do? i dont know what to pass in as the parameter,
because I'm not sure how to create an instance of the "IStream" object
in C#
|
by: Ralf |
last post by:
Hallo,
I'm trying to call a COM function from C#.
The function has a parameter from the type array of IStream* (IStream**).
The COM component (out-proc-server (.exe)) has the following code:
(C++)
STDMETHODIMP CIntf::SendFiles(int noOfStreams, IUnknown** dataStreams)
{
|
by: admb600 |
last post by:
I wouldn't normally beg but my dissertation is due in, in a couple of weeks and I am in way over my head here.. Fixing this issue will make or break the project and my degree..
The goal is to extract the raw html from Internet Explorer using a BHO. When accessing the HTML via the mshtml.HTMLDocument (DOM) object you get a version of the HTML that is different from what you see when you "right click --> view source". IE changes the code for...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |