[linux-lvm] [lvm2cmd] Heap destruction by lvm2_exit()?
Hubert Kario
hubert at kario.pl
Thu Aug 2 10:16:08 UTC 2012
On Thursday 02 of August 2012 02:50:17 Alasdair G Kergon wrote:
> Another factor might be different contents in your lvm.conf file compared
> with mine, or different devices present causing you to hit a problem code
> path and me not to.
As far as I know, I'm using standard lvm.conf (attached).
I'm having the same error (in valgrind) when I run the test app as a regular
user, so actual LVM config shouldn't have any effect (?):
/dev/mapper/control: open failed: Permission denied
Failure to communicate with kernel device-mapper driver.
>
> Or some other difference in the distribution/compiler/libraries etc.
I don't think so, I've got a test app that reliably crashes with normal
execution while works fine under valgrind:
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <lvm2cmd.h>
#include <unistd.h>
#include <assert.h>
#include <signal.h>
#include <string.h>
int keep_running = 1;
void
signal_handler(int dummy)
{
keep_running = 0;
}
int
main(int argc, char **argv)
{
signal(SIGTERM, signal_handler);
signal(SIGINT, signal_handler);
const char dev[] = "string";
printf("Variable before: \"%s\"\n", dev);
void *handle = lvm2_init();
lvm2_exit(handle);
while (keep_running) {
int arr_len = (random()%320+1) * 1024;
char **table = malloc(sizeof(char *) * arr_len);
assert(table);
for (size_t i=0; i<arr_len; i++) {
table[i] = strdup(dev);
assert(table[i]);
}
char *big_alloc = malloc(arr_len * 1024);
big_alloc[0] = '\0';
big_alloc[4095] = '\0';
big_alloc[arr_len * 1024 - 4096] = '\0';
printf("Some text to output\n");
char *string = strdup("Other text");
printf("Variable after: \"%s\"\n", table[arr_len/2]);
free(string);
free(big_alloc);
for (size_t i=0; i<arr_len; i++) {
free(table[i]);
}
free(table);
//sleep(1);
}
return 0;
}
--
Hubert Kario
hubert at kario.pl kario at wit.edu.pl https://hubert.kario.pl
PGP: 30D7 71F5 2F6F B157 872C D811 A1D0 6BC9 8956 DCFE
-------------- next part --------------
devices {
dir = "/dev"
scan = [ "/dev" ]
obtain_device_list_from_udev = 1
preferred_names = [ ]
filter = [ "a/.*/" ]
cache_dir = "/etc/lvm/cache"
cache_file_prefix = ""
write_cache_state = 1
sysfs_scan = 1
multipath_component_detection = 1
md_component_detection = 1
md_chunk_alignment = 1
data_alignment_detection = 1
data_alignment = 0
data_alignment_offset_detection = 1
ignore_suspended_devices = 0
disable_after_error_count = 0
require_restorefile_with_uuid = 1
pv_min_size = 2048
issue_discards = 0
}
allocation {
maximise_cling = 1
mirror_logs_require_separate_pvs = 0
thin_pool_metadata_require_separate_pvs = 0
}
log {
verbose = 0
syslog = 1
overwrite = 0
level = 0
indent = 1
command_names = 0
prefix = " "
}
backup {
backup = 1
backup_dir = "/etc/lvm/backup"
archive = 1
archive_dir = "/etc/lvm/archive"
retain_min = 10
retain_days = 30
}
shell {
history_size = 100
}
global {
umask = 077
test = 0
units = "h"
si_unit_consistency = 1
activation = 1
proc = "/proc"
locking_type = 1
wait_for_locks = 1
fallback_to_clustered_locking = 1
fallback_to_local_locking = 1
locking_dir = "/var/lock/lvm"
prioritise_write_locks = 1
abort_on_internal_errors = 0
detect_internal_vg_cache_corruption = 0
metadata_read_only = 0
mirror_segtype_default = "mirror"
use_lvmetad = 0
thin_check_executable = ""
thin_check_options = [ "-q" ]
}
activation {
checks = 0
udev_sync = 1
udev_rules = 1
verify_udev_operations = 0
retry_deactivation = 1
missing_stripe_filler = "error"
use_linear_target = 1
reserved_stack = 64
reserved_memory = 8192
process_priority = -18
mirror_region_size = 512
readahead = "auto"
raid_fault_policy = "warn"
mirror_log_fault_policy = "allocate"
mirror_image_fault_policy = "remove"
snapshot_autoextend_threshold = 100
snapshot_autoextend_percent = 20
thin_pool_autoextend_threshold = 100
thin_pool_autoextend_percent = 20
use_mlockall = 0
monitoring = 1
polling_interval = 15
}
dmeventd {
mirror_library = "libdevmapper-event-lvm2mirror.so"
snapshot_library = "libdevmapper-event-lvm2snapshot.so"
thin_library = "libdevmapper-event-lvm2thin.so"
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/linux-lvm/attachments/20120802/16cab231/attachment.sig>
More information about the linux-lvm
mailing list