X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f X-Recipient: geda-user AT delorie DOT com X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prochac.sk; s=default; t=1475863932; bh=8iTSdFc+Sd5qB4ydK1iO5Qwfm3yEzQbDvBH5Kd+LIms=; h=Subject:To:References:From:Date:In-Reply-To; b=EOI8iK6+Ktd/7jqys3YTkRhupgeEwW+5jyFg6YaFgh2+hXYQ3KB72T/WV9JUySevx qZ4u/3Bk0XxNZHmzi4PY9CVGJZ1K8vh/hMgnrjF+qNikMyvjWa4I/RFtrJvtgzxcVT /fanKCYOBWfxKtWA0yBDFwzzdJIweije0CpE1QDY= X-Clacks-Overhead: "GNU Terry Pratchett" Subject: Re: [geda-user] Segfault bug in PCB? To: geda-user AT delorie DOT com References: <1475747077 DOT 18232 DOT 10 DOT camel AT linetec> From: "Milan Prochac (milan AT prochac DOT sk) [via geda-user AT delorie DOT com]" Message-ID: <5d74ff3f-1470-7745-33b3-385d98cfb961@prochac.sk> Date: Fri, 7 Oct 2016 20:11:59 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="------------ms040201040603040609040401" X-Spam-Status: No, score=-101.0 required=5.0 tests=ALL_TRUSTED,HTML_MESSAGE, USER_IN_WHITELIST autolearn=ham autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on angua.bastl.sk Reply-To: geda-user AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: geda-user AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk This is a cryptographically signed message in MIME format. --------------ms040201040603040609040401 Content-Type: multipart/alternative; boundary="------------96955411A521CB110C484C44" This is a multi-part message in MIME format. --------------96955411A521CB110C484C44 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Thank you for comments. I made new patch which accepted your proposal=20 and added some more changes. See=20 https://bugs.launchpad.net/pcb/+bug/1631059 Comments in text... > On 07.10.2016 16:41, Chad Parker (parker DOT charles AT gmail DOT com) [via=20 > geda-user AT delorie DOT com] wrote: > Someone with more experience please correct me if I'm wrong, but I=20 > think that removing the text from the rtree is basically the entire=20 > point of EraseText. It removes the object from the rtree, and flags=20 > the area for being redrawn. If the object is removed from the rtree=20 > then it wont be found when drawing occurs, and so it wont be drawn.=20 > So, I'm not sure that commenting that line is the right thing to do. > EraseText also adds the bounding box of text to area to be redrawn, like = any other Erase... functions. But only EraseText removes the entity from = rtree, no other Erase... function does it. I think that major purpose of = EraseText function should be to invalidate drawing area. Just for code=20 clarity. > It looks like, in most cases, you can get away with commenting this=20 > line because almost all of the functions that call EraseText also try=20 > to remove the object from the rtree anyway, but not all of them. If=20 > you compile with debugging enabled, you get a failed assertion in when = > you change text. Just put some text on an empty layout, put the arrow=20 > over it, hit n, input new text, hit enter, and crash. > Well, in that case it's better to add removal from rtree in function=20 ChangeTextName (done in new patch)... Then the use of EraseText /=20 DrawText function pairs and r_delete_entry / r_insert_entry pairs will=20 be more symmetrical and better understandable. The only other function=20 which needs the r_delete_entry to be added is RemoveText function. (done = in new patch) But other functions - like text move, rotate - use r_delete_entry and =20 r_insert_entry in pairs and r_delete_entry in EraseText is IMO redundant.= I tested this time with debug turned on, no more assertions. > I think maybe a the error is actually in EraseObject, which calls=20 > EraseText for both TEXT_TYPE and ELEMENTNAME_TYPE. This is problematic = > for two reasons. First, if EraseObject is getting an element name,=20 > then as you noted, lptr will be pointing to an element not a layer=20 > (the result of SearchObjectByID), as you pointed out. Second, the text = > types associated with element names are not stored in the layer rtree, = > but rather in one of the PCB->Data rtrees. > > I think a better solution is that when EraseObject gets an=20 > ELEMENTNAME_TYPE, it should call EraseElementName instead of EraseText.= > That's good idea, but technically the EraseElementName calls DrawText=20 function to invalidate drawing area. DrawText does exactly the same as=20 EraseText function, except that r_delete_entry call. This does not look=20 like clear coding style. So I agree that we should call the EraseElementName, which in turn can=20 call modified updated EraseText. (done in new patch) > I pushed this fix to the repo home/cparker/LP1631059. > > This has highlighted a couple other problems though. When you undo=20 > changing the size of a text type (not an element name) it disappears.=20 > There's also an issue of UndoChangeSize using the Thickness parameter, = > which is of type Coord, but for text objects, the Size parameter is of = > type int. So there's still a mismatch there. Could be the cause and=20 > effect. I'll look into it a bit more later. > I did not notice that any text disappearing while undoing size change... = but it disappears after undoing the text creation :) For text objects the Scale parameter is used. It's type of int, but=20 sizeof(Coord) should be >=3D than sizeof(int). So for time being it shoul= d=20 be OK to accept the type impurity without changing the data structures. But it is very easy to extend the Undo data structure by new "Scale"=20 property to safely store the text Scale value. (done in new patch) Milan > --Chad > > > > On Thu, Oct 6, 2016 at 12:26 PM, Milan Prochac (milan AT prochac DOT sk=20 > ) [via geda-user AT delorie DOT com=20 > ] > wrote: > > On 06.10.2016 11:44, Richard Rasker (rasker AT linetec DOT nl > ) [via geda-user AT delorie DOT com > ] wrote: > > Hello, > > There appears to be a little segfault problem in PCB version > 1.99z, > build Sep 13 2016 at 08:12:51, used on Linux Mint 17.3 KDE: > > When I change the size of a RefDes text using the S key, and > then try to > undo this action using the U key, PCB crashes. This also > happens when > the resize action is followed by other actions; when subsequent= ly > undoing these using U, PCB crashes the moment that it tries to > undo the > RefDes text resize. As far as I can tell, this bug only > pertains to > Refdes text, not to other elements. > > It's not a big deal, but still a little annoying to have some > minutes of > work vanish when unthinkingly pressing the U key. > > Best regards, > > Richard Rasker > > > Bug logged and patch provided here: > https://bugs.launchpad.net/pcb/+bug/1631059 > > > Patch solves the issue (2 issues in fact), undo/redo works fine. > But second pair of eyes should check if the patch has some > unwanted side effects. More details on Launchpad. > > Milan > > > --------------96955411A521CB110C484C44 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

