bugGNU patch - Bugs: bug #56681, Assertion `tp_char[0] == '*''...


bug #56681: Assertion `tp_char[0] == '*'' failed

Submitter:  Manh-Dung Nguyen <strongcourage>
Submitted:  Sat 27 Jul 2019 04:45:14 PM UTC
Category:  Parser / Internal Representation Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup

Sun 28 Jul 2019 08:08:04 AM UTC, comment #2: 

The bug happens here:
src/pch.c:2574: p_Char[p_end] = *buf;
  p_end == 0
  buf = "-  0\320\066X\n"

Patch thinks this is the third hunk of a difftype = CONTEXT_DIFF patch.  Here, p_Char[0] changes from '*' to '-', which is illegal because p_Char[0] must always be '*'.  (p_Char represents the types of lines in the internal representation of a hunk.)  This is later caught here:

src/pch.c:2154: assert(tp_char[0] == '*');

Andreas Gruenbacher <agruen>
Group administrator
Sat 27 Jul 2019 05:29:37 PM UTC, comment #1: 

Sorry I deleted the attached patch by accident; I've re-added it now.

Andreas Gruenbacher <agruen>
Group administrator
Sat 27 Jul 2019 04:45:14 PM UTC, original submission:  


I found an assertion failure that causes the program patch (the latest commit 76e7758 on master) to abort.

PoC: https://github.com/strongcourage/PoCs/blob/master/patch_76e7758/PoC_aborted
Command: patch -Rf < $PoC -o /tmp/out

Valgrind says:
The next patch, when reversed, would delete the file L��X,
which does not exist!  Applying it anyway.
(Patch is indented 8 spaces.)
patching file L��X
patch: ../../src/pch.c:2154: pch_swap: Assertion `tp_char[0] == '*'' failed.
==19175== Process terminating with default action of signal 6 (SIGABRT)
==19175==    at 0x4E6F428: raise (raise.c:54)
==19175==    by 0x4E71029: abort (abort.c:89)
==19175==    by 0x4E67BD6: __assert_fail_base (assert.c:92)
==19175==    by 0x4E67C81: __assert_fail (assert.c:101)
==19175==    by 0x424CD4: pch_swap (pch.c:2154)
==19175==    by 0x42CA54: another_hunk (pch.c:1912)
==19175==    by 0x404AE9: main (patch.c:408)

Manh Dung

Manh-Dung Nguyen <strongcourage>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #47272:  PoC_aborted added by agruen (199B - application/octet-stream)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by agruen (Updated the item)
  • -email is unavailable- added by strongcourage (Submitted the item)
  • -email is unavailable- added by strongcourage

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.


    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-07-28 agruen CategoryNone Parser / Internal Representation
    2019-07-27 agruen Attached File- Added PoC_aborted, #47272
    2019-07-27 agruen Attached File#47271 Removed
    2019-07-27 strongcourage Attached File- Added PoC_aborted, #47271
        Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code