| Summary: | Memcheck performs leak-checking even if killed by SIGTERM | ||
|---|---|---|---|
| Product: | [Developer tools] valgrind | Reporter: | Timur Iskhodzhanov <timurrrr> |
| Component: | memcheck | Assignee: | Julian Seward <jseward> |
| Status: | REPORTED --- | ||
| Severity: | normal | CC: | laurynas.biveinis |
| Priority: | NOR | ||
| Version First Reported In: | 3.7 SVN | ||
| Target Milestone: | --- | ||
| Platform: | Unlisted Binaries | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Timur Iskhodzhanov
2011-02-04 09:00:19 UTC
The report may change slightly:
--------------------
void* thread_func(void *) {
std::string str = "Valgrind";
str += " rocks\n";
printf("Entering!\n");
usleep(100000); // Make sure the thread is killed
printf("Finished!\n");
return 0;
}
--------------------
results in:
==20839== 153 bytes in 1 blocks are possibly lost in loss record 1 of 2
==20839== at 0x4C2B2A6: operator new(unsigned long) (vg_replace_malloc.c:261)
==20839== by 0x50F6D98: std::string::_Rep::_S_create(...) (new_allocator.h:89)
==20839== by 0x50F776A: std::string::_Rep::_M_clone(...) (basic_string.tcc:607)
==20839== by 0x50F829B: std::string::reserve(unsigned long) (basic_string.tcc:488)
==20839== by 0x50F84E7: std::string::append(...) (basic_string.tcc:309)
==20839== by 0x400BE8: thread_func(void*) (repstr.cpp:11)
==20839== by 0x4E389C9: start_thread (pthread_create.c:300)
==20839== by 0x58E370C: clone (clone.S:112)
Terribly sorry: the last comment should have been added to bug 280271 Related:
Why does Valgrind perform leak-checking when it gets a SIGSEGV?
--------------------------
#include <malloc.h>
int main(void) {
char * mystr = (char*)malloc(16);
mystr = (char*)0; /* Someone has corrupted the pointer */
*mystr = 0;
free(mystr);
}
--------------------------
==22700== Invalid write of size 1
==22700== at 0x400586: main (read_null.c:6)
==22700== Address 0x0 is not stack'd, malloc'd or (recently) free'd
...
==22700== Process terminating with default action of signal 11 (SIGSEGV)
==22700== Access not within mapped region at address 0x0
==22700== at 0x400586: main (read_null.c:6)
==22700== ...
==22700== HEAP SUMMARY:
==22700== ...
==22700== 16 bytes in 1 blocks are definitely lost in loss record 1 of 1
==22700== at 0x4C2A05F: malloc (vg_replace_malloc.c:236)
==22700== by 0x400575: main (read_null.c:4)
==22700==
==22700== LEAK SUMMARY:
==22700== definitely lost: 16 bytes in 1 blocks
Re: SIGTERM I've heard some Linux programs always shut down their children using SIGTERM? In this case Memcheck should continue doing leak-checking on SIGTERM; but (I think) not on SIGSEGV |