[Privoxy-devel] PATCH for pcre2 support

Gagan Sidhu broly at mac.com
Mon Jun 19 14:40:17 CEST 2023



> On Jun 19, 2023, at 4:00 AM, Fabian Keil <fk at fabiankeil.de> wrote:
> 
> Fabian Keil <fk at fabiankeil.de> wrote on 2023-06-19 at 11:30:31:
> 
>> Fabian Keil <fk at fabiankeil.de> wrote on 2023-06-19 at 09:20:17:
>> 
>>> Gagan Sidhu <broly at mac.com> wrote on 2023-06-18 at 08:44:35:
>>> 
>>>> test 17, i assume? since after i ran the program with your change, i had one failed test:
>>> 
>>> No it's test 383:
>>> 
>>> (gdb) where
>>> #0  kill () at kill.S:4
>>> #1  0x00000008008926e0 in __fail (msg=0x80079c824 "stack overflow detected; terminated") at /usr/src/lib/libc/secure/stack_protector.c:130
>>> #2  0x0000000800892650 in __stack_chk_fail () at /usr/src/lib/libc/secure/stack_protector.c:137
>>> #3  0x000000000024abed in rewrite_url (old_url=0x80246d000 "http://go.eniro.dk/lg/ni/http:/eas8.emediate.eu/eas?camp=79;ty=ct;EASLink=http://www.bt.dk?http://redirect.metropol.dk/cgi-bin/redir.pl?url=www.bt.dk", 
>>>    pcrs_command=0x801cac140 "s at .*url=@http://@") at filters.c:1038
>>> #4  0x000000000024acf7 in redirect_url (csp=0x800ef2c08) at filters.c:1257
>>> #5  0x00000000002583b5 in crunch_response_triggered (csp=0x800ef2c08, crunchers=0x218920 <crunchers_all>) at jcc.c:953
>>> #6  0x00000000002568bb in chat (csp=0x800ef2c08) at jcc.c:4438
>>> #7  0x0000000000255736 in serve (csp=0x800ef2c08) at jcc.c:5056
>>> #8  0x000000080073ca7a in thread_start (curthread=0x800e13c00) at /usr/src/lib/libthr/thread/thr_create.c:292
>>> #9  0x0000000000000000 in ?? ()
>>> Backtrace stopped: Cannot access memory at address 0x7fffdf9fb000
>> 
>> The attached patch seems to fix this. (It will not cleanly apply
>> to your tree as I made other changes in the region in previous
>> commits).
> 
thanks for changing that error pointer to PCRE2_SIZE, i didn’t know it could cause an issue.

> I'm not seeing different crashes like this one, though:
> 
> #0  0x0000000823c95acd in ?? () from /usr/local/lib/libpcre2-8.so.0
> [Current thread is 1 (LWP 108957)]
> (gdb) where
> #0  0x0000000823c95acd in ?? () from /usr/local/lib/libpcre2-8.so.0
> #1  0x0000000823c9002a in pcre2_match_8 () from /usr/local/lib/libpcre2-8.so.0
> #2  0x00000008255e60fe in pcre2_regexec () from /usr/local/lib/libpcre2-posix.so.3
> #3  0x000000000027309b in path_matches (path=0x856e3c040 "/iomm/latest/bootstrap/stub.js", pattern=0x82a2c5f20) at urlmatch.c:1360
> #4  0x0000000000272e7e in url_match (pattern=0x82a2c5f20, http=0x835520a58) at urlmatch.c:1387
> #5  0x000000000024cfa8 in apply_url_actions (action=0x835520810, http=0x835520a58, client_tags=0x835520ba0, b=0x82a2c5f20) at filters.c:2884
> #6  0x000000000024cf11 in get_url_actions (csp=0x835520808, http=0x835520a58) at filters.c:2845
> #7  0x00000000002580ac in process_encrypted_request_headers (csp=0x835520808) at jcc.c:2799
> #8  0x0000000000256a03 in chat (csp=0x835520808) at jcc.c:4472
> #9  0x0000000000255796 in serve (csp=0x835520808) at jcc.c:5056
> #10 0x0000000825a07a7a in thread_start (curthread=0x8355a6000) at /usr/src/lib/libthr/thread/thr_create.c:292
> #11 0x0000000000000000 in ?? ()
> Backtrace stopped: Cannot access memory at address 0x843d01000
> 
> I haven't been able to reproduce this yet.

i didn’t report that one, haha. who did?

it seems these are “teething problems” when moving from pcre1 to pcre2?

it’s possible that the new data structure we must use, pcre2_matches, needs to be “bigger” than PCRS_MAX_SUBMATCHES.

the cleanest way i can think of, would be to change from

> pcre2_match_data_create(PCRS_MAX_SUBMATCHES, NULL)


to

> pcre2_match_data_create_from_pattern(job->pattern, NULL)



that way, it’s allocated according to the pattern.

sha256sum is 

c1d2ac55d13e583a2276ab31240cde0ab779653abfdb4db1315001fbc95430af

i’ve updated my patch on sourceforge with this change, i ran the regression tests and nothing changes for me (just the elsainsights fails. i have no diea why. probably because i’m on a mac)

p.s. how come you can send patches via the list, but i can’t? perks of being ’the boss’, i assume? ;)

> 
> Fabian
> _______________________________________________
> Privoxy-devel mailing list
> Privoxy-devel at lists.privoxy.org
> https://lists.privoxy.org/mailman/listinfo/privoxy-devel



More information about the Privoxy-devel mailing list