[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug] lost mktemp reference?
- To: hlwm devel <herbstluftwm _minus_ devel _at_ lists _dot_ sourceforge _dot_ net>
- Subject: Re: [Bug] lost mktemp reference?
- From: Thorsten Wißmann <edu _at_ thorsten _minus_ wissmann _dot_ de>
- Date: Mon, 25 Mar 2013 03:09:36 +0100
Hi Tylo,
thank you very much!
On Sun, Mar 24, 2013 at 02:47:15PM -0700, Tyler Thomas Hart wrote:
> Ive found the 'where' of this problem, but I have yet to find the
> 'why'.
>
> http://web.cecs.pdx.edu/~htyler/gitweb/?p=herbstlogic;a=blob;f=scripts/shift.out;h=0a29a9b0c
>
> This is the script Im trying to run. Ive linked to a gitweb for
> reference only (with herbstlogic pretty- print :D), Ill copy/paste the
> runnable arguments below.
Nice, I already thought about implementing a pretty printer for
commands, but using the tree-styled output and completely hiding the
separator names.
> The problem lies on line 60. When I substitute an attribute with a
> MUCH greater recursion level, it works fine. After line 60 though, the
> reference to the mktemp attribute 'delta' seems to get lost. When I
> attempt to dereference it at line 64, hlwm crashes. I assume this is a
> segfault because the reference is lost, but perhaps it is a different
> issue.
>
> You can try it yourself by removing line 60. Line 64 executes just
> fine.
Your "reference loosing" guess was right. I could not reproduce it with
your exact command but with:
mktemp string a mktemp string b set_attr a asdf
The problem occurred when setting the outer temporary variable within
the inner one. The reason: I dealt with constant pointers to the memory
where the data of temporary attribute was. By the inner `mktemp` that
data was shifted because of reallocing the attributes, but the pointer
to the value of "a" never was updated, so it crashed.
It's now fixed by commit 25755afbcbe[1]. Now the data is always at a
constant position because basically it is allocated independent from the
HSAttribute.
Thanks for your help,
Thorsten
[1] http://git.cs.fau.de/?p=hlwm;a=commitdiff;h=25755afbcbe