Signal SEGV (no mapping at the fault address) in _memcpy at 0xff0b07c0


 
Thread Tools Search this Thread
Top Forums Programming Signal SEGV (no mapping at the fault address) in _memcpy at 0xff0b07c0
# 1  
Old 01-10-2013
Signal SEGV (no mapping at the fault address) in _memcpy at 0xff0b07c0

Hi,

I am unable to copy the cursor value into character variable which is defined in nested structure by pointer.

Code:
typedef struct aaa
   {
   unsigned char device_type;
   unsigned char encrypt;
   unsigned short rec_len;
   } ABC;
typedef ABC *Pabc;

typedef struct def
   {
   ABC abc;
   unsigned char reference[5];
   } def;
typedef def *Pdef;


void main()
{
def apply;
Pdef pReturn;

pReturn = &apply;


memset((char*)(pReturn), '0',sizeof(pReturn));


short Ind_device_type; //Indicator Variable

char device_type_Cur[2]; //Host variable

//after fetching this value from database using cursor, i am using below statement to copy in to strucure

memcpy((char*)pReturn->abc.device_type,device_type_Cur,sizeof(pReturn->abc));

}

But getting error like signal SEGV (no mapping at the fault address) in _memcpy at 0xff0b07c0
0xff0b07c0: _memcpy+0x0080: stb %o3, [%o0]

Please help!Smilie

Regards,
Gayathri
# 2  
Old 01-10-2013
Why are you using memcpy to write to individual structure elements instead of just assigning them?

Code:
pReturn->abc.device_type=device_type_Cur;

Your code is crashing because this is not a pointer:

Code:
pReturn->abc.device_type

You are retrieving the device type from the structure and forcing it into a pointer variable, which forces memcpy to try and write to an address somewhere between 0-255. You need & to turn it into a pointer if you really, really need one.

Which you don't appear to.
# 3  
Old 01-10-2013
More importantly - your compiler had to have complained. Mine would not even compile with an error like that.

Please consider
1. turn on warnings - fix them - only ZERO warnings is acceptable
2. If your code apprears to run and you ignore warnings you are coding by accident. It is an irresponsible act to put code with warnings into production.
# 4  
Old 01-10-2013
Hi Corona688,

I have used the below
Code:
pReturn->abc.device_type=device_type_Cur;But i got the warning message that 
warning: improper pointer/integer combination: op "="

In debug mode, it has some junk value
Code:
(dbx) print device_type_Cur
device_type_Cur = "M"
(dbx) print pReturn->abc.device_type
pReturn->abc.device_type = 'ô':confused:

Actually in Pro*C code, we have to declare a variable with one extra byte. So device_type_Cur is defined with 2 bytes. but our abc structure has device_type as unsigned char which is single byte.

Last edited by Scott; 01-16-2013 at 02:41 AM.. Reason: Code tags
# 5  
Old 01-11-2013
I see device_type is an array now.

pReturn->abc.device_type=device_type_Cur[0];
# 6  
Old 01-11-2013
Wow..........

Code:
stopped in abc at line 566 in file "abc.c"
  566           pReturn->abc.device_type = device_type_Cur[0];
(dbx) next
stopped in abc at line 568 in file "abc.c"
pReturn->abc.device_type = 'M'
(dbx) print device_type_Cur[0]
device_type_Cur[0] = 'M'
(dbx)

Thanks so much!!!!!!!!!!!!!!!!!!!!!!Smilie

bw, i get one more warning

Code:
warning: no explicit type given in the below lines

/* SQLLIB Prototypes */
extern sqlcxt (/*_ void **, unsigned int *,
                   struct sqlexd *, struct sqlcxp * _*/);
extern sqlcx2t(/*_ void **, unsigned int *,
                   struct sqlexd *, struct sqlcxp * _*/);
extern sqlbuft(/*_ void **, char * _*/);
extern sqlgs2t(/*_ void **, char * _*/);
extern sqlorat(/*_ void **, unsigned int *, void * _*/);

Can you please help?

Last edited by Scott; 01-16-2013 at 02:42 AM.. Reason: Code tags
# 7  
Old 01-11-2013
You might have to put up with those ones, since it looks like they're doing that on purpose. Might be a side-effect of some generated code.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Creating unique mapping from multiple mapping

Hello, I do not know if this is the right title to use. I have a large dictionary database which has the following structure: where a b c d e are in English and p q r s t are in a target language., the two separated by the delimiter =. What I am looking for is a perl script which will take... (5 Replies)
Discussion started by: gimley
5 Replies

2. Red Hat

Help needed 'Segv'

Red Hat Enterprise 4.5 (32 bit) In strace we see "unexpected reloc type 0x38" What does that code 0x38 mean? mprotect(0x59a000, 42229760, PROT_READ|PROT_WRITE) = 0 writev(2, unexpected reloc type 0x38", 26}, {"", 0}, {"", 0}, {"\n", 1}], 1 0) = 113 exit_group(127) ... (6 Replies)
Discussion started by: Sunusernewbie
6 Replies

3. UNIX for Dummies Questions & Answers

signal SEGV (no mapping at the fault address)

Hello i ve got the following error on a C servor. signal SEGV (no mapping at the fault address) when running in dbx program terminated by signal SEGV (no mapping at the fault address) 0xff1d5cb4: srch_dir+0x0154: cmp %o1, %o0 Current function is _log 533 ... (4 Replies)
Discussion started by: mumuri
4 Replies

4. UNIX for Dummies Questions & Answers

Help with HUP and SEGV.

Hello - I need to know the detail of HUP and SEGV. I know HUP is Hangup and can be use to kill a Unix login session remotely by sending a hangup signal to the process running the login session. Could someone tell me in detail prupose of HUP and SEGV (segmentation violation)? I need to... (1 Reply)
Discussion started by: namasteall2000
1 Replies

5. UNIX for Dummies Questions & Answers

Panic kernal-mode address fault on user address 0x14

:) Firstly Hi all!!, im NEW!! and on here hoping that someone might be able to offer me some help... i have a server that keeps crashing every few days with the error message: PANIC KERNAL-MODE ADDRESS FAULT ON USER ADDRESS 0X14 KERNAL PAGE FAULT FROM (CS:EIP)=(100:EF71B5BD) EAX=EF822000... (10 Replies)
Discussion started by: Twix
10 Replies

6. Programming

segmantation Fault error SEGV_MAPERR - Address not mapped to object

Program received signal SIGSEGV, Segmentation fault si_code: 1 - SEGV_MAPERR - Address not mapped to object. 0x9fffffffbe7080d0:0 in free+0xb0 () from /usr/lib/hpux64/libc.so.1 Hi , I have developed a class to read config file (flat file with space as a field seperator ) on plattform... (3 Replies)
Discussion started by: pravinbhingare
3 Replies

7. UNIX for Dummies Questions & Answers

signal SEGV (no mapping at the fault address) in _malloc_unlocked at 0xfe1d44ac

When i run a program in sun solaris i got core dumped with an error message as follows... signal SEGV (no mapping at the fault address) in _malloc_unlocked at 0xfe1d44ac 0xfe1d44ac: _malloc_unlocked+0x022c: ld , %o3 Current function is GetEDBInfo 360 EXEC SQL (dbx) where... (1 Reply)
Discussion started by: noufal
1 Replies

8. 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
Login or Register to Ask a Question