asan_symbolize.py: SyntaxError: invalid syntax

67 views
Skip to first unread message

nolo...@gmail.com

unread,
Mar 15, 2014, 10:17:20 AM3/15/14
to address-...@googlegroups.com
Hi Gentleman,

I managed to get myself in more trouble. This time with asan_symbolize.py.

$ make | asan_symbolize.py
  File "/usr/local/bin/asan_symbolize.py", line 69
    print ' '.join(cmd)
            ^
SyntaxError: invalid syntax

Here's the relevant snippet:

  def open_llvm_symbolizer(self):
    if not os.path.exists(self.symbolizer_path):
      return None
    cmd = [self.symbolizer_path,
           '--use-symbol-table=true',
           '--demangle=%s' % demangle,
           '--functions=true',
           '--inlining=true']
    if DEBUG:
      print ' '.join(cmd)
    return subprocess.Popen(cmd, stdin=subprocess.PIPE,
                            stdout=subprocess.PIPE)

The odd thing is DEBUG=false (and I'm not changing it).

If I comment out the:

    if DEBUG:
      print ' '.join(cmd)

Then the issue moves down the line to line 81:

$ make | asan_symbolize.py
  File "/usr/local/bin/asan_symbolize.py", line 81
    print symbolizer_input
                         ^
Which is:

      if DEBUG:
        print symbolizer_input

Changing the declaration of DEBUG to DEBUG=0 does not help; and deleting the declaration of DEBUG does not help.

Any ideas on how to proceed?

Alexander Potapenko

unread,
Mar 15, 2014, 10:50:50 AM3/15/14
to address-...@googlegroups.com

Which Python version are you using?
What happens if you invoke the script as 'python asan_symbolize.py'?

You'll also need to redirect stderr into stdout (2>&1), because ASan prints the reports into stderr.

--
You received this message because you are subscribed to the Google Groups "address-sanitizer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to address-saniti...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jeffrey Walton

unread,
Mar 15, 2014, 11:00:19 AM3/15/14
to address-...@googlegroups.com
On Sat, Mar 15, 2014 at 10:50 AM, Alexander Potapenko
<ramosia...@gmail.com> wrote:
> Which Python version are you using?
$ python --version
Python 3.3.5

$ which python
/usr/local/bin/python

It was built from sources because I needed SSL's server name
indication (SNI) of Python 3.x. The version installed in
/usr/local/bin was a standard build, and lacks any instrumentation
like Asan and UBsan.

> What happens if you invoke the script as 'python asan_symbolize.py'?

Here are the two results:

$ /usr/local/bin/python /usr/local/bin/asan_symbolize.py
File "/usr/local/bin/asan_symbolize.py", line 69
print ' '.join(cmd)
^
SyntaxError: invalid syntax

$ /usr/bin/python /usr/local/bin/asan_symbolize.py
^C

So it looks like something is broken with my build of 3.3.

> You'll also need to redirect stderr into stdout (2>&1), because ASan prints
> the reports into stderr.
Ah, right... I forgot about that. Thanks.

Thanks for the help. (Would you know what I should do next, before I
head over to the Stack Overflow).

Jeff

Yuri Gribov

unread,
Mar 15, 2014, 11:40:49 AM3/15/14
to address-...@googlegroups.com
I believe llvm_symbolizer expects python2 interpreter. You could try
one of these
* install your Python 3 as /usr/local/bin/python3 to avoid shadowing
default system Python
* explicitly run llvm_symbolizer under Python2 interpreter
* update asan_symbolizer.py using 2to3

-Y

Jeffrey Walton

unread,
Mar 15, 2014, 11:47:26 AM3/15/14
to address-...@googlegroups.com
Yes, you are right (again!). I just found
http://stackoverflow.com/questions/3367899/print-syntax-error-with-python-3.

The script appears to work with both interpreters if there are parens
around the print arguments.

Python is brutal for someone who does not know it (I'm a C/C++/ObjC
guy). I'm amazed that basic functionality such as print was broken
between 2 & 3. Imagine if printf stopped working in C99!

(And I'm not buying into that argument that Python is fast and easy.
It took me two days to get a Python working with SSL that provided
SNI).

Jeff

Yuri Gribov

unread,
Mar 15, 2014, 12:25:30 PM3/15/14
to address-...@googlegroups.com
On Sat, Mar 15, 2014 at 7:47 PM, Jeffrey Walton <nolo...@gmail.com> wrote:
> Python is brutal for someone who does not know it (I'm a C/C++/ObjC
> guy). I'm amazed that basic functionality such as print was broken
> between 2 & 3. Imagine if printf stopped working in C99!

Oh, don't get me started. After years of Python scripting I'm yet to
understand why people like this language so much.

-Y
Reply all
Reply to author
Forward
0 new messages