question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Segmentation fault on unrelated Python exceptions

See original GitHub issue

I’d like to use pyosmium using Python 3.6.2. When running the following example code (based on https://github.com/osmcode/pyosmium/blob/master/examples/osm_file_stats.py ) using Python 3, I get a Segmentation fault (core dumped) message (caused by the last line of code) with no additional info. However, running the same code using Python 2.7.15+, gives me a proper error message.

My question is not about this specific example, but about the combination of python3 and pyosmium in general: How would I debug such errors (and why aren’t any proper error messages displayed)?

import osmium as o
import sys

class FileStatsHandler(o.SimpleHandler):

    def __init__(self):
        super(FileStatsHandler, self).__init__()
        self.nodes = 0

    def node(self, n):
        self.nodes += 1

if __name__ == '__main__':
    if len(sys.argv) != 2:
        print("Usage: python osm_file_stats.py <osmfile>")
        sys.exit(-1)

    h = FileStatsHandler()

    h.apply_file(sys.argv[1])

    print("Nodes: %d" % h.nodes)
    print("Nodes: " + h.nodes) # XXX: h.nodes should be str(h.nodes)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
lonviacommented, Feb 24, 2019

We’ve found the culprit. Ubuntu’s apport installs a special exception handler which segfaults when trying to handle the exception. The workaround is to simply uninstall it: sudo apt-get remove python3-apport

I wouldn’t rule out that there is something wrong with the way we build the binaries that makes apport fail or that some resources are not properly freed but I’m at a loss how to debug that.

0reactions
lonviacommented, Mar 5, 2020

manylinux2020 binaries are now available. Be aware that a recent version of pip is necessary. The one that is shipped with Ubuntu is too old.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Segmentation fault (core dumped) - python
"Segmentation fault (core dumped)" is the string that Linux prints when a program exits with a SIGSEGV signal and you have core creation ......
Read more >
Segfault when using pickle with exceptions and dynamic class ...
msg350932 ‑ (view) Author: Gabriel C (gabrielc) Date: 2019‑08‑31 23:39 msg351547 ‑ (view) Author: Gabriel C (gabrielc) Date: 2019‑09‑09 19:01 msg401240 ‑ (view) Author: Irit...
Read more >
Issue 17408: second python execution fails when embedding
The reason is in Objects/typeobject.c: import_copyreg() has a static cache of the copyreg module. When the interpreter stops, the module is ...
Read more >
Segfault in test_re.test_sre_character_class_literals() when ...
The longobject.c warnings are almost certainly unrelated to the test_re crash ... For the segfault issue, best guess is that it's a compiler ......
Read more >
KeyboardInterrupt causes segmentation fault with threads
Investigation with gdb shows that the error occurs within ... Here's the patch with the irrelevant stuff from my new-style exceptions work ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found