segmentation-fault

sem_init() causing SEGV

北战南征 提交于 2019-12-10 21:02:43
问题 I have the following code and it is being killed by a SEGV signal. Using the debugger shows that it is being killed by the first sem_init() in main(). If I comment out the first sem_init() the second causes the same problem. I have tried figuring out what would cause this sys call to cause a SEGV. The else is not being run, so the error is happening before it can return a value. Any help would be greatly appreciated, Thank you. I removed the rest of the code that isnt being run before this

wxPython crashes with Segmentation fault

流过昼夜 提交于 2019-12-10 20:38:18
问题 I'm confused to why my application crashes with Segmentation fault. I have a python app using wxPython for front end. My application crashes randomly with segmentation fault and I know it has to be wxPython because I have a console version of the same code and it doesn't crash. The front end is a read-only table with items populating it automatically from a thread. I'm using wxPython2.8 and python version 3.0 and I'm running it on Ubuntu 10.04. And I can't tell if I'm doing something wrong or

segmentation fault on resizing a vector of large structures

◇◆丶佛笑我妖孽 提交于 2019-12-10 20:08:19
问题 The code below is generating a segementation fault, and I do not understand why. The code below uses a vector to store multiple large strucutres, but the code does not run and generates a segmentation fault. I don't understand why. My understanding is that vector resize allocates memory in heap so this shouldn't be a stack overflow problem. My system has very large physical memory (256 GB) and the code is compiled in 64 bit mode so allocating just 40 MB should not be a problem. Any ideas?

C: Array initialization segfaults depending on size and call to printf()

拜拜、爱过 提交于 2019-12-10 19:03:22
问题 Another student asked me what could be wrong with his C code. I successfully reproduced the erroneous behavior and have completely no idea why this segfaults. Consider this tiny C programm: #include <stdio.h> int main(void) { int N = 590; double A[N][N]; double B[N][N]; double C[N][N]; printf("done"); } Set N to a value <= 590: This runs without errors, with or without output. set N to a value > 590: Runs flawlessy with output line removed. Compile and run with output: segmentation fault What

Django WSGI Application SegFault

最后都变了- 提交于 2019-12-10 16:33:44
问题 so i'm getting segfaults with my django wsgi application in mod_wsgi via apache 2.22 here's the wsgi app: import os import sys sys.path.append('/home/***.com/zpencerq') sys.path.append('/home/***.com/zpencerq/part') os.environ['DJANGO_SETTINGS_MODULE'] = 'part.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() here's the error from the logs: [Mon Jun 18 18:13:39 2012] [info] mod_wsgi (pid=78535): Create interpreter 'www.***.com|'. [Mon Jun 18 18

Homework: Making an array using pointers

落爺英雄遲暮 提交于 2019-12-10 16:28:07
问题 I have a homework problem that I'm working out. Me and some other students are pretty sure that our teacher misspoke, but maybe not. I checked through a bit of the questions here already and can't really find a way to use pointers to create what is essentially an array. The instructions read as follows. Rewrite the following program to use pointers instead of arrays: The code is this int main() { int salary[20]; int i; for (i = 0; i < 20; i++) { cout << "Enter Salary: "; cin >> salary[i]; }

PyODBC Cursor.fetchall() causes python to crash (segfault)

风格不统一 提交于 2019-12-10 16:27:17
问题 I am using Python 2.7 on Windows XP. I have a simple python script on a schedule that uses pyodbc to grab data from an AR database which has worked perfectly until today. I get a segfault once the cursor reaches a particular row. I have similar code in C++ which has no problem retrieving the results, so I figure this is an issue with pyodbc. Either way, I'd like to "catch" this error. I've tried to use the subprocess module, but it doesn't seem to work since once the script hits a segfault it

Why char name[1] can hold more than 1 character? [duplicate]

牧云@^-^@ 提交于 2019-12-10 16:08:26
问题 This question already has answers here : Array index out of bound in C (10 answers) Closed 4 years ago . I was doing a little bit of research about a topic when I came across this situation. Assume the following C code: #include <stdio.h> int main() { char name[1]; scanf("%s",name); printf("Hi %s",name); return 0; } I've compiled with -fno-stack-protector and tested it with input longer than 1, like John , & to my surprise, It works! Shouldn't it throw a segmentation fault when the input is

Temporary redirection of stderr in a bash script

送分小仙女□ 提交于 2019-12-10 15:44:38
问题 I have a simple script which is used to start another program. This other program may sometimes yield a SIGSEGV , which disrupts my output. I have therefore added a couple of lines which is supposed to temporarily redirect the stderr to /dev/null such that the SIGSEGV is ignored. The following is a draft of my code: exec 2> /dev/null progname >& ./tmp/run.txt && run_status='OK' exec 2>1 The problem is that the last line does not do what I want. The first line obviously works, and redirects

Why doesn't this Rust program crash?

倾然丶 夕夏残阳落幕 提交于 2019-12-10 14:54:59
问题 Consider this Rust program: fn main() { let mut z : Vec<Vec<(bool,f64)>> = Vec::with_capacity(10); unsafe { z.set_len(10); } z[0] = vec!((true,1.)); println!("{:?}", z[0]); } https://play.rust-lang.org/?gist=ccf387ed66a0d8b832ed&version=stable Rust should attempt to drop z[0] when we set it, and since z[0] is uninitialized it should crash the program. However, it runs fine. Why? 回答1: While the memory in the Vec’s heap allocation is uninitialised, it will most commonly be filled with zeros,