After declaring with two recursive functions (and a few other functions), marshaling fails with the error:
Fatal error: exception Invalid_argument("output_value: abstract value (outside heap)"). It does not fail if we change the order of declaration of the two recursive functions.

Marshalling f fails. The weird thing is that it does not fail if we change the order of declarations of the recursive functions. It also does not fail if we remove the call to g in f. Marshalling test_list works.

The bug happens with bytecode and native code. It does not happen in OCaml 3.12.1 .

Indeed I can confirm that Jacques-Henri's patch fixes the issue. I have uploaded ccpasteur's initial example as patch to modify the existing "lib-marshal" testsuite, that makes apparent the issue and its solution, while allowing to check that the fix didn't break any of the lib-marshal tests.

Indeed, I did not intend to mean that the patch were bad, just that a "git bisect" showed that the error appeared precisely there. I did review the first one at the time (obviously I missed this problem), and I think they're kind of cool -- defunctionalization in the real world!

Regarding the current patch release, Damien will decide (because that would be work for him in the end), but indeed I think that would be a good idea.