c,pointers,struct,segmentation-fault,runtime-error
Your array dimensions are wrong. From the contest page: Input Specification The input contains several test cases. Each test case consists of an integer n. You may assume that 1<=n<=3000. A zero follows the input for the last test case. Output Specification For each test case specified by n output...
c,char,segmentation-fault,user-input,scanf
I'm not saying that it cannot be done using scanf(), but IMHO, that's not the best way to do it. Instead, use fgets() to read the whole like, use strtok() to tokenize the input and then, based on the first token value, iterate over the input string as required. A...
c,pointers,segmentation-fault,malloc,dynamic-memory-allocation
The problem in your code is if( first==NULL){ first->next=new_s; if first is NULL, you should not dererefence it. It is logically wrong, and invokes undefined behaviour. I think, what you want instead, is something like (pseudo-code) if(first == NULL){ first = new_s; first->next = NULL; That said, current->next=new_s; current=new_s; also...
Your code requires some fixes: Style and formatting, the code must be beautiful, easy on the eyes. Do not use malloc() when you don't need to. Do not use pointer arithmetic notation when you can use index notation. Always check the return values of functions The actual problem: you iterate...
matrix,segmentation-fault,fortran,derived-types
After narrowing down the issue to using numbers vs. variables of those same numbers, it was discovered that Fortran doesn't like assigning a matrix to a matrix of different dimensions even if it fit inside. This was weird because smaller values of M, N, and Nblock got around the issue...
c++,segmentation-fault,shared-ptr,raw-pointer
The code in your question contains 2 conflicting definitions of p. I'm assuming you meant to post something like int* p = new int(10); std::shared_ptr<int> p1(p); delete p; When the shared_ptr goes out of scope and its reference count falls to zero it will attempt to delete p;, leading to...
php,regex,svg,segmentation-fault,preg-replace
Use the PHP DOM functions to parse XML files. There is a good reason, why you shouldn't use RegEX to parse XML :-) Since you are looking for all <g ...></g> tags, you can do this like this: $xdoc = new DOMDocument; // load your .svg $xdoc->Load('0057b8.svg'); // get all...
c++,segmentation-fault,chdir,unistd.h
You have recursive, unterminated behaviour in Your code. This overflows the stack. Try to insert breakpoint in void chdir(std::string path) and see what happens. You will see that the function chdir calls itself, and in turn calls itself again, and again and... well, segmentation fault. Also, try to see what...
So I suspect that your Seg Fault may be coming from your last for loop. for( i=i+7; storage[i] != '<'; j++ ){ title[j] = storage[i]; } You aren't updating the value for i in this loop, since, if you wanted to, I believe it would need to be right next...
c++,segmentation-fault,sdl-2,signed-integer
First of all, bools don't default to anything in C++, you need to initialize them. The fact that they appear to always be true is that they're byte in size. Which means they have a size between 0 and 255 inclusive. Only 0 would mean false so its a 255...
c,linked-list,segmentation-fault,postfix-notation
Given this declaration ... char temp[256][256]; ... the loop termination condition here is wrong: for (int i = 0; temp[i]; ++i) { C multi-dimensional arrays are not Java-style arrays of array references. They are arrays of actual arrays. The expression temp[i] will not be false when i exceeds the number...
c++,design-patterns,vector,segmentation-fault,copy-constructor
This may not solve all of your issues, but one thing you should do is to have your TCPClient pointer as a std::shared_ptr instead of a raw pointer. Given your description, you are indeed sharing the pointer between instances due to your usage of std::vector<ConcreteResynthesis>. You also mentioned that you...
c,segmentation-fault,command-line-arguments,getopt,getopt-long
You have to terminate the longopts array with an entry that is all zeros, otherwise getopt_long doesn't know when it ends. Your code is crashing because getopt_long is just iterating through random memory at that point because it has fallen off the end of longopts. struct option longopts[] = {...
c++,c,pointers,segmentation-fault,binary-search-tree
Since searchSpecific may return NULL, you need to protect your code from it, and check x before accessing one of its members: tree *x=searchSpecific(root,f); if (x != NULL && x->left) ...
c,arrays,function,random,segmentation-fault
In your code, strncpy(argv[i], token, strlen(token)); usage is wrong. You need to copy the terminating null byte also. As we can see from the man page of strncpy() The strncpy() function is similar, except that at most n bytes of src are copied. Warning: If there is no null byte...
c,graph,segmentation-fault,edge,adjacency-matrix
Your initialization function is initializing the matrix incorrectly: g->mat = calloc(max, sizeof(double*)); for (i = 0; i < max; i++) g->mat = calloc(max, sizeof(double)); Note that each iteration of the loop is recording the resulting pointer in the same (wrong) place: g->mat. The quickest way to fix it would be...
c++,arrays,vector,segmentation-fault
You have a vector nested inside of a vector. Note the term nested. That implies that you need a nested loop of some kind to access the inner-most vector. Let's have a simple example: std::vector<std::vector<AObject*>> vect; //... std::vector<AObject*> inner = {new AObject, new AObject, new AObject}; //... vect.push_back(inner); vect.push_back(inner); vect.push_back(inner);...
There are quite a few problems here. In no particular order: you're double-freeing output (in the case where you find a string). That's highly likely to provoke a segfault, although not necessarily at the point of the second call to free. You're also freeing bytes even when it is not...
c,assembly,linker,segmentation-fault
In gdb you get SIGSEGV like this: Program received signal SIGSEGV, Segmentation fault. fibonacci () at f1.S:6 6 push %rax What's more interesting is your backtrace (end of it): (gdb) backtrace -10 #1048280 0x00007fffffffe6e0 in ?? () #1048281 0x000000000040056d in more () at f1.S:28 #1048282 0x00007fffffffe7fe in ?? () #1048283...
I have built and executed your code with your suggested data, and it executes without error. However, you do not check that the call to fopen() is successful, and if fp is not a valid open file pointer, it does indeed abort. I suspect in that case that the file...
c++,c,arrays,pointers,segmentation-fault
In your code, change for (int i=0; argc; i++){ to for (int i=0; i < argc; i++){ Otherwise, there is apparently no conditional check for the for loop (argc will be >= 1 and unchanged, usually), transforming it into an infinite loop. FWIW, this unbound increment of i causes testArray[i]...
c,segmentation-fault,memset,invalid-argument
If you want to set each byte of aiorp to the ASCII value of 'a', your first varaiant: memset((void *) aiorp, 'a', sizeof(struct aiocb)); is good. (You don't need the cast to void *, though, and could rewrite the size to sizeof(*aiorp) to follow a common pattern.) But why do...
Compare your loop bound checking to your indexing - they aren't the same. (I believe you meant to write i*prime[j]<N in your for loop.)
c,arrays,struct,segmentation-fault,segment
As far as _t-suffixed identifiers go, according to the C standard they're reserved for the implementation (e.g. your compiler, and/or your standard library). It's very possible that your implementation already has a date_t type, and your code might be causing some kind of mischief. If you wish to avoid subtly...
I was trying to debug your code using gdb and it gave me a segfault at line mpz_inits(l, rand). Then I modified that line and now it does not give a segfault. I will see if I can find a reason for the segfault. #include <iostream> #include "gmp.h" void makeprime...
Compile the program with the -g option g++ -g -o file1 file2.cpp Then execute the executable created with gdb. gdb file1 Once you see the seg fault issue bt, this will give you the stack. frame <frame number> you can see the details about the particular stack. Happy debugging....
c,debugging,segmentation-fault,gdb
Most likely, in your case, debug symbols are not present in the binary. That is why, gdb is not able to read the debugging info and display them. Re-compile your code, with the debugging enabled. Example: for gcc, use the -g options....
c++11,linked-list,segmentation-fault,dynamic-programming
for(int i=0;i<k;i++) { while(!dlist[k].empty()) std::cout<<(dlist[k]).pop_back()<<" "; std::cout<<std::endl; } Is not using the iterator i. It should be: for(int i=0;i<k;i++) { while(!dlist[i].empty()) std::cout<<(dlist[i]).pop_back()<<" "; std::cout<<std::endl; } Since dlist is an array of size k, the original code produces an out-of-bounds access. Since the aforementioned loop makes every list in the...
//X int num = 5; int *ptr; ptr = # For the above, the int value "num" is allocated on stack, or in program data segment so it has an address. Lets pretend it was assigned by the compiler the address 0x12345678. You create an int* ptr. This also has...
c++,segmentation-fault,omnet++,inet
You are getting this error because you are trying to dereference a Null pointer. You are getting a Null pointer because the module name "xyz[123]" given to getSubmodule does not exist. It does not exist because the number in square brackets is not part of the submodule name, but its...
You do not check for the return of strtok_r, which can be NULL and therefore crash atoi. And in this case: temp2 = strtok_r(temp1, ".", &saveptr2) ; operand1 = atoi(strtok_r(NULL, ".", &saveptr2)) ; ...you seem to be looking for two consecutive points? Such as 5.123.723? If there is only one,...
c++,segmentation-fault,multimap,cc
You allocate space for one character... this->key_manager[this->total_accounts] = new (nothrow) char; ...then copy many... strcpy(key_manager[this->total_accounts],acc.name); You should use std::string and std::vector, and avoid new and const char* in multimap keys: you'll be massively more likely to avoid bugs (including memory leaks, and especially if you have exceptions)....
c,arrays,string,segmentation-fault,scanf
In your code, char * n = ""; makes n point to a string literal which is usually placed in read-only memory area, so cannot be modified. Hence, n cannot be used to scan another input. What you want, is either of below a char array, like char n[128] =...
c,arrays,segmentation-fault,initialization,int
In your code, int i is an automatic local variable. If not initialized explicitly, the value held by that variable in indeterministic. So, without explicit initialization, using (reading the value of ) i in any form, like array[i] invokes undefined behaviour, the side-effect being a segmentation fault. Isn't it automatically...
c++,segmentation-fault,coredump
As you've indicated yourself, the size of A (tm) is 3371 x 3371. The file REL.txt contains numbers like 3383 (line 138 in the file) which are larger than the dimensions of A. This makes you reach out of bounds in this part, as indicated by the debugger: for(i=0;i<div;i+=2) {...
c,string,segmentation-fault,malloc,dynamic-memory-allocation
Point 1 for (i = 0; input[i] != ','; i++){ is unsafe. if your input does not contain , you'll be overrunning memory. Instead use something like int len = strlen(input); for (i = 0; (input[i] != ',') && len ; i++, len--){ Point 2 in C, we have 0...
You close the connection using mysql_close(connect) but not sure if you reopen the connection before querying again? Check here when you close it the handle is also closed. Also check your mysql database if you have any null values in it. ...
c,segmentation-fault,char-pointer
Because you do not allocate any memory to str before using it in your scanf(). You need to allocate some memory with malloc() Both your codes exhibit Undefined Behavior as you try to access unsafe memory. ...
You cant use the indexing of vector or [] unless you have already initialized that index by declaring size or by vec.push_back() method! Refer to these two pieces of code for clarification This code will not run (segmentation error): int main() { vector<int> a; //not initialized so cant be indexed...
Let me break down a debugging session for you, but in future you better do that yourself. If the problem can be easily reproduced, it is quite trivial to fix it: gdb ./GAME (gdb) r Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7b2d10c in ?? () from /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0 (gdb) bt #0...
c++,arrays,string,vector,segmentation-fault
You said: I have some C++ code where I'm taking input from a user, adding it to a vector splitting the string by delimiter, and for debugging purposes, printing the vector's contents. And your code does: while (true) { //Prints current working directory cout<<cCurrentPath<<": "; /// /// This line of...
c,file,struct,segmentation-fault,records
Well, you get a segfault because you haven't allocated memory for the first entity in your records. So to resolve that you need to records[size-1] = malloc(sizeof(Records)); To put it in this way: You have records that is a pointer to a pointer to Records. When you did records =...
c,sockets,segmentation-fault,shellcode,experimental-design
This doesn't work because shellcode file is an object file. It is an intermediate file format meant for linker consumption. Treating it as a sequence of instructions is plain wrong. Object file contains code, among other things. However this code is incomplete. When a code references a symbol, like write,...
Just looking at your code without inspecting in detail shows an evident problem You don't check if strtok() returned NULL, dereferencing a NULL pointer is undefined behavior, the faulty line is char* p = strtok(pathc, "/"); and you strcpy() the "token" right after that. You don't allocate space for k,...
c++,segmentation-fault,codeblocks
You declare these variables int i, j, row, column Then you do an assignment here while (getline(sudokutxtfile,txtline)) { sudokubox[row] = txtline; row++; } row was never initialized, so whatever index you are trying to write to sudokubox[row] is probably out of range (or negative, or the color green, or who...
c++,c++11,segmentation-fault,coredump
Yeah, I think you're doing something pretty silly. You probably compiled the first code, which doesn't have the std::cout statement, and you probably executed the compilation steps without -std=c++11 which would result in std::stoi not being included beecause std::stoi is from C++11 and onward. The result is still the old...
c,segmentation-fault,realloc,dynamic-allocation
fscanf does not return EOF, it returns the number of input items assigned (man fscanf). For your purposes, you need to check while ( c == 1 ) ... However, that in itself does not cause the segfault! It is caused by attempting to print prefix[i] (repeatedly), which is not...
c,segmentation-fault,malloc,memset,unsigned-char
It seems that your program is written in C instead of C++. In C++ you should use operator new [] instead of malloc. The problem with the function is that function parameters are its local variables. So the function parameter char *data is a copy of its argument declared in...
c++,segmentation-fault,stack-overflow
Sort Tables[20]; most probably exceeds your available stack size with N = 30000. You may try to allocate an appropriate vector from the heap instead: std::vector<Sort> Tables(20); ...
c++,gcc,segmentation-fault,undefined-behavior,move-semantics
We can see exactly what GCC is doing under the hood by compiling both cases with -S: g++-4.6 -std=c++0x test.cc -S -fverbose-asm And then using diff to compare the outputs: diff -rNu move.s ret.s |c++filt --- move.s 2015-05-21 14:00:49.097524035 +0100 +++ ret.s 2015-05-21 14:00:40.021510019 +0100 @@ -79,23 +79,13 @@ .cfi_offset...
c,variables,segmentation-fault,arguments
You need to initialize the args list using va_start double shape_area(double shapetype, ...) { va_list args; va_start(args,shapetype); . . ...
You are accessing primesRef[i + jump] where i could be primesRef.size() - 1 and jump could be primesRef.size() - 1, leading to an out of bounds access. It is happening with a 500 limit, it is just that you happen to not have any bad side effects from the out...
assembly,x86,segmentation-fault,mmap
The value in R8 at the time your program crashes is the file descriptor returned by the open syscall. Its value is probably 3 which isn't a valid address. You'll need to stores these values in a range of memory you've properly allocated. You can create a buffer in your...
c,pointers,char,segmentation-fault,strlen
strlen() will dereference a pointer, which may cause some problems when this pointer,i.e optarg, is not valid. For example, in case of optarg=NULL and c='f', your code will be executed as: case 'f': wfiles = optarg; //Now wfiles=NULL strlen(wfiles) will be: strlen(NULL) and segmentation fault happens. See this related question...
char (*string)[100]; OK, string represents a pointer to 100 char, but it's not initialized. Therefore, it represents an arbitrary address. (Even worse, it doesn't necessarily even represent the same arbitrary address when accessed on subsequent occasions.) gets(string[i]); Hmm, this reads data from standard input to a block of memory starting...
c,arrays,pointers,segmentation-fault
You have not allocated or freed memory correctly, and the function didn't even return the pointer! I think you were trying to allocate one block of memory for the struct and the array it contains, but the struct does not contain an array: only a pointer to an array. You...
Issues in your code: 0<=a[i]<=10^10 is not correct, should change to 0<=a[i] && a[i]<=(10^10) ^ is a bitwise xor, not power, In your for loop, you always compare before read element of a[], so you need to read first, then compare. use unsigned long long, don't need int at end....
c,segmentation-fault,shared-memory
I think this is where your problem lies: shd == mmap(NULL, sizeof(shared1), PROT_READ | PROT_WRITE, MAP_SHARED, shm, 0); You're comparing shd to the return value of mmap with '=='. I think you meant to use a single '=' which would assign the return value to shd....
c,unix,segmentation-fault,pthreads
The name of the array, global points to the base address of the array. You can simply pass that and use the same inside your thread function. However, just to mention a logical point, if you're passing global as a parameter to sum_thread() function, it need not be a global....
c,arrays,function,pointers,segmentation-fault
try this int main(void) { int *a, *b, *c; int i; srand(time(NULL)); printf("Enter array lenght:"); scanf("%d", &velA); getchar(); a = (int*)calloc(velA, sizeof(int)); //b = NULL;//There is no need to set the value //c = NULL;//NULL is better than malloc(4) for(i = 0; i < velA; i++) { a[i] = rand()...
c++,segmentation-fault,maps,dynamic-programming
You get SIGSEGV on dp(0) call. It causes an infinite recursion. By the way, your solution is wrong, for example the answer for 24 is not 25. Try to avoid magic constants, it is just enough to set a[0] = 0 and make a more accurate dp function: uint32_t dp(uint32_t...
node *cursor = theMap->root; I'm assuming if the map is empty, root will be NULL. while(cursor->next != NULL) If root was NULL, cursor is NULL as well, and you are dereferencing it when accessing the next field. Perhaps change the while condition to: while (cursor && cursor->next) ? EDIT: Here's...
I suspect there's some issue with your line for (j = 0; j < height; j += height-1) { prev[i][j] = prev[0][j]; Consider the previous for loop, for a value of say width = 3. i evolves as 0, 2, 4. When i becomes 4, that for loop is not...
"is it because of insufficient memory??" Yes, your stack size is probably too small to hold this. Use std::vector<int> array(size); instead of int array[size]; ...
c++11,segmentation-fault,stdvector
What are the possible causes of a segmentation fault at the following line? The line itself is exceedingly unlikely to cause a segmentation fault. The only way that could happen is if you've exhausted stack. Do (gdb) x/i $pc. Is the crashing instruction a PUSH or a CALL? If...
c++,c,segmentation-fault,coredump
I would think you would need to add check on your externally accepted values (using assert might be a start) Like : checking tm>0 ler>0 C[i]<tm A[i]!=NULL B[i]!=NULL As mentionned in the comment it an off by one issue : in LER the values should be from 0 to tm-1...
The kernel message buffer is a ring buffer with limited space - when new messages arrive old may get dropped. dmesg outputs the current buffer. Normally /var/log/dmesg is filled directly after boot, so that the boot messages do not get lost....
c++,c,multithreading,segmentation-fault
From what I understand, the main thread is freeing memory used by the drawing thread without any form of synchronization, i.e., the main thread may free that memory when it is being written by the drawing thread. It's not safe, and you most definitely shouldn't be leaving it that way....
c++,segmentation-fault,avl-tree
You have undefined behavior in your code, because local variables are not initialized, their values are indeterminate. You need to initialize the variables before you try to use them, e.g. node* root = nullptr; // or `0` or `NULL` ...
The bug is in this statement here: void *writeStart = (void*)( (unsigned long long)data + dataLength*64 - charsLength*8 ); That is, it appears you're trying to get the right write location in bits, when you should be doing this in bytes. When you have statements like dataLength*64 and charsLength*8, you're...
c++,linux,segmentation-fault,portability
As the code you just added to the question reveals, the problem arises because you did not initialize the episode variable. The behavior of any code that uses its value before you assign one is undefined, so it is entirely reasonable that the program behaves differently in one environment than...
c++,segmentation-fault,valgrind,ifstream
this->binaryData = new uint8_t[bytesToAllocate]; inFile.read(reinterpret_cast<char*>(&this->binaryData), bytesToAllocate); You're reading into the address of this->binaryData. But the value of this->binaryData is the address you want. You want: this->binaryData = new uint8_t[bytesToAllocate]; inFile.read(reinterpret_cast<char*>(this->binaryData), bytesToAllocate); ...
c++,unix,segmentation-fault,fork,shared-memory
Check the return value of shmget (which you are storing in idShMem). It is possible for the call to fail. If it is negative then you are never successfully allocating the memory in the first place. If idShMem is negative, that is your problem. This is analogous to checking a...
c,string,segmentation-fault,dynamic-memory-allocation,strcpy
The problem here, as I can see, is with char* tTmp[20]; you never allocated memory to tTmp[n] before using like strcpy(tTmp[compteur],t[compteur]); using uninitialized memory leads to undefined behaviour. Note: Don't be fooled by the strange behavior of UB. your cop == 0 case is equally erroneous as cop < 0...
c++,templates,segmentation-fault,sfinae
You can use a combination of std::is_pointer and std::enable_if: #include <type_traits> #include <iostream> class MyClass { }; template <typename Object> class List { public: template<class T=Object> void insert(T t, typename std::enable_if<std::is_pointer<T>::value >::type* = 0) { std::cout << "insert pointer" << std::endl; } template<class T=Object> void insert(T t, typename std::enable_if<!std::is_pointer<T>::value >::type*...
c++,multidimensional-array,segmentation-fault,dynamic-memory-allocation
pic[i] == new char*[width]; -> Why is there a == comparison instead of = assignment ? Similarly for pic[i][j] == new char[3]; -> a comparison is being done and no assignment....
You only check if (j > n) but actually j == n is off bounds, also you can use else if instead of a separate else and if, like this else if (j >= n) { printf("No path from %d to %d found", src, dest); stopper = 0; } or...
c,segmentation-fault,coordinates,fscanf
@Weather Vane well answered the major issue. Below are additional points. #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { // Check argc if (argc < 1) Print_Error_And Quit(); int n = atoi(argv[1]); FILE *fp; fp = fopen("data.dat","r"); if (fp == NULL) { perror("Error"); } int number; char str[3];...
In the create_string() function you should properly set the values of malloced str so that it does not contain any random values. Especially, str->value is not set to NULL. And then you are checking it in set_string() which may not succeed and you would strcpy() to unallocated memory causing undefined...
You need to allocate memory for each node that is going into your hash table. How's about something like the following: /* make hash table */ node* hashtable[729]; /* initialise all buckets to NULL */ memset(hashtable, 0, sizeof(node*)*729); node new_node; /* Use a stack node for the temporary */ new_node.next...
c,pointers,file-io,segmentation-fault,malloc
In your readFileToBuffer() code, fileBuffer is of type char ** and your function is called as readFileToBuffer("/tmp/file.txt", &fileBuffer); Then you have rightly allocated memory to *fileBuffer in readFileToBuffer() [so that is gets reflected to the fileBuffer in main()]. So, you need to pass *fileBuffer to fread() to read the contents...
c,segmentation-fault,fopen,compiler-warnings,fscanf
In your code, you're fopen()ing the file twice. Just get rid of the TM = fopen("TM","r"); before the if statement. That said, you should check the value of fscanf() to ensure success. Otherwise, you'll end up reading an uninitialized array string2, which is not null-terminated which in turn invokes undefined...
c++,vector,segmentation-fault,intrinsics,avx
AVX requires aligned data. vector does not guarantee the elements will be aligned properly. See this question (How is a vector's data aligned?) for a discussion of allocation alignment, specifically with regards to SIMD execution.
One issue right away: Simple* simple_obj; int number = simple_obj->getSampleCounts(infile); simple_obj is an uninitialized pointer, thus your program exhibits undefined behavior at this point. Why use a pointer anyway? You could have simply done this to avoid the issue: Simple simple_obj; simple_obj.getSampleCounts(infile); Also, this line may not be an issue,...
c,pointers,segmentation-fault,scanf
In your code, stack* st; st->top=-1; you're using st uninitialized which in turn invokes undefined behaviour. You need to allocate memory to st before using it. Try something like stack* st = malloc(sizeof*st); //also, check for malloc success That said, Please see why not to cast the return value of...
c,segmentation-fault,free,memcpy
Use free(temp-i) You increment temp in the loop. Hence you are not freeing the pointer you created. A better approach would be for(i=0;i<5;i++){ printf("%c\n",*(temp+i)); } free(temp); ...
c++,stl,segmentation-fault,multiset
Your first erase effectively emptied your multiset. From std::multiset::erase (emphasis mine) Removes specified elements from the container. 1) Removes the element at pos. 2) Removes the elements in the range [first; last), which must be a valid range in *this. 3) Removes all elements with the key value key. References...
c,segmentation-fault,malloc,strncpy
The difference is that the string literals you initialized to the pointers dst and src in the later cases are stored in the data segment. A data segment is a portion of virtual address space of a program, which contains the global variables and static variables that are initialized by...
c,debugging,segmentation-fault,gdb,strcmp
You should check that you properly use strcmp(), the API is: int strcmp(const char *str1, const char *str2) You must: 1) Validate that st[i], your first argument is a pointer. 2) Make sure that st[i] & s has the Null terminator '\0'`. 3) Check that st[i] & s pointing to...
Names which start with an underscore (or two) are reserved for the compiler. This is official C++ standard. Use at own risk.
Use _mm256_storeu_pd. Just like your loads, an unaligned store is required because the arrays are not guaranteed to be properly aligned for AVX.
c++,recursion,segmentation-fault
The number of recursion levels you can do depends on the call-stack size combined with the size of local variables and arguments that are placed on such a stack. Aside from "how the code is written", just like many other memory related things, this is very much dependent on the...
c,linux,sockets,tcp,segmentation-fault
The code as shown misses to #include any headers, so as it stands won't compile due to some undefined symbols. It would compile however if you missed to just prototype any library functions referenced by the code, which would lead to any function being assumed to return int. The latter...
c,memory,segmentation-fault,mmap,coredump
I'm guessing you also need read permissions in your mmap: PROT_WRITE | PROT_READ
I assume that your initialization function is something like this: void initialize() { char (*globalScreen)[SSIZEY] = malloc(SSIZEX * SSIZEY * sizeof(char*)); // rest of code } Which means that it declares a new variable named globalScreen, instead of giving value to the global variable. Additionally, you can't access globalScreen as...
c++,vector,segmentation-fault,gdb
I think the problem is here: fin >> n; vector<Table> tables; int temp; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { fin >> temp; tables[0].data[i][j] = temp; // HERE } } The vector is empty while you access...
c++,segmentation-fault,gdb,valgrind
As the functions are recursive insert calls insert_if_leq and vice versa, I had to make node_ptr root in insert_if_leq a reference, because the assignment in insert depended on it. The new function definitions are as follows: node_ptr scene_manager::insert(node_ptr & root, node_ptr other) node_ptr scene_manager::insert_if_leq(node_ptr & root, node_ptr other)...