Skip to content

Error with stop_before_partial in 7.1.0 #797

@trflynn89

Description

@trflynn89

Hello,

We're using simdutf in Ladybird for our implementation of the JS Base64 proposal. I recently tried updating to simdutf 7.1.0 and ran into some test failures with the stop_before_partial option.

For example, this test:
https://github.com/tc39/test262/blob/5132804523bd0493cb51ef654fffd3193224fdac/test/built-ins/Uint8Array/fromBase64/last-chunk-handling.js#L13

assert.compareArray(Uint8Array.fromBase64('ZXhhZg==', { lastChunkHandling: 'stop-before-partial' }), [101, 120, 97, 102]);

Here's that test translated to c++ with simdutf:

#include <array>
#include <cstdio>
#include <string_view>
#include <tuple>

#include <simdutf.h>

int main()
{
    static constexpr auto decode_up_to_bad_character = true;

    std::string_view input = "ZXhhZg==";
    std::array<char, 4> output {};

    auto result = simdutf::base64_to_binary_safe(
        input,
        output,
        simdutf::base64_default,
        simdutf::last_chunk_handling_options::stop_before_partial,
        decode_up_to_bad_character);

    printf("result: %d\n", std::get<0>(result).error);

    printf("output:");
    for (size_t i = 0; i < std::get<1>(result); ++i) {
        printf(" %d", output[i]);
    }
    printf("\n");
}

The output I get from that test:

result: 0
output length = 3
output: 101 120 97

So according to the JS proposal's expectations, we are one byte short with simdutf - missing the 102 value at the end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions