473,414 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

seg-fault on vector-auto-reserve

Hi,

I'm holding a vector of boost::filesystem::pathS and a vector of
pointers to them. I use the reserve member function on both to reserve
space for 500 files. That means, for the 501th file added, the vector
will grow to hold 1000 files right?
Well, as soon as this happens I am getting a segmentation fault. I'm
sure this is the reason, because the program crashed when I entered
/usr/bin which holds about 1700 files, and if I change the initial
capacity to 2000 instead, the program won't crash.

I'm totally lost, any idea what could cause the crash?

--
Matthias Kaeppler
Jul 23 '05 #1
2 2082
Matthias Kaeppler wrote:
Hi,

I'm holding a vector of boost::filesystem::pathS and a vector of
pointers to them. I use the reserve member function on both to reserve
space for 500 files. That means, for the 501th file added, the vector
will grow to hold 1000 files right?
Well, as soon as this happens I am getting a segmentation fault. I'm
sure this is the reason, because the program crashed when I entered
/usr/bin which holds about 1700 files, and if I change the initial
capacity to 2000 instead, the program won't crash.

I'm totally lost, any idea what could cause the crash?


I did a segfault backtrace and recognized that it happens in
std::partition invoked on the pointer-vector. Is this, because as soon
as the vector gets resized, all pointers get invalidated?

--
Matthias Kaeppler
Jul 23 '05 #2
"Matthias Kaeppler" <no****@digitalraid.com> wrote...
Matthias Kaeppler wrote:
Hi,

I'm holding a vector of boost::filesystem::pathS and a vector of pointers
to them. I use the reserve member function on both to reserve space for
500 files. That means, for the 501th file added, the vector will grow to
hold 1000 files right?
Well, as soon as this happens I am getting a segmentation fault. I'm sure
this is the reason, because the program crashed when I entered /usr/bin
which holds about 1700 files, and if I change the initial capacity to
2000 instead, the program won't crash.

I'm totally lost, any idea what could cause the crash?


I did a segfault backtrace and recognized that it happens in
std::partition invoked on the pointer-vector. Is this, because as soon as
the vector gets resized, all pointers get invalidated?


Quite possible. Resizing may require reallocation. Reallocation makes
all iterators and references (and pointers) invalid.

V
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Michael | last post by:
Trying to process xml (xml-rpx) with a handler in mod_python crashes mod_python. Previous versions worked fine. Only change is I recompiled with newest versions of Apache, Python, and mod_python....
4
by: hpy_awad | last post by:
What are the reasons of that message ? linker error fixup overflow at 'seg:xxxx' h,target = 'symbol' in module 'module' I am just compiling a small program under Borland C++ ver 3. #include...
7
by: Berk Birand | last post by:
Hi, For an assignement that I have, I have to write a function that is used for duplicating arrays of some objects (called Product). It is supposed to be something similar to strndup, but taking...
4
by: stephenma7 | last post by:
Hi, everybody. I am new here. I have encountered these many problems for the last couple of days. I have Linux Fedora Core 3(Gnu G++ 3.4.2), Linux Fedora Core 2 (Gnu G++ 3.3.3), Red Hat 9 (Gnu...
4
by: a2x | last post by:
Hi, I've fixed this error, but I don't know why it occurs. Do you? Code: #include <stdlib.h> #include <string.h> void another(); int main()
11
by: grid | last post by:
Hi, Many times I have observed that some program which functions properly without optimisation or with debug option dosn't seem to work when optimasation is on or at a higer level.And occasionally...
5
by: Philippe C. Martin | last post by:
Hi, I just installed (compiled) Python 2.4.2 under Suse 10. The following code generates a seg error: import shelve print shelve.open ('test') I assume this has to do with the db behind...
13
by: ralphedge | last post by:
These sorts work fine on 100000 ints but if I go much higher they will both segmentation fault **************************MERGESORT********************* mergesort(int *a, int size) //a is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.