At 08:57 11.07.2018, Mahmood Naderan via gcc-help wrote: >>Sorry, I don't get your point. >>What else do you expect to happen? > > >I don't expect a crash. Why? because the strcpy should simply copy an item to memory location. I wonder why it says "I can not access the memory location where is memory location is the data value"?!!! >Why on earth strcpy wants to access a memory location where I didn't tell him to access? > >Moreover, as I said multiple times, why w/o specifying -m32, the program finishes without error? > > > > > >Breakpoint 1, main (argc=1, argv=0xffffd154) at mico.c:35 >35 strcpy( dest, buffer ); >(gdb) p &buffer[0] >$1 = 0xffffcfb5 '\220' <repeats 50 times>, "\061\300Ph//shh/bin\211\343P\211\342S\211\341\260\vÍ?", '\220' <repeats 37 times>, "P\336\377\377\377\177" >(gdb) p &dest[0] >$2 = 0xffffd02c "\020\334\377", <incomplete sequence \367> >(gdb) x/100x 0xffffcfb5 >0xffffcfb5: 0x90909090 0x90909090 0x90909090 0x90909090 >0xffffcfc5: 0x90909090 0x90909090 0x90909090 0x90909090 >0xffffcfd5: 0x90909090 0x90909090 0x90909090 0x90909090 >0xffffcfe5: 0xc0319090 0x2f2f6850 0x2f686873 0x896e6962 >0xffffcff5: 0xe28950e3 0xb0e18953 0x9080cd0b 0x90909090 >0xffffd005: 0x90909090 0x90909090 0x90909090 0x90909090 >0xffffd015: 0x90909090 0x90909090 0x90909090 0x90909090 >0xffffd025: 0xffffde50 0x10007fff 0x00f7ffdc 0x5cf7ffca >0xffffd035: 0xe0ffffd1 0xb7000000 0xe0f7f047 0x90f7ffdd >0xffffd045: 0x00ffffd0 0x00000000 0x00000000 0x2c000000 >(gdb) next > >Program received signal SIGSEGV, Segmentation fault. >0x56555655 in main (argc=<error reading variable: Cannot access memory at address 0x90909090>, > argv=<error reading variable: Cannot access memory at address 0x90909094>) at mico.c:37 >37 } You said that you intentionally overwrite the stack. Maybe the strcpy starts copying until it overwrites in the stack the address that is holding the content of the local 'buffer' variable. So instead of pointing to 0xffffcfb5 it now points to 0x90909090 which is illegal, therefore the crash on the next read access. Are you trying to create a virus? >Moreover, as I said multiple times, why w/o specifying -m32, the program finishes without error? Overwriting the stack is undefined behaviour unless you know exactly what you're doing (which I doubt). Anything can happen, including success, as others have already told you. In 64 bit the stack layout is different, addresses and register values are bigger, therefore the buffer variable is maybe not overwritten. bye Fabi