Issue354

Title Fails when kernel arch and userspace arch don't match
Priority bug Status resolved
Superseder Nosy List drk, kayhayen
Assigned To kayhayen Keywords compiler_crash, debian

Created on 2017-02-04.15:16:49 by drk, last changed by kayhayen.

Messages
msg2499 (view) Author: kayhayen Date: 2018-08-23.23:18:06
The develop release has no fibers anymore, and therefore the linker arch is only 
used on Windows now.
msg2191 (view) Author: kayhayen Date: 2017-07-19.10:26:36
There is no straightforward way to get at the real architecture it seems, I was hesitant to 
lie about it, making e.g. "i686" up.

Fortunately, all uses of the target arch will go away in a future release, because fibers 
will become unused, and because I am solving a TODO, that is to detect the linker arch from 
the Python binary with objdump. Then only Windows should use that information to make any 
real decision.

This will however need other issues to be solved first, specifically generators without 
fibers  will require a full more release cycle at least.

Yours,
Kay
msg2127 (view) Author: drk Date: 2017-02-06.12:22:45
Hi, thanks for your prompt reply. Here is the output of functions you may be
interested in. These are from standard Debian python packages.

$ python
Python 2.7.9 (default, Aug 13 2016, 16:41:35) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os, platform, sys
>>> os.uname()[4]
'x86_64'
>>> platform.machine()
'x86_64'
>>> platform.architecture()
('32bit', 'ELF')
>>> sys.maxint
2147483647
>>> sys.version
'2.7.9 (default, Aug 13 2016, 16:41:35) \n[GCC 4.9.2]'


$ python3
Python 3.4.2 (default, Oct  8 2014, 13:14:40) 
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os, platform, sys
>>> os.uname()[4]
'x86_64'
>>> platform.machine()
'x86_64'
>>> platform.architecture()
('32bit', 'ELF')
>>> sys.version
'3.4.2 (default, Oct  8 2014, 13:14:40) \n[GCC 4.9.1]'
>>> sys.maxsize
2147483647
msg2126 (view) Author: kayhayen Date: 2017-02-06.07:57:13
Hello there,

Nuitka uses the os.uname(), specifically element 4, which is coming from the 
kernel, and wrong, agreed. What about platform.machine(), what does it say in 
your case? And what about platform.architecture(). The later seems the best, but 
doesn't give identifiers to easily match.

Otherwise, of course, "sys.maxint" could be abused, to switch around. Similar is 
already done for Windows, using "sys.version" looking for AMD64, where probably 
"sys.maxint" might be a better trick too.

Yours,
Kay
msg2125 (view) Author: drk Date: 2017-02-04.15:16:49
Build fails when the architecture of the kernel and toolchain doesn't match in
Linux.

For example, this system has 64 bit kernel and 32 bit everything else.

$ uname -m
x86_64
$ dpkg --print-architecture 
i386
$ nuitka --verbose --debug hello.py 
Nuitka:DEBUG:hello.py:1 : new_expression : Using original '__file__' value.
hello.build/swapfiber.S: Assembler messages:
hello.build/swapfiber.S:41: Error: bad register name `%rbx'
hello.build/swapfiber.S:42: Error: bad register name `%rbp'
hello.build/swapfiber.S:43: Error: bad register name `%r12'
hello.build/swapfiber.S:44: Error: bad register name `%r13'
hello.build/swapfiber.S:45: Error: bad register name `%r14'
hello.build/swapfiber.S:46: Error: bad register name `%r15'
hello.build/swapfiber.S:48: Error: bad register name `%rdi'
hello.build/swapfiber.S:49: Error: bad register name `%rsi'
hello.build/swapfiber.S:50: Error: bad register name `%rdx'
hello.build/swapfiber.S:51: Error: bad register name `%rcx'
hello.build/swapfiber.S:52: Error: bad register name `%r8'
hello.build/swapfiber.S:53: Error: bad register name `%r9'
hello.build/swapfiber.S:55: Error: bad register name `%rsp)'
hello.build/swapfiber.S:56: Error: bad register name `%rcx'
hello.build/swapfiber.S:59: Error: bad register name `%rsp)'
hello.build/swapfiber.S:60: Error: bad register name `%rcx'
hello.build/swapfiber.S:63: Error: bad register name `%rdi)'
hello.build/swapfiber.S:64: Error: bad register name `%rcx'
hello.build/swapfiber.S:67: Error: bad register name `%rsi)'
hello.build/swapfiber.S:68: Error: bad register name `%rsi)'
hello.build/swapfiber.S:69: Error: bad register name `%rsi)'
hello.build/swapfiber.S:70: Error: bad register name `%rsi)'
hello.build/swapfiber.S:71: Error: bad register name `%rsi)'
hello.build/swapfiber.S:72: Error: bad register name `%rsi)'
hello.build/swapfiber.S:73: Error: bad register name `%rsi)'
hello.build/swapfiber.S:76: Error: bad register name `%rsi)'
hello.build/swapfiber.S:77: Error: bad register name `%rcx'
hello.build/swapfiber.S:80: Error: bad register name `%rsi)'
hello.build/swapfiber.S:81: Error: bad register name `%rsi)'
hello.build/swapfiber.S:82: Error: bad register name `%rsi)'
hello.build/swapfiber.S:83: Error: bad register name `%rsi)'
hello.build/swapfiber.S:84: Error: bad register name `%rsi)'
hello.build/swapfiber.S:87: Error: bad register name `%rsi)'
scons: *** [hello.build/swapfiber.o] Error 1
hello.build/fibers_x64.cpp: In function 'int _prepareFiber(Fiber*, void*,
uintptr_t)':
hello.build/fibers_x64.cpp:55:69: error: 'ar[1]' may be used uninitialized in
this function [-Werror=maybe-uninitialized]
     makecontext( &to->f_context, (void (*)())code, 2, ar[0], ar[1] );
                                                                     ^
cc1plus: all warnings being treated as errors
scons: *** [hello.build/fibers_x64.o] Error 1

It works fine when we fake the architecture:

$ linux32 nuitka --verbose --debug hello.py
Nuitka:DEBUG:hello.py:1 : new_expression : Using original '__file__' value.
$ ./hello.exe 
hello world
History
Date User Action Args
2018-08-23 23:18:06kayhayensetstatus: deferred -> resolved
assignedto: kayhayen
messages: + msg2499
nosy: + kayhayen
2017-07-19 10:26:36kayhayensetstatus: chatting -> deferred
messages: + msg2191
keyword: + compiler_crash, debian
2017-02-06 12:22:45drksetmessages: + msg2127
2017-02-06 07:57:13kayhayensetstatus: unread -> chatting
messages: + msg2126
2017-02-04 15:16:49drkcreate