segmentation-fault

Passing big multi-dimensional array to function in C

Hi, I'm having trouble passing a big array to a function in C. I declare: int image[height][width][3]={}; where height and width can be as big as 1500. And when I call: foo((void *)image,height,width); which is declared as follows: int *foo(const int *inputImage, int h, int w); I get segmentation fault error. What's strange is ...

Segmentation fault in Qt application framework

this generates a segmentation fault becuase of "QColor colorMap[9]";. If I remove colorMap the segmentation fault goes away. If I put it back. It comes back. If I do a clean all then build all, it goes away. If I increase its arraysize it comes back. On the other hand if I reduce it it doesnt come back. I tired adding this array to ...

SWFTools Segmentation Fault

I saw that thread: http://stackoverflow.com/questions/2055061/swftools-segmentation-fault When I tried to convert a PDF to SWF using pdf2swf I got an error: /usr/local/bin/pdf2swf /var/www/html/ny-sto-p.watchitoo.com/content/userContent/2/1GRKm/1GRKm.pdf -i -p 5 -o /var/www/html/ny-sto-p.watchitoo.com/content/userContent/2/1GRKm/1GRKm-...

Learning C, would appreciate input on why this solution works.

This is literally the first thing I've ever written in C, so please feel free to point out all it's flaws. :) My issue, however is this: if I write the program the way I feel is cleanest, I get a broken program: #include <sys/queue.h> #include <stdlib.h> #include <stdio.h> #include <string.h> /* Removed prototypes and non related cod...

Segfault (possibly due to casting)

I don't normally go to stackoverflow for sigsegv errors, but I have done all I can with my debugger at the moment. The segmentation fault error is thrown following the completion of the function. Any ideas what I'm overlooking? I suspect that it is due to the casting of the sockaddr to the sockaddr_in, but I am unable to find any mistak...

Segmentation fault on writing char to char* address

Hi guys, I've got problem with my little C program. Maybe you could help me. char* shiftujVzorku(char* text, char* pattern, int offset){ char* pom = text; int size = 0; int index = 0; while(*(text + size) != '\0'){ size++; } while(*(pom + index) != '\0'){ if(overVzorku(pom + index, pattern)){ ...

C segmentation fault before/during return statement

I print the value that I'm returning right before my return statement, and tell my code to print the value that was returned right after the function call. However, I get a segmentation fault after my first print statement and before my second (also interesting to note, this always happens on the third time the function is called; never ...

Segmentation fault when accessing a PHP page

Sometimes when one of our Apache web servers is restarted, we experience segmentation faults when any PHP page is subsequently accessed. The following line is printed in the httpd error_log: [Wed Jun 16 10:59:33 2010] [notice] child pid 31513 exit signal Segmentation fault (11) There will be one of these lines for each PHP page that is...

C++ Segmentation fault in binary_function

I'm using Visual Studio 2010 Beta 2 (also tried with NetBeans), and I'm having a segmentation fault in the following code: // One of the @link s20_3_3_comparisons comparison functors@endlink. template <class _Tp> struct less : public binary_function<_Tp, _Tp, bool> { bool operator()(const _Tp& __x, const _Tp& __y) const { return _...

Expected segmentation fault, as soon as assigning a value to index 1?

Hello, In the code snippet, I expected a segmentation fault as soon as trying to assign a value to count[1]. However the code continues and executes the second for-loop, only indicating a segmentation fault when the program terminates. #include <stdio.h> int main() { int count[1]; int i; for(i = 0; i < 100; i...

segfault when trying to access a string member of a class

I have a class Message that has a std::string as a data member, defined like this: class Message { // Member Variables private: std::string text; (...) // Member Functions public: Message(const std::string& t) : text(t) {} std::string getText() const {return text;} (...) }; Thi...

strange error in g++

My program has a class with a vector of Level objects named levels. In a member function there is this line: levels.push_back(level::Level()); I made several changes to my program today, and that line of code started segfaulting: 0x0804d248 in void std::vector<yarl::level::Level, std::allocator<yarl::level::Level> >::emplace_back<ya...

Got segfault on a macbook pro with a 24+bits indexed array

I am using GCC + the terminal to make an array of prime numbers. I once asked on #[email protected], but I still don't understand: An int can store values on 32 bits (so a total of 2^32 unique values), but can't an array have more than 2^24 values ? I'm not sure, but is http://stackoverflow.com/questions/2318278/why-24-bits-registers...

Wrapping C++ dynamic array with Python+ctypes, segfault

Hi! I wanted to wrap a small C++ code allocating an array with ctypes and there is something wrong with storing the address in a c_void_p object. (Note: the pointers are intentionally cast to void*, 'cause later I want to do the allocation the same way for arrays of C++ objects, too.) The C(++) functions to be wrapped: void* test_all...

Rmagick on windows segmentation fault

I have problems installing RMagick on top of Windows. I did as I should according to the instructions: Downloaded the archive: RMagick-2.12.0-ImageMagick-6.5.6-8-Q8.zip from here and unzipped to a local folder. Installed ImageMagick-6.5.6-8-Q8-windows-dll.exe gem install rmagick-2.12.0-x86-mswin32.gem --local Even a reboot Then I fol...

PHP segmentation fault | __get called inside the class for a protected property ?

Hi all, I have a class with the methods __toString and __get and some protected properties such as "message". So far, so good. The problem now is that I need to access $this->message in __toString, and this causes (NOT ALWAYS BUT OFTEN) a segmentation fault when (see following example) $display_all is set to true. Do you know why and ...

Educational example to show that sometimes printf as debugging may hide a bug

Hello all, I remember when I was in some course of C programming, a teacher once suggested to use printf to watch the execution of a program that I was trying to debug. This program had a segmentation fault with a cause that I cannot remember at the moment. I followed his advice and the segmentation fault disappeared. Fortunately, a cle...

Segmentation Fault when run loop 41881 times

I am writing a C program that reads a text file and parses the data in it into various fields. The text file I am reading from is very large though (31MB) and when I run the program on a text file that has 41880 lines of input everything works fine. I will ultimately need to read from text files that are much much larger than that thou...

TOUGH: Dealing with deeply nested pointers in C++

I define this structure: struct s_molecule { std::string res_name; std::vector<t_particle> my_particles; std::vector<t_bond> my_bonds; std::vector<t_angle> my_angles; std::vector<t_dihedral> my_dihedrals; s_molecule& operator=(const s_molecule &to_assign) { res_name = to_assign.res_name; my_particles = to_assign.m...

including <stdlib.h> causes segmentation fault

I am writing a program to read info from a text file and I had everything working. The problem is that I am trying to add the functionality to calculate the mean of some of fields and have to convert the strings to doubles. I noticed that atof would work in some cases but would return -1 for the most part. i then realized that I didn'...