News for hackers. Stuff that matters.
Re:Parsing integers quickly with AVX-512 by rwmj on Monday September 25, 2023 @04:59AM (#37641103)
Does this handle the case where you try to parse a short string which is abutting the end of a page, and the next page is unmapped? The problem is you over-read and crash when you try to read the unmapped page. Looking at the code it doesn't seem to take account of that case. (On the other hand, maybe the AVX instructions don't do an actual read if the field is masked? In which case it would be fine.)

We had a similar case with some AVX-optimized string operation in glibc.

Re:Parsing integers quickly with AVX-512 by anonymoushn on Monday September 25, 2023 @05:15AM (#37641216)
It looks like the instructions handle this https://stackoverflow.com/questions/54497141/when-using-a-ma...
Re:Parsing integers quickly with AVX-512 by Findecanor on Monday September 25, 2023 @08:07AM (#37642426)
Yes. The bounds from the std::string are used to create a read-mask which is used in a masked load that does not fault on lanes outside the mask.

If the length had been unknown (say, a C-style null-terminated string) then the code would have needed to be more complex. You would either have to find the length before-hand or done only aligned loads. BTW. ARM's SVE and RISC-V's Vector extension have special "first fault" load-instructions that make that case simpler: they instead modify the vector's mask/length to the lowest-numbered lane that would have faulted.