#166316 sgrep: Assert violated common.c:845

Package:
sgrep
Source:
sgrep
Description:
tool to search a file for structured pattern
Submitter:
Date:
2025-07-13 13:47:02 UTC
Severity:
wishlist
#166316#5
Date:
2002-10-25 12:11:06 UTC
From:
To:
- Launching the command
./sgrep -o "\n%r\n" 'FIRST_IN(("if" .. ("(" ..  ")")), "if" not in (C_COMMENTS
or C_PREPROCS) .. ("(" ..  ")"))' file.c

- On the following file (file.c):
#ifdef
#else
#define
#endif
#ifdef
#else
#define F (param)
#endif
C();
C();
if (C) {
}

- Leads to the following error message:
sgrep: common.c:845: check_add_region: Assertion `l->length==0 ||
l->sorted!=START_SORTED || ((l)->last->list[(l)->length-1]).start<s ||
(((l)->last->list[(l)->length-1]).start=\=s &&
((l)->last->list[(l)->length-1]).end<e)' failed.
Aborted (core dumped)

Please confirm it can be reproduced.

Suggested fix: Warn user who read man (in BUGS section) if appropriate.

#166316#10
Date:
2025-07-13 13:45:41 UTC
From:
To:
Control: found -1 1.94a-7+b1

Indeed.

sgrep: common.c:801: check_add_region: Assertion `l->length==0 || l->sorted!=START_SORTED || LAST_NODE(l).start<s || (LAST_NODE(l).start==s && LAST_NODE(l).end<e)' failed.
[1]    406867 abort (core dumped)  sgrep -o "\n%r\n"  file.c