- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我使用 ctypes 围绕 libbgpdump 编写了一个 python 包装器,但是当 libbgpdump 调用“err()”时它会出现段错误。这是失败的 C 代码:
if(count > MAX_PREFIXES) {
err("too many prefixes (%i > %i)", count, MAX_PREFIXES);
return MAX_PREFIXES;
}
当我用 printf() 替换 err() 时,它起作用了。
这是堆栈跟踪:
#0 strchrnul () at ../sysdeps/x86_64/strchrnul.S:34
#1 0x00007ffff6f2ba60 in __find_specmb (format=0x3fa <Address 0x3fa out of bounds>) at printf-parse.h:99
#2 _IO_vfprintf_internal (s=0x7fffffffc660, format=0x3fa <Address 0x3fa out of bounds>, ap=0x7fffffffce68) at vfprintf.c:1335
#3 0x00007ffff6f311a4 in buffered_vfprintf (s=0x7ffff729d1a0 <_IO_2_1_stderr_>, format=<optimized out>, args=<optimized out>) at vfprintf.c:2313
#4 0x00007ffff6f2bbde in _IO_vfprintf_internal (s=0x7ffff729d1a0 <_IO_2_1_stderr_>, format=0x3fa <Address 0x3fa out of bounds>, ap=0x7fffffffce68)
at vfprintf.c:1316
#5 0x00007ffff6fd4ef1 in __GI_vwarn (format=0x3fa <Address 0x3fa out of bounds>, ap=0x7fffffffce68) at err.c:140
#6 0x00007ffff6fd512e in __GI_verr (status=-177566080, format=<optimized out>, ap=<optimized out>) at err.c:168
#7 0x00007ffff6fd51e7 in err (status=<optimized out>, status@entry=-177566080, format=<optimized out>,
format@entry=0x3fa <Address 0x3fa out of bounds>) at err.c:184
#8 0x00007ffff56a4196 in read_prefix_list (s=s@entry=0x7fffffffd010, afi=afi@entry=1, prefixes=prefixes@entry=0xa4d9a4,
incomplete=incomplete@entry=0xa527c8) at bgpdump_lib.c:1255
#9 0x00007ffff56a5db8 in process_zebra_bgp_message_update (asn_len=4 '\004', entry=0xa48b20, s=0x7fffffffd010) at bgpdump_lib.c:741
#10 process_zebra_bgp_message (s=s@entry=0x7fffffffd0e0, entry=entry@entry=0xa48b20, asn_len=asn_len@entry=4 '\004') at bgpdump_lib.c:682
#11 0x00007ffff56a6941 in process_zebra_bgp (entry=0xa48b20, s=0x7fffffffd0e0) at bgpdump_lib.c:543
#12 bgpdump_read_next (dump=0x9c2cf0) at bgpdump_lib.c:190
#13 0x00007ffff5b7d4d8 in ffi_call_unix64 () from /usr/lib/python2.7/lib-dynload/_ctypes.so
#14 0x00007ffff5b7cee0 in ffi_call () from /usr/lib/python2.7/lib-dynload/_ctypes.so
#15 0x00007ffff5b6f311 in _ctypes_callproc () from /usr/lib/python2.7/lib-dynload/_ctypes.so
#16 0x00007ffff5b6fa82 in ?? () from /usr/lib/python2.7/lib-dynload/_ctypes.so
#17 0x000000000046005e in PyEval_EvalFrameEx ()
#18 0x0000000000467209 in PyEval_EvalCodeEx ()
#19 0x00000000004ab55a in ?? ()
#20 0x0000000000486c3d in ?? ()
#21 0x0000000000491a5d in PyEval_CallObjectWithKeywords ()
#22 0x00000000004ebdc7 in ?? ()
#23 0x000000000045fdca in PyEval_EvalFrameEx ()
#24 0x0000000000460227 in PyEval_EvalFrameEx ()
#25 0x0000000000467209 in PyEval_EvalCodeEx ()
#26 0x00000000004cfc12 in PyEval_EvalCode ()
#27 0x00000000005137db in ?? ()
#28 0x000000000044cab6 in PyRun_FileExFlags ()
#29 0x000000000044cfca in PyRun_SimpleFileExFlags ()
#30 0x000000000044dd0c in Py_Main ()
#31 0x00007ffff6f0476d in __libc_start_main (main=0x44ddcb <main>, argc=2, ubp_av=0x7fffffffe178, init=<optimized out>, fini=<optimized out>,
rtld_fini=<optimized out>, stack_end=0x7fffffffe168) at libc-start.c:226
#32 0x00000000004cda7d in _start ()
感谢您的帮助:)
--------------------编辑------------------------ -
啊,现在我明白问题所在了。 libbgpdump 使用它自己的 err() 函数,在 ./util.c 中定义,但是当我使用来自 ctypes 的库时,它会尝试使用来自 err.h 的库,即使它从未包含在内。
对于为什么会发生这种情况以及如何使其发挥作用有什么建议吗?
最佳答案
基本上,您缺少 err 函数的一个参数,即返回值(参见 err MAN pages ):
if(count > MAX_PREFIXES)
err(MAX_PREFIXES, "too many prefixes (%i > %i)", count, MAX_PREFIXES);
关于python - 当从 python ctypes 调用时,err() 处的段错误(来自 err.c),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23889812/
这个问题已经有答案了: What is the difference between a variable, object, and reference? [duplicate] (5 个回答) 已关
我正在使用以下代码来学习java套接字编程。它的作用是,client.java 程序从用户那里获取一个号码并将其发送到 sever.java。然后服务器将其乘以2并发回给客户端。在我的客户端程序中,它
我编写了一个自己开发的串行端口类,为了简单起见,我使用了阻塞/同步/非重叠。我浏览了所有 MSDN 文档,这对我来说很困难。 我在从端口打开、传输或接收字节方面没有任何问题。所有操作都是同步并且没有线
//Not finished -- disregard function evaluate() { var cdate = new Date(); var cday = cdate.getDa
我已经尝试过了,但它有效 例如: x= 523.897 y= x[0:"."] print y 我只想打印 523。如何让 Python 抓取字符串直到某个字母或数字? 最佳答案 行 y = x[0:
我想移动拐 Angular 处的方框(从左上角开始水平移动 Angular 落到右上角然后你去到右下角。 function myMove() { var elem = document.getEl
如何让侧边栏停止在第二个侧边栏部分而不是顶部? fiddle http://jsfiddle.net/EvAdP/2/ HTML I'm the header
我刚刚在大学开始我的第二门编程类(class),我们的第一个作业相当简单,旨在基本上检查我们的环境并检查我们是否知道如何通过类(class)网站提交作业。 当我运行我们提供的代码时,它卡在应该提示用户
我目前正忙于我的这个信息学元素(构建一个示例交友网站)。问题是我在把所有东西都放在正确的地方时遇到了一些麻烦。一切都很顺利,直到我的邮箱出现在错误的位置(但是,Dreamweaver 会按照我的意
我想,和你一样hover a GIF shot on Dribbble , 当光标位于元素高度顶部之后/50% 处时显示带有信息的 div。 测试示例 我做了这个,这是有效的,但有点棘手......特
我有一个下拉菜单,并且我已将 mouseenter 设置为选项。因此,如果鼠标位于触发器之外,菜单应该关闭。我正在使用 jQuery 1.8.0。这可能是 CSS 问题吗? 这是我初始化插件的代码。
我正在尝试在 Visual Basic for Applications 中编写一个 hello world 应用程序,即修改 Excel 工作表中的单元格。这是: Sub hello() D
我的应用程序使用 JSF 2.1 和 PrimeFaces。最近,由于一些线程卡住,观察到 CPU 利用率非常高。所有卡住线程的卡住线程转储都指向 javax.faces.component.UICo
在列出 aws cognito 用户时,我的 Node js 应用程序遇到问题。 仅当我有超过 60 个 Cognito 用户时才会出现此问题。 Reference of API 下面是我的代码片段。
我是 ubuntu 用户..我在 php 中有一个执行 python 文件的命令..python 文件设置为可执行文件..所以,我的 php 命令是:- shell_exec("try.py");
我正在尝试将剪贴板内容写入文件,但由于某种原因程序卡住了。 FILE *fp; fp = fopen("tmp.code","w"); fprintf(fp,getclip()); /*writes*
当用户向下滚动时,我使用此代码使侧边栏固定在某个 div 处。问题是我必须手动输入一个阈值数字,这并不总是理想的,因为该部分的位置可能会更改或在各种浏览器和系统之间不一致。我想知道是否有一种方法可以在
我有一个字符串数组,例如 first_page = {{"U","M","Y","Q","I","A","L","D","P"、"F"、"E"、"G"、"T"、"Z"、"V"、"W"、"H"、"O"、
我能否在页面上的特定 px 位置放置一个元素(例如图像),然后让文本围绕它流动? 必要时使用 JS/jquery。 我确实看到了这个Have text flow around an object th
第一次在这里提问。 我有两个简单的 Javascript 函数,1. 生成一个随机字母,2. 在每个单元格中使用单个字母填充 10x10 表格。创建表的主要函数是通过带有 onclick 的简单 HT
我是一名优秀的程序员,十分优秀!