Thank you for comments. I made new patch which accepted your proposal and added some more changes. See https://bugs.launchpad.net/pcb/+bug/1631059
=
Comments in text...

On 07.10.2016 16:41, Chad Parker (parker DOT charles AT gmail= =2Ecom) [via geda-user AT delorie DOT com] wrote:
Someone with more experience please correct me if I'm wrong, but I think that removing the text from the rtree is basically the entire point of EraseText. It removes the object from the rtree, and flags the area for being redrawn. If the object is removed from the rtree then it wont be found when drawing occurs, and so it wont be drawn. So, I'm not sure that commenting that line is the right thing to do.


EraseText also adds the bounding box of text to area to be redrawn, like any other Erase... functions. But only EraseText removes the entity from rtree, no other Erase... function does it. I think that major purpose of EraseText function should be to invalidate drawing area. Just for code clarity.


It looks like, in most cases, you can get away with commenting this line because almost all of the functions that call EraseText also try to remove the object from the rtree anyway, but not all of them. If you compile with debugging enabled, you get a failed assertion in when you change text. Just put some text on an empty layout, put the arrow over it, hit n, input new text, hit enter, and crash.


Well, in that case it's better to add removal from rtree=C2=A0 in function ChangeTextName (done in new patch)... Then the use of EraseText / DrawText function pairs and r_delete_entry / r_insert_entry pairs will be more symmetrical and better understandable. The only other function which needs the r_delete_entry to be added is RemoveText function. (done in new patch)

But other functions - like text move, rotate - use r_delete_entry and=C2=A0 r_insert_entry in pairs and r_delete_entry in EraseText is = IMO redundant.

I tested this time with debug turned on, no more assertions.

I think maybe a the error is actually in EraseObject, which calls EraseText for both TEXT_TYPE and ELEMENTNAME_TYPE. This is problematic for two reasons. First, if EraseObject is getting an element name, then as you noted, lptr will be pointing to an element not a layer (the result of SearchObjectByID), as you pointed out. Second, the text types associated with element names are not stored in the layer rtree, but rather in one of the PCB->Data rtrees.

I think a better solution is that when EraseObject gets an ELEMENTNAME_TYPE, it should call EraseElementName instead of EraseText.


That's good idea, but technically the EraseElementName calls DrawText function to invalidate drawing area. DrawText does exactly the same as EraseText function, except that r_delete_entry call. This does not look like clear coding style.

So I agree that we should call the EraseElementName, which in turn can call modified updated EraseText. (done in new patch)

I pushed this fix to the repo home/cparker/LP1631059.

This has highlighted a couple other problems though. When you undo changing the size of a text type (not an element name) it disappears. There's also an issue of UndoChangeSize using the Thickness parameter, which is of type Coord, but for text objects, the Size parameter is of type int. So there's still a mismatch there. Could be the cause and effect. I'll look into it a bit more later.


I did not notice that any text disappearing while undoing size change... but it disappears after undoing the text creation :)

For text objects the Scale parameter is used.=C2=A0 It's type of int,= but sizeof(Coord) should be >=3D than sizeof(int). So for time being i= t should be OK to accept the type impurity without changing the data structures.

But it is very easy to extend the Undo data structure by new "Scale" property to safely store the text Scale value. (done in new patch)
Milan



--Chad



On Thu, Oct 6, 2016 at 12:26 PM, Milan= Prochac (milan AT prochac DOT sk) [via <= a moz-do-not-send=3D"true" href=3D"mailto:geda-user AT delorie DOT com= ">geda-user AT delorie DOT com] <ged= a-user AT delorie DOT com> wrote:
On 06.10.2016 11:44, Richard Rasker (rasker AT linetec DOT nl) [via geda-user AT delorie DOT com] wrote:
Hello,

There appears to be a little segfault problem in PCB version 1.99z,
build Sep 13 2016 at 08:12:51, used on Linux Mint 17.3 KDE:

When I change the size of a RefDes text using the S key, and then try to
undo this action using the U key, PCB crashes. This also happens when
the resize action is followed by other actions; when subsequently
undoing these using U, PCB crashes the moment that it tries to undo the
RefDes text resize. As far as I can tell, this bug only pertains to
Refdes text, not to other elements.

It's not a big deal, but still a little annoying to have some minutes of
work vanish when unthinkingly pressing the U key.

Best regards,

Richard Rasker

Bug logged and patch provided here: https://bugs.launchpad= =2Enet/pcb/+bug/1631059

Patch solves the issue (2 issues in fact), undo/redo works fine. But second pair of eyes should check if the patch has some unwanted side effects. More details on Launchpad.

Milan




--------------96955411A521CB110C484C44-- --------------ms040201040603040609040401 Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgkqhkiG9w0BBwEAAKCC CtowggTwMIID2KADAgECAhBqqLAGfunD4XYlcEsP4ElzMA0GCSqGSIb3DQEBCwUAMHUxCzAJ BgNVB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