Segmentation fault on unrelated Python exceptions
See original GitHub issueI’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:
- Created 5 years ago
- Comments:13 (9 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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.