Skip to content

serialisation - add FREEZE and THAW support #510

@shawnlaffan

Description

@shawnlaffan

Serialisation using Sereal, and presumably other such systems, results in fatal errors. Reproducer below, along with its output.

Fixing this should (one hopes) just be a case of adding FREEZE and THAW methods, as documented at https://metacpan.org/pod/Sereal::Encoder#FREEZE%2FTHAW-CALLBACK-MECHANISM

Similar code has already been added for Storable via PDL::IO::Storable so it should be a case of reusing that.

I'll run some testing and if it works then I'll raise a PR.

#  reproducer
use strict;
use warnings;
use 5.014;
use PDL;
use Sereal qw/decode_sereal encode_sereal/;
my $x = decode_sereal encode_sereal (xvals(25,25));

say 'Result:';
say '=====';
say $x;
say '=====';
say 'Script completed';
Result:
=====
Stringizing problem: Fatal error: argument is probably not an ndarray, or magic no overwritten. You're in trouble, guv: 2453f26e5a8 245412ebf40 1111638597
 at C:/perls/5.40.0.1_PDL/perl/vendor/lib/PDL/Core.pm line 3294.
        PDL::string(PDL=SCALAR(0x2453f26e5a8), undef, "") called at serialise.pl line 9
        (in cleanup) Fatal error: argument is probably not an ndarray, or magic no overwritten. You're in trouble, guv: 2453f26e5a8 245412ebf40 1111638597

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