in reply to perl +xs : crash after some time

Look into running your app under valgrind. It's the first thing I turn to when I experience crashes or other issues with my C/XS code.

update: Completely overlooked this is Windows here, and valgrind doesn't work there. However, there may be an alternative. See this SO post for example.

Another option, if you're on win10, using the windows bash thingy.

Replies are listed 'Best First'.
Re^2: perl +xs : crash after some time
by frazap (Monk) on Nov 03, 2017 at 16:07 UTC

    I'm on Windows 10, but without the anniversary update (and I have no options on update plan)

    In fact if I run the code given here Re^6: Win32::API and keyboard hook, I can crash perl after some/many keystrokes.

    The error messages is emit at the call of the perl sub:

    Attempt to change a readonly variable

    or

    Odd number of elements in hash assignment

    I pass a sub reference to be called by the c hook function, and it's the code that receive the parameters from the c function that crash:

    sub { my ($cup, $code, $alt, $ext) = @_; .... }

      Code looks nice and contained in your example. I'll try to get a chance to poke around over the course of the weekend and see if I can reproduce/come up with a debugging procedure.

      -stevieb