Could someone please look through my code here ->https://github.com/MemeManMemes/termsheets/blob/main/termsheets.cpp and tell me why a get a segfault whenever I try to set the sheet to be 1 x 7 or 1 x 8?
#I need help (quite dire)
25 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
Try using address sanatizers
How To Use Sanitizers
Sanitizers are tools which generate additional code in your program that can catch many common programming mistakes,
such as:
General Advice
Not all sanitizers can be combined, but when they can, use e.g.:
-fsanitize=address,undefined to combine them.
Always compile with debug info to get line numbers, variable names, etc.
GCC 4.8+
- -fsanitize=address
- -fsanitize=undefined
- -fsanitize=thread
- -g for debug info
clang 3.1+
- -fsanitize=address
- -fsanitize=undefined
- -fsanitize=thread
- -fsanitize=memory
- -g for debug info
MSVC 19.27+ and VS 2019 16.9+
- -fsanitize=address
- -Zi for debug info
Sample Program
int main(void) {
int x;
return x;
}
`-fsanitize=memory -g` Output
SUMMARY: MemorySanitizer: use-of-uninitialized-value /tmp/test.cpp:3:5 in main
Exiting
(3:5is line and column ofreturn)
Note: The sanitizer lists for GCC and clang are not exhaustive
did you also try the undefined sanitizer?
How do you change the dimensions?
CTRL + e
So I used address santizier and got this
somewhere at this line
for (uint8_t i = 0; i < size(cols); i++) if (uint16_t(text[(i * cols.size()) + x].length()) < uint16_t(cols[x] - 1)) j++;
you are reading invalid memory
change the [] to .at(), I got this
RRADIX TERMSHEETS - 01 rows x 07 columns
______________________________________________________________________
_________._________|_________|_________|_________|_________|_________|
X: 0
Y: 0
terminate called after throwing an instance of 'std::out_of_range'
what(): deque::_M_range_check: __n (which is 7)>= this->size() (which is 7)
thx cuhs
what do you mean change [] to .at()? Like from [x] to .at(x)?
@spare tinsel
This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.