Bug 6561 - second dwfl smashes first dwfl's sysroot
Summary: second dwfl smashes first dwfl's sysroot
Status: RESOLVED FIXED
Alias: None
Product: frysk
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-05-25 22:31 UTC by Andrew Cagney
Modified: 2008-06-11 19:35 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Cagney 2008-05-25 22:31:36 UTC
In the below, since the flags and callbacks are static, each call to dwflBegin
smashes the previous structure.

jlong
lib::dwfl::Dwfl::dwflBegin(jnixx::env env, jstring jsysroot) {
  jstringUTFChars sysroot = jsttringUTFChars(env, jsysroot);
  static char* flags;
  if (asprintf (&flags, ".debug:%s", sysroot) < 0)
    return (jlong) NULL;

  static Dwfl_Callbacks callbacks = {
    &::dwfl_frysk_proc_find_elf,
    &::dwfl_standard_find_debuginfo,
    NULL,
    &flags,
  };
  return (jlong) ::dwfl_begin(&callbacks);
}
Comment 1 Andrew Cagney 2008-06-11 19:35:23 UTC
minecommit 4c67208accaec119dcda3f2ec795e8e98584a740
Author: Andrew Cagney <cagney@redhat.com>
Date:   Tue Jun 3 16:32:15 2008 -0400

    Dynamically allocate/free the dwfl callback struct.
    
    The change to store a per-dwfl debug-info path in the dwfl callback
    struct wasn't accompanied by a change to allocate the callback struct
    dynamically.  Consequently each successive dwfl-begin call was
    overwriting the previous debug-info path.
    
    frysk-sys/lib/dwfl/ChangeLog
    2008-06-03  Andrew Cagney  <cagney@redhat.com>
    
        * Dwfl.java (callbackBegin, callbackEnd): New.
        (Dwfl(String), close()): Use.
        * cni/Dwfl.cxx: Update.
        * jni/Dwfl.cxx: Update.