pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/47906: lang/g95: SEGV occurs when stack address is not aligned 8 bytes at main().



>Number:         47906
>Category:       pkg
>Synopsis:       lang/g95: SEGV occurs when stack address is not aligned 8 
>bytes at main().
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jun 07 14:00:00 +0000 2013
>Originator:     NONAKA Kimihiro
>Release:        NetBSD/i386 6.99.21
>Organization:
>Environment:
NetBSD netbsd-vm 6.99.21 NetBSD 6.99.21 (KOHARU) #17: Thu Jun  7 10:23:42 JST 
2013  nonaka@netbsd-vm:/usr/obj.i386/sys/arch/i386/compile/KOHARU i386
>Description:
If the stack address is not aligned on 8 bytes, it is adjusted to 8 bytes 
aligned at main(). 
If stack address is adjusted, to get from the stack address the wrong return 
address, SEGV occurs.
>How-To-Repeat:
On my NetBSD/i386 environment, testversion occur SEGV when building 
pkgsrc/math/lapack.
>Fix:
Before returning from main() function, restore stack address.

Index: distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/lang/g95/distinfo,v
retrieving revision 1.15
diff -u -r1.15 distinfo
--- distinfo    20 May 2013 05:47:34 -0000      1.15
+++ distinfo    7 Jun 2013 13:15:07 -0000
@@ -26,3 +26,4 @@
 SHA1 (patch-libf95.a-0.93_math_ff.c) = 353121bc08a86765d18b0e6f051ba91f7e65e9c2
 SHA1 (patch-libf95.a-0.93_math_x87.S) = 
d1eb02bd2358b6abb9b8dc3e32629cba540adcc4
 SHA1 (patch-libf95.a-0.93_quad_power16.c) = 
fc7375aa90ecf75bb8ba26d41739614040b16e09
+SHA1 (patch-libf95.a-0.93_runtime_main.c) = 
d103084758ae48e6afa67f48f20010f176b6de4d
Index: patches/patch-libf95.a-0.93_runtime_main.c
===================================================================
RCS file: patches/patch-libf95.a-0.93_runtime_main.c
diff -N patches/patch-libf95.a-0.93_runtime_main.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-libf95.a-0.93_runtime_main.c  7 Jun 2013 13:15:07 -0000
@@ -0,0 +1,28 @@
+$NetBSD$
+
+--- libf95.a-0.93/runtime/main.c.orig  2010-04-19 00:47:28.000000000 +0900
++++ libf95.a-0.93/runtime/main.c       2013-06-07 16:22:22.000000000 +0900
+@@ -50,9 +50,11 @@
+  * unaligned. */
+ 
+ #if HAVE_REAL_10 == 1 || HAVE_REAL_10 == 2
++    int diff;
+     asm("mov %%esp, %%eax\n"
+       "and $0x04, %%eax\n"
+-      "sub %%eax, %%esp\n" : : : "%eax");
++      "movl %%eax, %0\n"
++      "sub %%eax, %%esp\n" : "=r"(diff) : : "%eax");
+ #endif
+ 
+     g95_runtime_start(argc, argv);
+@@ -62,5 +64,10 @@
+     memory_done();
+     g95_runtime_stop();
+ 
++#if HAVE_REAL_10 == 1 || HAVE_REAL_10 == 2
++    asm("mov %0, %%eax\n"
++      "add %%eax, %%esp\n" : : "r"(diff) : "%eax");
++#endif
++
+     return 0;
+ }



Home | Main Index | Thread Index | Old Index