- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一个奇怪的错误,现在在 2 台机器上重复出现。它可能仅限于 python 2.7 64 位,但目前还不清楚。在 Mac OS X 10.7 上,我得到:段错误:11在 10.6 上,每当我关闭 python 时,我都会收到一个简单的“段错误”。
但是,错误很难重现。简单的 python 脚本,例如: python -c "导入 sys;打印 sys.maxint"打开和关闭没有问题。
我怀疑 matplotlib 有问题,但同样 python -c “导入 pylab;pylab.plot();pylab.show()”也不会遇到任何问题。
但是,有许多不同的包确实会在 python 关闭时导致段错误,但不会在交互式 session 期间发生,也不会发生在脚本完成之前。因此,该错误不会影响我的任何代码 - 但它会在 10.7 中运行任何内容时造成困惑,因为会弹出焦点窃取错误消息。
我会努力列出并记录导致崩溃的脚本/模块,但我想我现在应该提出这个问题,看看是否有其他人遇到过类似的问题。
这是引用示例(感谢 Ned 的建议)。
Process: python2.7 [42731]
Path: /usr/local/bin/python
Identifier: python2.7
Version: ??? (???)
Code Type: X86-64 (Native)
Parent Process: bash [1838]
Date/Time: 2011-09-16 20:38:52.847 -0600
OS Version: Mac OS X 10.7.1 (11B2118)
Report Version: 9
Interval Since Last Report: 11388 sec
Crashes Since Last Report: 12
Per-App Crashes Since Last Report: 11
Anonymous UUID: CE462F4B-5DAF-482A-8901-28ADB7AB0AD6
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000008
VM Regions Near 0x8:
-->
__TEXT 0000000100000000-0000000100001000 [ 4K] r-x/rwx SM=COW /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Application Specific Information:
objc[42731]: garbage collection is OFF
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 org.python.python 0x00000001000c3f71 new_threadstate + 305
1 org.python.python 0x00000001000c3fe8 PyGILState_Ensure + 40
2 h5e.so 0x0000000106558c21 __pyx_f_4h5py_3h5e_err_callback + 33 (h5e.c:2045)
3 libhdf5.7.dylib 0x0000000106323940 H5E_dump_api_stack + 144
4 libhdf5.7.dylib 0x0000000106320428 H5Eget_auto2 + 136
5 libhdf5.7.dylib 0x00000001062bf2f0 H5_term_library + 64
6 libsystem_c.dylib 0x00007fff8ff1b7d0 __cxa_finalize + 282
7 libsystem_c.dylib 0x00007fff8ff1b652 exit + 18
8 python 0x0000000100000e51 _start + 255
9 python 0x0000000100000d51 start + 33
Thread 1:: Dispatch queue: com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x00007fff8bcfd7e6 kevent + 10
1 libdispatch.dylib 0x00007fff8bdf760e _dispatch_mgr_invoke + 923
2 libdispatch.dylib 0x00007fff8bdf619e _dispatch_mgr_thread + 54
Thread 2:
0 libsystem_kernel.dylib 0x00007fff8bcfd192 __workq_kernreturn + 10
1 libsystem_c.dylib 0x00007fff8ff2a594 _pthread_wqthread + 758
2 libsystem_c.dylib 0x00007fff8ff2bb85 start_wqthread + 13
Thread 3:
0 libsystem_kernel.dylib 0x00007fff8bcfd192 __workq_kernreturn + 10
1 libsystem_c.dylib 0x00007fff8ff2a594 _pthread_wqthread + 758
2 libsystem_c.dylib 0x00007fff8ff2bb85 start_wqthread + 13
Thread 4:
0 libsystem_kernel.dylib 0x00007fff8bcfd192 __workq_kernreturn + 10
1 libsystem_c.dylib 0x00007fff8ff2a594 _pthread_wqthread + 758
2 libsystem_c.dylib 0x00007fff8ff2bb85 start_wqthread + 13
Thread 5:
0 libsystem_kernel.dylib 0x00007fff8bcfcdf2 __select + 10
1 Tcl 0x00000001022eb80b NotifierThreadProc + 558
2 libsystem_c.dylib 0x00007fff8ff288bf _pthread_start + 335
3 libsystem_c.dylib 0x00007fff8ff2bb75 thread_start + 13
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000001 rbx: 0x0000000000000001 rcx: 0x0000000000000b00 rdx: 0x00007fff5fbff034
rdi: 0x00000a0000000b03 rsi: 0x00000b0000000b00 rbp: 0x00007fff5fbff0c0 rsp: 0x00007fff5fbff0a0
r8: 0x00007fff5fbff03c r9: 0x00007fff5fbff038 r10: 0x0000000000000081 r11: 0x00000000e33a913f
r12: 0x00000001062bf2b0 r13: 0x0000000000000000 r14: 0x0000000000000000 r15: 0x0000000101bd05a0
rip: 0x00000001000c3f71 rfl: 0x0000000000010202 cr2: 0x0000000000000008
Logical CPU: 0
Binary Images:
0x100000000 - 0x100000fff +python (??? - ???) <BA9D2124-1753-3A21-91BE-15C8CD5FE7F3> /usr/local/bin/python
0x100003000 - 0x100142fe7 +org.python.python (, [c] 2004-2011 Python Software Foundation. - ???) <C6142A6D-0D50-32D9-A058-2A2BA484D94E> /Library/Frameworks/Python.framework/Versions/2.7/Python
--SNIP - TOO LONG--
0x7fff98338000 - 0x7fff9841cdef libobjc.A.dylib (228.0.0 - compatibility 1.0.0) <C5F2392D-B481-3A9D-91BE-3D039FFF4DEC> /usr/lib/libobjc.A.dylib
External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 6
thread_create: 0
thread_set_state: 0
Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 1288178
thread_create: 1
thread_set_state: 0
VM Region Summary:
ReadOnly portion of Libraries: Total=170.9M resident=77.2M(45%) swapped_out_or_unallocated=93.7M(55%)
Writable regions: Total=169.1M written=87.2M(52%) resident=111.0M(66%) swapped_out=1536K(1%) unallocated=58.2M(34%)
REGION TYPE VIRTUAL
=========== =======
CG image 4K
CG raster data 64K
CG shared images 3416K
CoreGraphics 16K
CoreServices 1800K
MALLOC 140.4M
MALLOC guard page 48K
Memory tag=242 12K
Memory tag=251 8K
STACK GUARD 56.0M
Stack 10.1M
VM_ALLOCATE 16.1M
__CI_BITMAP 80K
__DATA 15.6M
__IMAGE 1256K
__LINKEDIT 53.4M
__TEXT 117.5M
__UNICODE 544K
mapped file 30.4M
shared memory 308K
=========== =======
TOTAL 446.8M
产生相同(近似)错误的 C 代码:helloworld.cpp -
#include<iostream>
using namespace std;
int main() {
char *blah;
cout << "Hello World" << endl << "I am the C sea" << endl;
cin >> blah;
cout << blah << endl;
return 0;
}
编译者:
g++ helloworld.cpp -o helloworld.out
./helloworld.out
错误报告#2:
Process: helloworld.out [10982]
Path: /Users/USER/*/helloworld.out
Identifier: helloworld.out
Version: ??? (???)
Code Type: X86-64 (Native)
Parent Process: bash [10803]
Date/Time: 2011-09-24 09:36:43.979 -0600
OS Version: Mac OS X 10.7.1 (11B2118)
Report Version: 9
Interval Since Last Report: 271170 sec
Crashes Since Last Report: 119
Per-App Crashes Since Last Report: 4
Anonymous UUID: CE462F4B-5DAF-482A-8901-28ADB7AB0AD6
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: 0x000000000000000d, 0x0000000000000000
VM Regions Near 0:
-->
__TEXT 0000000104ca3000-0000000104ca4000 [ 4K] r-x/rwx SM=COW /Users/USER/*/*.out
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 helloworld.out 0x0000000104ca3d79 main + 169
1 ??? 0x0073657261757173 0 + 32481164257489267
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x0000000000000000 rcx: 0x0000000000000008 rdx: 0x0000000000000000
rdi: 0x00007fff7c8e24e8 rsi: 0x00007fab53000000 rbp: 0x00007fff648a28e0 rsp: 0x00007fff648a28d8
r8: 0x00000000fb343fb8 r9: 0x0000000000000000 r10: 0x0000000053000000 r11: 0x0000000000000246
r12: 0x0000000000000000 r13: 0x0000000000000000 r14: 0x0000000000000000 r15: 0x0000000000000000
rip: 0x0000000104ca3d79 rfl: 0x0000000000010202 cr2: 0x00007fab53001000
Logical CPU: 1
Binary Images:
0x104ca3000 - 0x104ca3ff7 +helloworld.out (??? - ???) <68FD4206-E8D6-340F-B25B-E2DE6FB1D3BC> /Users/USER/*/helloworld.out
0x7fff648a3000 - 0x7fff648d7ac7 dyld (195.5 - ???) <4A6E2B28-C7A2-3528-ADB7-4076B9836041> /usr/lib/dyld
0x7fff8bce6000 - 0x7fff8bd06fff libsystem_kernel.dylib (1699.23.2 - compatibility 1.0.0) <55377210-60A0-3F33-9D45-B2D19AA91859> /usr/lib/system/libsystem_kernel.dylib
0x7fff8bdf4000 - 0x7fff8be02fff libdispatch.dylib (187.5.0 - compatibility 1.0.0) <698F8EFB-7075-3111-94E3-891156C88172> /usr/lib/system/libdispatch.dylib
0x7fff8c415000 - 0x7fff8c41cfff libcopyfile.dylib (85.1.0 - compatibility 1.0.0) <65602684-33B1-32DE-802B-050CE07659AC> /usr/lib/system/libcopyfile.dylib
0x7fff8cf65000 - 0x7fff8cfa7ff7 libcommonCrypto.dylib (55010.0.0 - compatibility 1.0.0) <A5B9778E-11C3-3F61-B740-1F2114E967FB> /usr/lib/system/libcommonCrypto.dylib
0x7fff8cfcc000 - 0x7fff8cfccfff libkeymgr.dylib (23.0.0 - compatibility 1.0.0) <61EFED6A-A407-301E-B454-CD18314F0075> /usr/lib/system/libkeymgr.dylib
0x7fff8cfcd000 - 0x7fff8cfd1fff libmathCommon.A.dylib (2026.0.0 - compatibility 1.0.0) <FF83AFF7-42B2-306E-90AF-D539C51A4542> /usr/lib/system/libmathCommon.A.dylib
0x7fff8d001000 - 0x7fff8d006fff libcompiler_rt.dylib (6.0.0 - compatibility 1.0.0) <98ECD5F6-E85C-32A5-98CD-8911230CB66A> /usr/lib/system/libcompiler_rt.dylib
0x7fff8e5bb000 - 0x7fff8e5c3fff libsystem_dnssd.dylib (??? - ???) <1FA8F861-9D0D-33D2-939F-5BD382718B97> /usr/lib/system/libsystem_dnssd.dylib
0x7fff8e5d2000 - 0x7fff8e5d6fff libdyld.dylib (195.5.0 - compatibility 1.0.0) <F1903B7A-D3FF-3390-909A-B24E09BAD1A5> /usr/lib/system/libdyld.dylib
0x7fff8e67d000 - 0x7fff8e69aff7 libxpc.dylib (77.16.0 - compatibility 1.0.0) <1FEBB79D-8537-38A4-882D-1E2AE212CD31> /usr/lib/system/libxpc.dylib
0x7fff8e999000 - 0x7fff8e99fff7 libunwind.dylib (30.0.0 - compatibility 1.0.0) <1E9C6C8C-CBE8-3F4B-A5B5-E03E3AB53231> /usr/lib/system/libunwind.dylib
0x7fff8ebdd000 - 0x7fff8ebe8ff7 libc++abi.dylib (14.0.0 - compatibility 1.0.0) <8FF3D766-D678-36F6-84AC-423C878E6D14> /usr/lib/libc++abi.dylib
0x7fff8f110000 - 0x7fff8f111fff libsystem_sandbox.dylib (??? - ???) <8D14139B-B671-35F4-9E5A-023B4C523C38> /usr/lib/system/libsystem_sandbox.dylib
0x7fff8f21e000 - 0x7fff8f21ffff libunc.dylib (24.0.0 - compatibility 1.0.0) <0482C762-746D-37EB-A8C9-E1048CF70462> /usr/lib/system/libunc.dylib
0x7fff8f5d0000 - 0x7fff8f5d1ff7 libsystem_blocks.dylib (53.0.0 - compatibility 1.0.0) <8BCA214A-8992-34B2-A8B9-B74DEACA1869> /usr/lib/system/libsystem_blocks.dylib
0x7fff8feda000 - 0x7fff8ffb7fef libsystem_c.dylib (763.11.0 - compatibility 1.0.0) <D48352AB-D1F1-3D8F-875C-2C807425CB8C> /usr/lib/system/libsystem_c.dylib
0x7fff907e1000 - 0x7fff907e6fff libcache.dylib (47.0.0 - compatibility 1.0.0) <3D114C8A-AD1F-3C78-9E8C-B8F3810740E5> /usr/lib/system/libcache.dylib
0x7fff908ec000 - 0x7fff9095ffff libstdc++.6.dylib (52.0.0 - compatibility 7.0.0) <6BDD43E4-A4B1-379E-9ED5-8C713653DFF2> /usr/lib/libstdc++.6.dylib
0x7fff90e9b000 - 0x7fff90ec8fe7 libSystem.B.dylib (159.0.0 - compatibility 1.0.0) <B4654B67-7521-3CD2-A67D-E1393C459D23> /usr/lib/libSystem.B.dylib
0x7fff9165c000 - 0x7fff9165dfff libdnsinfo.dylib (395.7.0 - compatibility 1.0.0) <37FEFE78-BCB5-37EC-8E99-747469BCA4C7> /usr/lib/system/libdnsinfo.dylib
0x7fff91704000 - 0x7fff91740fff libsystem_info.dylib (??? - ???) <BC49C624-1DAB-3A37-890F-6EFD46538424> /usr/lib/system/libsystem_info.dylib
0x7fff920e2000 - 0x7fff920e3ff7 libremovefile.dylib (21.0.0 - compatibility 1.0.0) <AACAD200-A346-3653-89E2-D9D10FE4DC06> /usr/lib/system/libremovefile.dylib
0x7fff92227000 - 0x7fff92230fff libnotify.dylib (80.0.0 - compatibility 1.0.0) <BD08553D-8088-38A8-8007-CF5C0B8F0404> /usr/lib/system/libnotify.dylib
0x7fff92e3e000 - 0x7fff92e40fff libquarantine.dylib (36.0.0 - compatibility 1.0.0) <A6B3CF07-A0D0-3C56-9BEC-33CBDD63CB89> /usr/lib/system/libquarantine.dylib
0x7fff9385e000 - 0x7fff93864fff libmacho.dylib (800.0.0 - compatibility 1.0.0) <548BAEB6-8C4C-3B0F-AB0C-7E1C960BCAB5> /usr/lib/system/libmacho.dylib
0x7fff95371000 - 0x7fff9537bff7 liblaunch.dylib (392.18.0 - compatibility 1.0.0) <EB5C4B29-D3B7-38AC-A646-3D445C767F03> /usr/lib/system/liblaunch.dylib
0x7fff9777d000 - 0x7fff97782ff7 libsystem_network.dylib (??? - ???) <4ABCEEF3-A3F9-3E06-9682-CE00F17138B7> /usr/lib/system/libsystem_network.dylib
External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 8407398
thread_create: 1
thread_set_state: 0
VM Region Summary:
ReadOnly portion of Libraries: Total=50.0M resident=14.0M(28%) swapped_out_or_unallocated=36.1M(72%)
Writable regions: Total=17.4M written=60K(0%) resident=104K(1%) swapped_out=0K(0%) unallocated=17.3M(99%)
REGION TYPE VIRTUAL
=========== =======
MALLOC 9396K
MALLOC guard page 16K
STACK GUARD 56.0M
Stack 8192K
__DATA 516K
__LINKEDIT 47.1M
__TEXT 3000K
shared memory 12K
=========== =======
TOTAL 123.8M
Model: MacBookAir4,2, BootROM MBA41.0077.B00, 2 processors, Intel Core i7, 1.8 GHz, 4 GB, SMC 1.73f63
Graphics: Intel HD Graphics 3000, Intel HD Graphics 3000, Built-In, 384 MB
Memory Module: BANK 0/DIMM0, 2 GB, DDR3, 1333 MHz, 0x80AD, 0x484D54333235533642465238432D48392020
Memory Module: BANK 1/DIMM0, 2 GB, DDR3, 1333 MHz, 0x80AD, 0x484D54333235533642465238432D48392020
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0xE9), Broadcom BCM43xx 1.0 (5.100.98.75.10)
Bluetooth: Version 4.0.0f4, 2 service, 11 devices, 1 incoming serial ports
Serial ATA Device: APPLE SSD SM256C, 251 GB
USB Device: FaceTime Camera (Built-in), apple_vendor_id, 0x850a, 0xfa200000 / 3
USB Device: hub_device, 0x0424 (SMSC), 0x2513, 0xfa100000 / 2
USB Device: BRCM20702 Hub, 0x0a5c (Broadcom Corp.), 0x4500, 0xfa110000 / 5
USB Device: Bluetooth USB Host Controller, apple_vendor_id, 0x821f, 0xfa113000 / 6
USB Device: Apple Internal Keyboard / Trackpad, apple_vendor_id, 0x024c, 0xfa120000 / 4
USB Device: hub_device, 0x0424 (SMSC), 0x2513, 0xfd100000 / 2
USB Device: Internal Memory Card Reader, apple_vendor_id, 0x8404, 0xfd110000 / 3
最佳答案
从堆栈跟踪来看,您的 Python 解释器在进程退出时 C 库运行的“atexit”处理程序中崩溃。具体来说,清理“HDF5”库的代码似乎遇到了错误。我认为崩溃的发生是因为 Python 运行时大部分已被清理,并且当库尝试调用某个错误处理程序时,该处理程序已经消失。
您的 C 应用程序存在“相同”问题的唯一原因在于它还使用了未初始化的变量。
如果 Python 总是崩溃并出现非常相似的堆栈跟踪(在转储报告中查找“崩溃的线程:X”,然后在转储中找到 X 线程的崩溃回溯),那么 HDF5 有问题正在使用。也许这是 Mac Python 端口中的一个已知错误? (我不太确定 hdf5 库是什么。)
关于关闭/退出时出现 python 段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7450881/
我正在处理一组标记为 160 个组的 173k 点。我想通过合并最接近的(到 9 或 10 个组)来减少组/集群的数量。我搜索过 sklearn 或类似的库,但没有成功。 我猜它只是通过 knn 聚类
我有一个扁平数字列表,这些数字逻辑上以 3 为一组,其中每个三元组是 (number, __ignored, flag[0 or 1]),例如: [7,56,1, 8,0,0, 2,0,0, 6,1,
我正在使用 pipenv 来管理我的包。我想编写一个 python 脚本来调用另一个使用不同虚拟环境(VE)的 python 脚本。 如何运行使用 VE1 的 python 脚本 1 并调用另一个 p
假设我有一个文件 script.py 位于 path = "foo/bar/script.py"。我正在寻找一种在 Python 中通过函数 execute_script() 从我的主要 Python
这听起来像是谜语或笑话,但实际上我还没有找到这个问题的答案。 问题到底是什么? 我想运行 2 个脚本。在第一个脚本中,我调用另一个脚本,但我希望它们继续并行,而不是在两个单独的线程中。主要是我不希望第
我有一个带有 python 2.5.5 的软件。我想发送一个命令,该命令将在 python 2.7.5 中启动一个脚本,然后继续执行该脚本。 我试过用 #!python2.7.5 和http://re
我在 python 命令行(使用 python 2.7)中,并尝试运行 Python 脚本。我的操作系统是 Windows 7。我已将我的目录设置为包含我所有脚本的文件夹,使用: os.chdir("
剧透:部分解决(见最后)。 以下是使用 Python 嵌入的代码示例: #include int main(int argc, char** argv) { Py_SetPythonHome
假设我有以下列表,对应于及时的股票价格: prices = [1, 3, 7, 10, 9, 8, 5, 3, 6, 8, 12, 9, 6, 10, 13, 8, 4, 11] 我想确定以下总体上最
所以我试图在选择某个单选按钮时更改此框架的背景。 我的框架位于一个类中,并且单选按钮的功能位于该类之外。 (这样我就可以在所有其他框架上调用它们。) 问题是每当我选择单选按钮时都会出现以下错误: co
我正在尝试将字符串与 python 中的正则表达式进行比较,如下所示, #!/usr/bin/env python3 import re str1 = "Expecting property name
考虑以下原型(prototype) Boost.Python 模块,该模块从单独的 C++ 头文件中引入类“D”。 /* file: a/b.cpp */ BOOST_PYTHON_MODULE(c)
如何编写一个程序来“识别函数调用的行号?” python 检查模块提供了定位行号的选项,但是, def di(): return inspect.currentframe().f_back.f_l
我已经使用 macports 安装了 Python 2.7,并且由于我的 $PATH 变量,这就是我输入 $ python 时得到的变量。然而,virtualenv 默认使用 Python 2.6,除
我只想问如何加快 python 上的 re.search 速度。 我有一个很长的字符串行,长度为 176861(即带有一些符号的字母数字字符),我使用此函数测试了该行以进行研究: def getExe
list1= [u'%app%%General%%Council%', u'%people%', u'%people%%Regional%%Council%%Mandate%', u'%ppp%%Ge
这个问题在这里已经有了答案: Is it Pythonic to use list comprehensions for just side effects? (7 个答案) 关闭 4 个月前。 告
我想用 Python 将两个列表组合成一个列表,方法如下: a = [1,1,1,2,2,2,3,3,3,3] b= ["Sun", "is", "bright", "June","and" ,"Ju
我正在运行带有最新 Boost 发行版 (1.55.0) 的 Mac OS X 10.8.4 (Darwin 12.4.0)。我正在按照说明 here构建包含在我的发行版中的教程 Boost-Pyth
学习 Python,我正在尝试制作一个没有任何第 3 方库的网络抓取工具,这样过程对我来说并没有简化,而且我知道我在做什么。我浏览了一些在线资源,但所有这些都让我对某些事情感到困惑。 html 看起来
我是一名优秀的程序员,十分优秀!