Skip to content

Commit 7b6e25e

Browse files
committed
The different xs_handshake() failures need distinct messages
xs_handshake() makes two different comparisons that on failure are reported as "got handshake key %p, needed %p", with opaque hexadecimal values. The first is the "actual" key as generated by the HS_KEY() macro, which encodes various values such as sizeof(PerlInterpreter) and the API version. The second is the address of the current thread's PerlInterpreter struct. Either can fail, and before this commit they would fail with identical text. Hence it wasn't obvious what the problem was, causing "confusion and delay" if one tried to decode the hexadecimal output as the wrong thing. (For example when it's actually pointers mismatching, but one tries to decode the values into API version and structure size, assuming that the values were the packed output from HS_KEY().)
1 parent d40d6ec commit 7b6e25e

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

pod/perldiag.pod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3420,7 +3420,7 @@ does when displayed.
34203420
\n line feed
34213421
\cK vertical tab
34223422

3423-
=item %s: loadable library and perl binaries are mismatched (got handshake key %p, needed %p)
3423+
=item %s: loadable library and perl binaries are mismatched (got %s handshake key %p, needed %p)
34243424

34253425
(P) A dynamic loading library C<.so> or C<.dll> was being loaded into the
34263426
process that was built against a different build of perl than the

util.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5588,6 +5588,7 @@ Perl_xs_handshake(const U32 key, void * v_my_perl, const char * file, ...)
55885588
U32 items, ax;
55895589
void * got;
55905590
void * need;
5591+
const char *stage = "first";
55915592
#ifdef MULTIPLICITY
55925593
dTHX;
55935594
tTHX xs_interp;
@@ -5624,12 +5625,13 @@ Perl_xs_handshake(const U32 key, void * v_my_perl, const char * file, ...)
56245625
got = xs_spp;
56255626
need = &PL_stack_sp;
56265627
#endif
5628+
stage = "second";
56275629
if(UNLIKELY(got != need)) {
56285630
bad_handshake:/* recycle branch and string from above */
56295631
if(got != (void *)HSf_NOCHK)
56305632
noperl_die("%s: loadable library and perl binaries are mismatched"
5631-
" (got handshake key %p, needed %p)\n",
5632-
file, got, need);
5633+
" (got %s handshake key %p, needed %p)\n",
5634+
file, stage, got, need);
56335635
}
56345636

56355637
if(key & HSf_SETXSUBFN) { /* this might be called from a module bootstrap */

0 commit comments

Comments
 (0)