linux-lvm.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Hubert Kario <hubert@kario.pl>
To: Alasdair G Kergon <agk@redhat.com>
Cc: linux-lvm@redhat.com
Subject: Re: [linux-lvm] [lvm2cmd] Heap destruction by lvm2_exit()?
Date: Thu, 02 Aug 2012 12:16:08 +0200	[thread overview]
Message-ID: <2897273.IW82gCqcCL@bursa22> (raw)
In-Reply-To: <20120802015017.GH11876@agk-dp.fab.redhat.com>


[-- Attachment #1.1: Type: text/plain, Size: 2167 bytes --]

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@kario.pl     kario@wit.edu.pl    https://hubert.kario.pl
PGP: 30D7 71F5 2F6F B157 872C  D811 A1D0 6BC9 8956 DCFE

[-- Attachment #1.2: lvm.conf --]
[-- Type: text/plain, Size: 2393 bytes --]

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"
}

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2012-08-02 10:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-31 23:23 [linux-lvm] [lvm2cmd] Heap destruction by lvm2_exit()? Hubert Kario
2012-08-01 12:24 ` Alasdair G Kergon
2012-08-01 16:17   ` Hubert Kario
2012-08-02  1:46     ` Alasdair G Kergon
2012-08-02  1:50     ` Alasdair G Kergon
2012-08-02 10:16       ` Hubert Kario [this message]
2012-08-03  9:56       ` Hubert Kario

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2897273.IW82gCqcCL@bursa22 \
    --to=hubert@kario.pl \
    --cc=agk@redhat.com \
    --cc=linux-lvm@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).