Sponsored Content
Top Forums Programming Program received signal: “EXC_BAD_ACCESS”? Post 302524558 by achenle on Monday 23rd of May 2011 08:45:20 PM
Old 05-23-2011
Quote:
Originally Posted by Corona688
Code:
char *string1;

This is a character pointer. On a 32-bit system, it takes 4 bytes, on a 64-bit system, 8 bytes. When I type in 'slartibartfast', where is it going to put it?

Inside the pointer? No, not enough room, and besides -- that's not how pointers work. The idea of a pointer is that it points to the memory you want to use, right?

So what memory have you got the pointer pointing to? Nothing? Uh-oh.

That leaves it at a random garbage value. Since pointers have no magic power of predicting what you want to do to them, it doesn't create memory for you to put things in and the pointer remains at what it started at -- some random garbage value. So scanf tries to store it in some undefined location in memory which naturally crashes

You should make the pointer actually point to something if you expect it to work. char string1[128]; or char *string1=malloc(128);
A string of characters such as "ABCD" is a character array. That we all know.

But an array evaluates to the address of it's first element, so when you see "ABCD" in an expression, it is effectively treated as a char *.

So the statement
Code:
char *string = "ABCD"

is perfectly valid. The pointer "string" is a char * value that is assigned the address of the first element of the "ABCD" array.

The OP's problem is he's trying to concatenate another string on the end of a static, constant array - his strcat() call is trying to write to the memory immediately following where his "tar czvf YourNewFile.tar.gz " string is stored.

And that appears to be read-only memory. Which is better than nuking whatever data is there.
 

10 More Discussions You Might Find Interesting

1. Programming

Program received signal SIGABRT, Aborted.

I ran degugger in C++ and the followings are the message I got: Program received signal SIGABRT, Aborted. 0x002a57a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2 (gdb) info s #0 0x002a57a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2 #1 0x002e97f5 in raise () from /lib/tls/libc.so.6... (1 Reply)
Discussion started by: napapanbkk
1 Replies

2. Programming

Program received signal SIGSEGV, Segmentation fault.

Dear all, I used debugger from C++ and these are the message I got: Program received signal SIGSEGV, Segmentation fault. 0x00323fc0 in free () from /lib/tls/libc.so.6 (gdb) info s #0 0x00323fc0 in free () from /lib/tls/libc.so.6 #1 0x00794fa1 in operator delete () from... (5 Replies)
Discussion started by: napapanbkk
5 Replies

3. Forum Support Area for Unregistered Users & Account Problems

no email received

I have tried to register and got a message saying an email would be sent but no email has turned up. Could you try again please? (1 Reply)
Discussion started by: lookingfor help
1 Replies

4. AIX

Received signal #11, SIGSEGV [default] on AIX 6.1

Hello, One of our customer is getting segmentation fault when he runs his shell script which invokes our executable on AIX 6.1. On AIX 5.3, there were no issues. Here is the truss output. 811242: __loadx(0x0A040000, 0xF0D3A26C, 0x00000000, 0x00000009, 0x00000000) = 0xF026E884... (0 Replies)
Discussion started by: erra_krishna
0 Replies

5. AIX

nim: error signal number 2 received

Hi to all, i am trying to make mksysb backup of a NIM client machine from NIM master and while i am reading that the backup is done successfully i get an error message below and it doesnt exit the smit screen. also the status of the command appears to be running. is there anybody who knows why... (3 Replies)
Discussion started by: omonoiatis9
3 Replies

6. Programming

Please help:program hang stuck there signal handling on POSIX Message Queue UNIX C programming

in a single main() function,so need signal handling. Use Posix Message Queue IPC mechanism , can ignore the priority and other linked list message,to implement the scenario: client:Knock Knock server:who's there client: Eric Server:Eric,Welcome. client:exit all process terminated ... (1 Reply)
Discussion started by: ouou
1 Replies

7. Programming

Why do I receive Program received signal SIGABRT, Aborted?

Im using gdb and when a user disconnects from my server I receive a message Program received signal SIGABRT, Aborted. 0x7ffe0304 in ?? () I was hoping someone here might have a explination for this message in gdb (26 Replies)
Discussion started by: Errigour
26 Replies

8. Forum Support Area for Unregistered Users & Account Problems

No activation email received

I have tried to register today with the username BatterBits, but have not received the activation email I do not live in any of the restricted countries - unless the UK has suddenly become a threat! I'd be grateful if you would assist. many thanks Ian (2 Replies)
Discussion started by: unregistered
2 Replies

9. UNIX for Beginners Questions & Answers

Error received

I have a program that i need to get done that gets the person's name and his grade then prints it in this order "name-grade-gradeletter" so i wrote this code: #!/bin/bash while :; do read -p "Enter the person's name: " name read -p "Enter the grade of the person: " grade case $grade in )... (3 Replies)
Discussion started by: UniverseCloud
3 Replies

10. Shell Programming and Scripting

Any help gratefully received

Multiple questions coming your way. A little back ground info as to why I am back to basics. A dear friend of mine passed away recently and as a request by him I have promised to keep his project alive. The problem I have it was being handed over when he was in the last weeks of his life and... (1 Reply)
Discussion started by: nobbyall
1 Replies
next(1mh)																 next(1mh)

Name
       next - show the next message

Syntax
       next [ +foldername ] [ -[no]header ] [ -help ] [ -showproc program ] [ -noshowproc ] [ options to ]

Description
       The  command  displays  the  next message in the current folder.  The next message is the one after the current message in the folder.  The
       message that is shown becomes the current message.

       If you name a folder using the +folder argument, displays the next message in the folder you specify.   That  folder  becomes  the  current
       folder.

Options
       -header
       -noheader Displays  a  one-line	header before the message.  The header consists of the name of the folder and the message number.  This is
		 the default behavior.	It can be suppressed with the -noheader option.

       -help	 Prints a list of the valid options to this command.

       -showproc program [ options ]
       -noshowproc
		 Specifies an alternative program to list messages.  The default is to use the program defined by the showproc: entry in the file.
		 As with you can give options to the program at the command line.  These are passed directly to by

       The defaults for this command are:

	      +folder defaults to the current folder
	      -header

Restrictions
       The  command  is  really  a  link  to  the program.  As a result, if you make a link to and that link is not called your link will act like
       instead.  To avoid this, add a profile-entry for the link to your and add the argument to the entry.

Profile Components
       Path:	   To determine the user's Mail directory
       showproc:   Program to show the message

Files
       The user profile.

See Also
       show(1mh), prev(1mh), mh_profile(5mh)

																	 next(1mh)
All times are GMT -4. The time now is 07:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy