Dear all,
I am running a program and in one of the functions I have to sort the
data of an array as follows:
..
..
..
for (m=0;m<M;++m) //Sort
{
k=m;
for (j=m+1;j<M;++j)
{
if (DT[j]<DT[k]) k=j;
}
Temp=DT[m];
DT[m]=DT[k]; <<-----The 'Valgrind' gives error in this line
DT[k]=Temp;
}
..
..
..
When I check my program by 'Valgrind', it gives me the following
sentence which is pointing to error in the line that I have pointed in
the program.
==11285==
==11285== Source and destination overlap in memcpy(0x4A3335 8,
0x4A33358, 400)
==11285== at 0x4906C4A: memcpy (mac_replace_st rmem.c:394)
==11285== by 0x4014F8: SP(Record*, Record*) (925.cpp:601)
==11285== by 0x40EDF5: main (925.cpp:197)
Is it really an error? I have just substituted the elements of an array! 2 1814
"Mohsen" <ja*******@gmai l.comwrote in message
news:11******** **************@ m73g2000cwd.goo glegroups.com.. .
Dear all,
I am running a program and in one of the functions I have to sort the
data of an array as follows:
.
.
.
for (m=0;m<M;++m) //Sort
{
k=m;
for (j=m+1;j<M;++j)
{
if (DT[j]<DT[k]) k=j;
}
Temp=DT[m];
DT[m]=DT[k]; <<-----The 'Valgrind' gives error in this line
DT[k]=Temp;
}
.
.
.
When I check my program by 'Valgrind', it gives me the following
sentence which is pointing to error in the line that I have pointed in
the program.
==11285==
==11285== Source and destination overlap in memcpy(0x4A3335 8,
0x4A33358, 400)
==11285== at 0x4906C4A: memcpy (mac_replace_st rmem.c:394)
==11285== by 0x4014F8: SP(Record*, Record*) (925.cpp:601)
==11285== by 0x40EDF5: main (925.cpp:197)
Is it really an error? I have just substituted the elements of an array!
In this case its harmless. I believe valgrind issues warnings about
overlapping
src/dst when using memcpy (which has undefined behavior in that situation),
you should use memmove when src/dst overlap.
In this case src and dst are the same. But why is that,shouldn't you only
be swapping elements which are actually different ?
Shouldn't the line be if (DT[j]<=DT[k]) k=j;
Hi,
The values af my array can not be the same and for that reason I have
written:
if (DT[j]<DT[k]) k=j;
Best,
Mohsen
Dave Townsend wrote:
"Mohsen" <ja*******@gmai l.comwrote in message
news:11******** **************@ m73g2000cwd.goo glegroups.com.. .
Dear all,
I am running a program and in one of the functions I have to sort the
data of an array as follows:
.
.
.
for (m=0;m<M;++m) //Sort
{
k=m;
for (j=m+1;j<M;++j)
{
if (DT[j]<DT[k]) k=j;
}
Temp=DT[m];
DT[m]=DT[k]; <<-----The 'Valgrind' gives error in this line
DT[k]=Temp;
}
.
.
.
When I check my program by 'Valgrind', it gives me the following
sentence which is pointing to error in the line that I have pointed in
the program.
==11285==
==11285== Source and destination overlap in memcpy(0x4A3335 8,
0x4A33358, 400)
==11285== at 0x4906C4A: memcpy (mac_replace_st rmem.c:394)
==11285== by 0x4014F8: SP(Record*, Record*) (925.cpp:601)
==11285== by 0x40EDF5: main (925.cpp:197)
Is it really an error? I have just substituted the elements of an array!
In this case its harmless. I believe valgrind issues warnings about
overlapping
src/dst when using memcpy (which has undefined behavior in that situation),
you should use memmove when src/dst overlap.
In this case src and dst are the same. But why is that,shouldn't you only
be swapping elements which are actually different ?
Shouldn't the line be if (DT[j]<=DT[k]) k=j;
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jerald |
last post by:
Running python 2.3.4 on valgrind (a tool like purify which checks
the use of uninitialized memory, etc), gives a lot of errors.
See below.
jfj@cluster:~/> python -V
Python 2.3.4
jfj@cluster:~/> valgrind python
==10517== Memcheck, a.k.a. Valgrind, a memory error detector for x86-linux.
|
by: Sitsofe Wheeler |
last post by:
Hello,
I am using a threaded C program and each thread creates its own
connection to mysql database using mysql_init(). When I run Valgrind on
the program it reports that there has been a small leak stemming from
several mysql_init and one mysql_real_connect. I have read
http://www.mysql.com/doc/en/Threaded_clients.html but despite adding
my_thread_init(), my_thread_end() and linking against mysqlclient_r a
leak is still reported. Here...
|
by: Andreas Andersen |
last post by:
Hi
I have been using valgrind to debug a program I have written in C++ and
it has been very helpful in eliminating memory errors/leaks. However, I
just recently discovered a bug and from what I can see it looks like
some kind of memory problem. However, when I run it through valgrind no
errors are reported and the bug seems to be gone! I print some status
from the program and at some point this becomes wrong but when the
program is run...
|
by: hvaisane |
last post by:
Valgrind says
==11604== Invalid read of size 4
==11604== at 0x8048ABB: main (foo.cc:36)
==11604== Address 0x1B92415C is 4 bytes inside a block of size 8 free'd
==11604== at 0x1B90514F: operator delete(void*) (vg_replace_malloc.c:156)
==11604== by 0x804A1BA: __gnu_cxx::new_allocator<Foo>::deallocate(Foo*, unsigned) (new_allocator.h:86)
==11604== by 0x8049C08: std::_Vector_base<Foo, std::allocator<Foo> >::_M_deallocate(Foo*,...
|
by: mfried |
last post by:
Hi all,
I'm testing an application using valgrind 3.2.0 unter Linux kernel 2.4.
When the test are finished and the app terminates valgrind gives the
error:
--15631:0:aspacem Valgrind: FATAL: I/O error on /proc/self/maps
--15631:0:aspacem Exiting now.
My first thought was that I need more access rights on that file, but
| |
by: Simple Simon |
last post by:
It's entirely possible that I'm completely in the wrong line of work,
but I don't see what Valgrind is complaining about in this code.
Invalid read/writes?
If I free the within main(), rather than within free_node_list(),
Valgrind reports 0 leaks?
OS: SuSE 9.3 Linux 2.6.11.4-21.11-default i686 i386
GCC: 3.3.5 20050117
|
by: Esa A E Peuha |
last post by:
Running Python 2.5.1 under Valgrind is interesting; just starting it and
then pressing Ctrl-D produces this:
==27082== ERROR SUMMARY: 713 errors from 56 contexts (suppressed: 10 from 1)
==27082== malloc/free: in use at exit: 1,243,153 bytes in 508 blocks.
==27082== malloc/free: 3,002 allocs, 2,494 frees, 2,748,487 bytes allocated.
==27082== For counts of detected errors, rerun with: -v
==27082== searching for pointers to 508 not-freed...
|
by: Salvatore Iovene |
last post by:
Hi,
I'm using the pexpect module to spawn some processes in a testing
environment. pexpect uses, internally, os.execv. What I need to do is
valgrind python and get memory leaks from the spawned children
(assuming that python doesn't leak :)).
Here's a simple testcase:
===================
leak.c:
|
by: tvnaidu |
last post by:
valgrind error - "failed to start tool 'memcheck' for platform x86-linux" no such file or dir
copied all lib and bin files which are generated after I compiled valgrind package, when I run my exe with valgrind, I am getting above error, any idea?
lib/
-rw-r--r-- 1 0 0 27934 default.supp
-rwxr-xr-x 1 0 0 4636305 cachegrind-x86-linux
-rwxr-xr-x 1 0 0 4891451 callgrind-x86-linux...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |