Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s390: v8tests.cctest/test-platform/StackAlignment in v8 tests #7659

Closed
mhdawson opened this issue Jul 11, 2016 · 8 comments
Closed

s390: v8tests.cctest/test-platform/StackAlignment in v8 tests #7659

mhdawson opened this issue Jul 11, 2016 · 8 comments
Labels
v8 engine Issues and PRs related to the V8 dependency.

Comments

@mhdawson
Copy link
Member

  • Version: master
  • Platform: linux/s390
  • Subsystem: dep/v8

Just added s390 to the v8 tests we run nightly. Shows failure in these tests:
https://ci.nodejs.org/job/node-test-commit-v8-linux/nodes=rhel72-s390x,v8test=v8test/196/

We don't see these failures in the google sim runs for 390 nor do we see them in our internal builds on real hardware for 5.1

=== cctest/test-platform/StackAlignment ===
Command: /data/iojs/build/workspace/node-test-commit-v8-linux/nodes/rhel72-s390x/v8test/v8test/deps/v8/out/s390x.release/cctest --random-seed=2016406410 test-platform/StackAlignment --nohard-abort --nodead-code-elimination --nofold-constants
exit code: -11
--- CRASHED ---
=== cctest/test-platform/StackAlignment ===
Command: /data/iojs/build/workspace/node-test-commit-v8-linux/nodes/rhel72-s390x/v8test/v8test/deps/v8/out/s390x.release/cctest --random-seed=2016406410 --stress-opt --always-opt test-platform/StackAlignment --nohard-abort --nodead-code-elimination --nofold-constants
exit code: -11
--- CRASHED ---
=== cctest/test-platform/StackAlignment ===
Command: /data/iojs/build/workspace/node-test-commit-v8-linux/nodes/rhel72-s390x/v8test/v8test/deps/v8/out/s390x.release/cctest --random-seed=2016406410 --turbo test-platform/StackAlignment --nohard-abort --nodead-code-elimination --nofold-constants
exit code: -11
--- CRASHED ---

@mhdawson mhdawson added the v8 engine Issues and PRs related to the V8 dependency. label Jul 11, 2016
@john-yan
Copy link

Looks like the test is checking stack alignment requirement is met. I could not reproduce it on our systems.

@bnoordhuis
Copy link
Member

Compiler issue, maybe? The test executes this on s390x:

__asm__ __volatile__("stg 15, %0" : "=g"(sp_addr));

Perhaps it solves the constraint in a way that emits wrong/illegal code?

@mhdawson If you can get a disassembly of the GetStackPointer() function, that might be helpful.

@joransiu
Copy link
Contributor

Managed to reproduce this on a local system. @bnoordhuis was on the right track.

   0x80436278 <_Z15GetStackPointerRKN2v820FunctionCallbackInfoINS_5ValueEEE>:   stmg    %r13,%r15,104(%r15)
   0x8043627e <_Z15GetStackPointerRKN2v820FunctionCallbackInfoINS_5ValueEEE+6>: lay %r15,-168(%r15)
=> 0x80436284 <_Z15GetStackPointerRKN2v820FunctionCallbackInfoINS_5ValueEEE+12>:    stg %r15,-450104

We crashed on the STG, which ended up generating the wrong memory reference... -450104 doesn't look right at all. Need to dig into how the compiler expanded the sp_addr in the inlined asm.

GCC compiler level:

gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

@joransiu
Copy link
Contributor

Looking at the object file, we do see a reloc entry for the stg to reference sp_addr. Except, it's uncertain how you can manage to reference the static without a proper base register... it's as if the compiler has confused stg's memory operand as a relative offset instead.

Disassembly of section .bss._ZL7sp_addr:

0000000000000000 <_ZL7sp_addr>:
        ...

Disassembly of section .text._Z15GetStackPointerRKN2v820FunctionCallbackInfoINS_5ValueEEE:

0000000000000000 <_Z15GetStackPointerRKN2v820FunctionCallbackInfoINS_5ValueEEE>:
   0:   eb bf f0 58 00 24       stmg    %r11,%r15,88(%r15)
   6:   e3 f0 ff 20 ff 71       lay     %r15,-224(%r15)
   c:   b9 04 00 bf             lgr     %r11,%r15
  10:   e3 20 b0 a0 00 24       stg     %r2,160(%r11)
  16:   e3 f0 00 00 00 24       stg     %r15,0
                        18: R_390_20    .bss._ZL7sp_addr

Interestingly, compiling with GCC 4.8.3, we get a slightly different sequence with an extra larl instruction that is a relative instruction that can address sp_addr.

0000000000000000 <_Z15GetStackPointerRKN2v820FunctionCallbackInfoINS_5ValueEEE>:
   0:   eb df f0 68 00 24       stmg    %r13,%r15,104(%r15)
   6:   c0 10 00 00 00 00       larl    %r1,6 <_Z15GetStackPointerRKN2v820FunctionCallbackInfoINS_5ValueEEE+0x6>
                        8: R_390_PC32DBL        .bss._ZL7sp_addr+0x2
   c:   a7 fb ff 58             aghi    %r15,-168
  10:   e3 f0 10 00 00 24       stg     %r15,0(%r1)

@bnoordhuis
Copy link
Member

Would changing the constraint from =g to =r suffice as a workaround for now? Untested:

diff --git a/deps/v8/test/cctest/test-platform.cc b/deps/v8/test/cctest/test-platform.cc
index 6012fd4..abcb475 100644
--- a/deps/v8/test/cctest/test-platform.cc
+++ b/deps/v8/test/cctest/test-platform.cc
@@ -25,7 +25,7 @@ void GetStackPointer(const v8::FunctionCallbackInfo<v8::Value>& args) {
 #elif V8_HOST_ARCH_MIPS64
   __asm__ __volatile__("sd $sp, %0" : "=g"(sp_addr));
 #elif defined(__s390x__) || defined(_ARCH_S390X)
-  __asm__ __volatile__("stg 15, %0" : "=g"(sp_addr));
+  __asm__ __volatile__("stg 15, %0" : "=r"(sp_addr));
 #elif defined(__s390__) || defined(_ARCH_S390)
   __asm__ __volatile__("st 15, %0" : "=g"(sp_addr));
 #elif defined(__PPC64__) || defined(_ARCH_PPC64)

@joransiu
Copy link
Contributor

joransiu commented Jul 14, 2016

I believe what we want instead is =m, to force the sp_addr to be a memory operand.

@joransiu
Copy link
Contributor

Sorry, was swamped today with other stuff. I've confirmed that =m constraint does resolve the issue. In this case, it's the more proper choice, given the specific assembly instruction (stg) we are trying to use. We don't have to rely on the compiler to try to work out which of the operand variants to treat the 'general' constraint.

I'd like to make the change to this into V8 as well, and will float it back over once it's committed there.

@joransiu
Copy link
Contributor

V8 CL .. pending approval: https://codereview.chromium.org/2158523002/

joransiu added a commit to joransiu/node that referenced this issue Jul 19, 2016
Original commit message:

S390:Update inline asm constraint in test-platform
The GetStackPointer() routine in test-platform uses an inline
assembly code to store the current stack pointer value into a static
variable sp_addr.  The existing asm code for S390 uses an ST/STG
instruction, with the memory operand associated with the general ('=g')
constraint to sp_addr.

On GCC 4.8.5, the GCC compiler got confused and treated sp_addr as
an integer operand instead of memory operand, resulting in a store
being emitted that writes to an invalid meory location.

Given the specific store instructions being inlined here, we should
restict the sp_addr operand to explicitly be a memory operand using '=m'
instead of '=g'.

[email protected],[email protected],[email protected],[email protected]
BUG=

Review-Url: https://codereview.chromium.org/2158523002
Cr-Commit-Position: refs/heads/master@{nodejs#37809}

Fixes: nodejs#7659
targos pushed a commit to targos/node that referenced this issue Jul 26, 2016
Original commit message:

S390:Update inline asm constraint in test-platform
The GetStackPointer() routine in test-platform uses an inline
assembly code to store the current stack pointer value into a static
variable sp_addr.  The existing asm code for S390 uses an ST/STG
instruction, with the memory operand associated with the general ('=g')
constraint to sp_addr.

On GCC 4.8.5, the GCC compiler got confused and treated sp_addr as
an integer operand instead of memory operand, resulting in a store
being emitted that writes to an invalid meory location.

Given the specific store instructions being inlined here, we should
restict the sp_addr operand to explicitly be a memory operand using '=m'
instead of '=g'.

[email protected],[email protected],[email protected],[email protected]
BUG=

Review-Url: https://codereview.chromium.org/2158523002
Cr-Commit-Position: refs/heads/master@{nodejs#37809}

Fixes: nodejs#7659
PR-URL: nodejs#7771
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Ali Ijaz Sheikh <[email protected]>
ofrobots pushed a commit to ofrobots/node that referenced this issue Aug 25, 2016
Original commit message:

S390:Update inline asm constraint in test-platform
The GetStackPointer() routine in test-platform uses an inline
assembly code to store the current stack pointer value into a static
variable sp_addr.  The existing asm code for S390 uses an ST/STG
instruction, with the memory operand associated with the general ('=g')
constraint to sp_addr.

On GCC 4.8.5, the GCC compiler got confused and treated sp_addr as
an integer operand instead of memory operand, resulting in a store
being emitted that writes to an invalid meory location.

Given the specific store instructions being inlined here, we should
restict the sp_addr operand to explicitly be a memory operand using '=m'
instead of '=g'.

[email protected],[email protected],[email protected],[email protected]
BUG=

Review-Url: https://codereview.chromium.org/2158523002
Cr-Commit-Position: refs/heads/master@{nodejs#37809}

Fixes: nodejs#7659
PR-URL: nodejs#7771
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Ali Ijaz Sheikh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v8 engine Issues and PRs related to the V8 dependency.
Projects
None yet
Development

No branches or pull requests

4 participants