A error about "Address 0x0 is not stack'd, malloc'd or (recently) free'd" in c program under linux
- by MaiTiano
There is a piece of my program:
height = atoi(argv[3]);
width = atoi(argv[2]);
sprintf(seqName,"%s", argv[1]);
// strcpy(seqName, argv[1]);
After compiling it, a exe file test is generated, then I use Valgrind to check it.
Then I got the following message, however I cannot understand what it tends to tell me.
Can anyone provide some kind help, Thanks.
1 contexts (suppressed: 13 from 8)
1 contexts (suppressed: 13 from 8) jl@ubuntu:~/work/dsr_analysis$
  valgrind --tool=memcheck
  
  --leak-check=yes ./test
  
  ==28940== Memcheck, a memory error detector
  
  ==28940== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
  
  ==28940== Using Valgrind-3.6.0.SVN-Debian and LibVEX;
  
  rerun with -h for copyright info
  
  ==28940== Command: ./test
  
  ==28940== 
  
  ==28940== Invalid read of size 1
  
  ==28940==    at 0x40260CA: strcpy (mc_replace_strmem.c:311)
  
  ==28940==    by 0x804A5C6: main (me_search.c:1428)
  
  ==28940==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
  
  ==28940== 
  
  ==28940== 
  
  ==28940== Process terminating with default action of signal 11 (SIGSEGV)
  
  ==28940==  Access not within mapped region at address 0x0
  
  ==28940==    at 0x40260CA: strcpy (mc_replace_strmem.c:311)
  
  ==28940==    by 0x804A5C6: main (me_search.c:1428)
  
  ==28940==  If you believe this happened as a result of a stack
  
  ==28940==  overflow in your program's main thread (unlikely but
  
  ==28940==  possible), you can try to increase the size of the
  
  ==28940==  main thread stack using the --main-stacksize= flag.
  
  ==28940==  The main thread stack size used in this run was 8388608.
  
  ==28940== 
  
  ==28940== HEAP SUMMARY:
  
  ==28940==     in use at exit: 0 bytes in 0 blocks
  
  ==28940==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
  
  ==28940== 
  
  ==28940== All heap blocks were freed -- no leaks are possible
  
  ==28940== 
  
  ==28940== For counts of detected and suppressed errors, rerun with: -v
  
  ==28940== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 13 from 8)1 contexts 
  (suppressed: 13 from 8)
1 contexts (suppressed: 13 from 8)