Bug#759803: python-llvm: Causes segfault on printing certain values

Robert robert.w.bliss at gmail.com
Sat Aug 30 15:26:10 UTC 2014


Package: python-llvm
Version: 0.12.6-2
Severity: important

Dear Maintainer,

python-llvm (llvm-py upstream) has been giving me quite a few issues
lately.

I wrote a quick test to see how easy it would be to generate some code
with it, and kept getting segfaults. That was a red flag right away;
python code shouldn't ever segfault unless you're doing something
strange.

I boiled it down to a MWE, attached below with some notes on where
segfaults happen. I also ran a backtrace with gdb to see where it was
segfaulting, although I didn't do any digging through source files to
see where improper checking/other bugs might be.

-- System Information:
Debian Release: jessie/sid
  APT prefers testing-updates
  APT policy: (500, 'testing-updates'), (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 3.14-1-686-pae (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages python-llvm depends on:
ii  libc6       2.19-7
ii  libffi6     3.1-2
ii  libgcc1     1:4.9.1-4
ii  libllvm3.4  1:3.4.2-6
ii  libstdc++6  4.9.1-4
ii  libtinfo5   5.9+20140712-2
ii  python      2.7.8-1

python-llvm recommends no packages.

python-llvm suggests no packages.

-- no debconf information

*** /home/rwb/python/parse/test.py
import llvm.core as llvm

module = llvm.Module.new("main")
int = llvm.Type.int()

func = llvm.Function.new(module, int, "main")
block = func.append_basic_block("entry")
builder = llvm.Builder.new(block)

# Segfault.
# print(func)

left = llvm.Constant.int(int, 1)
right = llvm.Constant.int(int, 1)

print(left)
print(right)

tmp = builder.add(left, right, "tmp")

# Segfault.
# print(block)

# Unclear if this should be 0 or 1.
print(len(block.instructions))
builder.ret(tmp)
print(len(block.instructions))
print(block.instructions[0].opcode_name)

# Segfault.
print(block.instructions[0])

*** /home/rwb/python/parse/gdb.txt
Starting program: /usr/bin/python test.py
warning: Could not load shared library symbols for linux-gate.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/i686/cmov/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0xb60aec55 in llvm::Function::BuildLazyArguments() const () from /usr/lib/i386-linux-gnu/libLLVM-3.4.so.1
#0  0xb60aec55 in llvm::Function::BuildLazyArguments() const () from /usr/lib/i386-linux-gnu/libLLVM-3.4.so.1
#1  0xb613fc25 in llvm::TypeFinder::run(llvm::Module const&, bool) ()
   from /usr/lib/i386-linux-gnu/libLLVM-3.4.so.1
#2  0xb604f32a in llvm::TypePrinting::incorporateTypes(llvm::Module const&) ()
   from /usr/lib/i386-linux-gnu/libLLVM-3.4.so.1
#3  0xb6051ac7 in llvm::AssemblyWriter::init() () from /usr/lib/i386-linux-gnu/libLLVM-3.4.so.1
#4  0xb6051b84 in llvm::AssemblyWriter::AssemblyWriter(llvm::formatted_raw_ostream&, llvm::SlotTracker&, llvm::Module const*, llvm::AssemblyAnnotationWriter*) () from /usr/lib/i386-linux-gnu/libLLVM-3.4.so.1
#5  0xb6058df1 in llvm::Value::print(llvm::raw_ostream&, llvm::AssemblyAnnotationWriter*) const ()
   from /usr/lib/i386-linux-gnu/libLLVM-3.4.so.1
#6  0xb78ff3ed in ?? () from /usr/lib/python2.7/dist-packages/llvmpy/_api.so
#7  0x08104248 in PyEval_EvalFrameEx ()
#8  0x080ff28d in PyEval_EvalCodeEx ()
#9  0x08101f4b in PyEval_EvalFrameEx ()
#10 0x08118e25 in ?? ()
#11 0x08134317 in ?? ()
#12 0x08107919 in PyEval_CallObjectWithKeywords ()
#13 0x081bf23d in ?? ()
#14 0x0816715c in ?? ()
#15 0x080f3018 in ?? ()
#16 0x0810125f in PyEval_EvalFrameEx ()
#17 0x08118e25 in ?? ()
#18 0x08134317 in ?? ()
#19 0x08107919 in PyEval_CallObjectWithKeywords ()
#20 0x081bf23d in ?? ()
#21 0x08157a97 in PyObject_Str ()
#22 0x08156235 in ?? ()
#23 0x08155ca8 in PyFile_WriteObject ()
#24 0x081059c4 in PyEval_EvalFrameEx ()
#25 0x080ff28d in PyEval_EvalCodeEx ()
#26 0x08132e5c in ?? ()
#27 0x0812a2b8 in PyRun_FileExFlags ()
#28 0x0812948a in PyRun_SimpleFileExFlags ()
#29 0x080d4b74 in Py_Main ()
#30 0x080d45fb in main ()
quit
A debugging session is active.

	Inferior 1 [process 24157] will be killed.

Quit anyway? (y or n)



More information about the Pkg-llvm-team mailing list