This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gdb crash: double free with free_objfile

>>>>> "Mathieu" == Mathieu Lacage <> writes:

Mathieu> a. make the duplicate entries point to private duplicates of
Mathieu> struct objfile *

Mathieu> b. make the duplicate entries point to a shared struct objfile and
Mathieu> add refcounting or some means to detect when the struct objfile is
Mathieu> shared.

Mathieu> I could implement a. by removing the for loop at the top of
Mathieu> symbol_add_stub but I suspect that there is a good reason for its
Mathieu> presence and that removing it would create some waste of memory in
Mathieu> other cases so, it's probably not a good idea to do this.

Mathieu> I am not totally sure that b. is correct to do. i.e., I _think_ (but I
Mathieu> am not sure) that the content of struct objfile is not dependent upon
Mathieu> the base address of the corresponding binary so I _think_ that it
Mathieu> should be safe to reuse the same one between two so_list entries
Mathieu> loaded at different base addresses. Am I wrong ? If so, my only option
Mathieu> is a but I the proposed 'fix' described above is probably not good. Is
Mathieu> there anyone with a better suggestion ?

Nope, right now objfile has the base address baked in to many things,
e.g. symbol addresses or psymtabs_addrmap.  I think we'd like to change
this, so that we can share objfiles between inferiors, but nobody has
tried to do that yet.  I don't know how hard this would be.

Your quickest route is probably a form of (a) -- change symbol_add_stub
to check both the file name and the base address.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]