Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #85691 > unrolled thread
| Started by | Jivanmukta <jivanmukta@poczta.onet.pl> |
|---|---|
| First post | 2022-07-27 18:32 +0200 |
| Last post | 2022-07-27 20:29 +0300 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.c++
undexpected modification of string array Jivanmukta <jivanmukta@poczta.onet.pl> - 2022-07-27 18:32 +0200
Re: undexpected modification of string array Ralf Fassel <ralfixx@gmx.de> - 2022-07-27 19:20 +0200
Re: undexpected modification of string array Paavo Helde <eesnimi@osa.pri.ee> - 2022-07-27 20:29 +0300
| From | Jivanmukta <jivanmukta@poczta.onet.pl> |
|---|---|
| Date | 2022-07-27 18:32 +0200 |
| Subject | undexpected modification of string array |
| Message-ID | <tbrpb2$2pdoq$1@portraits.wsisiz.edu.pl> |
I have object of my class source_file:
class source_file {
private:
std::wstring source_file_path;
int current_source_line_no;
bool inside_php, start_inside_php;
int num_source_lines, too_long_line_number;
std::vector<std::string> source_lines;
std::vector<std::pair<int, std::string>> tokenized_lines;
std::vector<std::pair<int, std::string>>::const_iterator
current_tokenized_lines_iter;
size_t max_line_len, too_long_line_len, max_found_line_len;
public:
source_file(size_t max_line_length = 0) { // 0 means 'no limit'
max_line_len = max_line_length;
too_long_line_len = 0;
max_found_line_len = 0;
current_source_line_no = -1;
num_source_lines = 0;
current_tokenized_lines_iter = tokenized_lines.end();
too_long_line_number = 0;
inside_php = start_inside_php = false;
}
size_t get_max_found_line_length() const {
return max_found_line_len;
}
size_t get_too_long_line_length() const {
return too_long_line_len;
}
int get_too_long_line_number() const {
return too_long_line_number;
}
bool open(std::wstring in_file_path);
void close() {
source_lines.clear();
tokenized_lines.clear();
too_long_line_len = 0;
max_found_line_len = 0;
num_source_lines = 0;
current_source_line_no = -1;
}
void rewind() { // go to begin of file
current_source_line_no = -1;
current_tokenized_lines_iter = tokenized_lines.begin();
inside_php = start_inside_php = false;
}
bool get_next_line(std::string &line);
bool change_current_line(std::string line, bool ltrim_line);
void ltrim_current_line();
void get_contents(std::vector<std::string> &contents);
bool change_file_with_contents(const std::vector<std::string>
&contents, unsigned int defines_line_num = 0, unsigned int
defines_num_lines = 0);
void remove_magic_str(); void write(std::wstring out_file_path)
const {
std::ofstream out_file(shortwstr2str(out_file_path));
for (std::string line : source_lines) {
out_file << line << std::endl;
}
}
void tokenize_file(std::string token_name_delim_str);
bool get_next_line_with_tokenized(std::string &line, std::string
&tokenized_line);
};
The problem is that in some moment of time source_lines[318] is
unexpectedly modified, I don't know why and when, although the file is
correctly loaded to source_lines[], I mean open() works fine and some
time later get_next_line() returns spoilt string. Conditional
breakpoints don't work (I use VSCodium).
How to find the moment of modification of source_line[318]?
[toc] | [next] | [standalone]
| From | Ralf Fassel <ralfixx@gmx.de> |
|---|---|
| Date | 2022-07-27 19:20 +0200 |
| Message-ID | <ygatu72wjye.fsf@akutech.de> |
| In reply to | #85691 |
* Jivanmukta <jivanmukta@poczta.onet.pl> | The problem is that in some moment of time source_lines[318] is | unexpectedly modified, --<snip-snip>-- | How to find the moment of modification of source_line[318]? Use valgrind or similar. R'
[toc] | [prev] | [next] | [standalone]
| From | Paavo Helde <eesnimi@osa.pri.ee> |
|---|---|
| Date | 2022-07-27 20:29 +0300 |
| Message-ID | <tbrsmf$2itfp$1@dont-email.me> |
| In reply to | #85691 |
27.07.2022 19:32 Jivanmukta kirjutas: > > I have object of my class source_file: [...] > The problem is that in some moment of time source_lines[318] is > unexpectedly modified, I don't know why and when, although the file is > correctly loaded to source_lines[], I mean open() works fine and some > time later get_next_line() returns spoilt string. Conditional > breakpoints don't work (I use VSCodium). > How to find the moment of modification of source_line[318]? If it is well reproducible, then a data breakpoint should work fine. Note that hardware data breakpoints are max 4 or 8 bytes, so you will need to figure out the exact address in the memory which will be illegally modified, and put a data breakpoint on it. > bool inside_php, Last time I used PHP as an in-process library, it wrote over some random foreign memory when initializing itself. It was a bit tricky to cope with as I was not able to compile its sources any more :-S
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c++
csiph-web