由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - Mysterious PgSQL 8.3 crash
相关主题
two general C++ question除了类,c++和C区别在那?
无法编译一个文件问个C++的String问题
can't understand this function definition"out of stack space" when constructing a _bstr_t object
[合集] 问个PHP+apache的问题 (转载)stl的map可以嵌套几层?
simple question on C++ initialization listhow can I convert CString to char*?
A function can be history-sensitive??????[合集] dll输出问题
高手请进[合集] 一个依赖于平台的memory问题
How to conver CString to long long type?问个c++问题
相关话题的讨论汇总
话题: pgsql话题: crash话题: mysterious话题: create话题: sprintf
进入Programming版参与讨论
1 (共1页)
c*****t
发帖数: 1879
1
【 以下文字转载自 Database 讨论区 】
发信人: coconut (向唐僧大师学习中), 信区: Database
标 题: Mysterious PgSQL 8.3 crash
发信站: BBS 未名空间站 (Fri Feb 8 12:32:47 2008), 站内
写 stored procedure 的时候,发现 sprintf, elog, ereport 等统统
会造成 crash 。可是 8.2.6 底下好好的。比如
strcpy (buffer, "test"); 执行没问题,但是
sprintf (buffer, "%s", "test"); 就 crash。
例如:
CREATE FUNCTION TCDB.t_create_table(cstring) RETURNS void
AS '/projects/workspace/tcdb/src/server/libmy_utils.dll', 't_create_table'
LANGUAGE C STRICT;
Datum t_create_table (PG_FUNCTION_ARGS)
{
T*******i
发帖数: 4992
2
0xc0000005是啥?查了么?

【在 c*****t 的大作中提到】
: 【 以下文字转载自 Database 讨论区 】
: 发信人: coconut (向唐僧大师学习中), 信区: Database
: 标 题: Mysterious PgSQL 8.3 crash
: 发信站: BBS 未名空间站 (Fri Feb 8 12:32:47 2008), 站内
: 写 stored procedure 的时候,发现 sprintf, elog, ereport 等统统
: 会造成 crash 。可是 8.2.6 底下好好的。比如
: strcpy (buffer, "test"); 执行没问题,但是
: sprintf (buffer, "%s", "test"); 就 crash。
: 例如:
: CREATE FUNCTION TCDB.t_create_table(cstring) RETURNS void

c*****t
发帖数: 1879
3
C0000005 STATUS_ACCESS_VIOLATION The instruction at 0x%08lx
referenced memory at 0x%08lx. The memory could not be %s.

【在 T*******i 的大作中提到】
: 0xc0000005是啥?查了么?
T*******i
发帖数: 4992
4
it looks like a memory leak. hehe

【在 c*****t 的大作中提到】
: C0000005 STATUS_ACCESS_VIOLATION The instruction at 0x%08lx
: referenced memory at 0x%08lx. The memory could not be %s.

X****r
发帖数: 3557
5
你试过用小一点的buffer吗?比如16而不是8192。万一是新版本的PqSQL把栈限制得更
小了?

【在 c*****t 的大作中提到】
: C0000005 STATUS_ACCESS_VIOLATION The instruction at 0x%08lx
: referenced memory at 0x%08lx. The memory could not be %s.

c*****t
发帖数: 1879
6
试了 200,也不行。不是 stack 的问题。这个问题类似
char* foo = "abc";
foo[0] = 'd';
因为 official windows binary 是用 vc++ compiled,而我的 dll 是用
MinGW 编的,以为是这问题。但是我尝试用 MinGW 编译了 PgSQL 8.3 以
后也是同样的问题。
sigh,8.3 里刚好有我急切需要的 composite type array 支持,但是这
个问题让俺止步。俺这个程序在 8.2.6 上执行好好的,但是 8.2.6 没
composite type array 支持我下面要加的东西就没法写 :(

【在 X****r 的大作中提到】
: 你试过用小一点的buffer吗?比如16而不是8192。万一是新版本的PqSQL把栈限制得更
: 小了?

X****r
发帖数: 3557
7
如果是这样的话把字符串常量都放到可以修改的地方试试?比如
char format[] = "%s"; // or use static if needed
char text[] = "test";
sprintf(buffer, format, text);

【在 c*****t 的大作中提到】
: 试了 200,也不行。不是 stack 的问题。这个问题类似
: char* foo = "abc";
: foo[0] = 'd';
: 因为 official windows binary 是用 vc++ compiled,而我的 dll 是用
: MinGW 编的,以为是这问题。但是我尝试用 MinGW 编译了 PgSQL 8.3 以
: 后也是同样的问题。
: sigh,8.3 里刚好有我急切需要的 composite type array 支持,但是这
: 个问题让俺止步。俺这个程序在 8.2.6 上执行好好的,但是 8.2.6 没
: composite type array 支持我下面要加的东西就没法写 :(

c*****t
发帖数: 1879
8
试过了。照样 crash 。所以我才奇怪。

【在 X****r 的大作中提到】
: 如果是这样的话把字符串常量都放到可以修改的地方试试?比如
: char format[] = "%s"; // or use static if needed
: char text[] = "test";
: sprintf(buffer, format, text);

c*****t
发帖数: 1879
9
Finally got it fixed. The new postgresql pre-compiled binary was
created using VC8 instead of MinGW which was used in previous versions,
so are the library files it bundles with it. I was using MinGW and
there are some incompatibilities between these two (particulary for
the vararg I guess). That's why some stuff works fine and some aren't.
Also, postgres re-defines sprintf etc to use its own routine, that's
why I was looking at the wrong place.
1 (共1页)
进入Programming版参与讨论
相关主题
问个c++问题simple question on C++ initialization list
#ifdef _MSC_VER 是什么意思啊?A function can be history-sensitive??????
Undefined symbols for architecture x86_64: 求助高手请进
有谁google过cstring吗?How to conver CString to long long type?
two general C++ question除了类,c++和C区别在那?
无法编译一个文件问个C++的String问题
can't understand this function definition"out of stack space" when constructing a _bstr_t object
[合集] 问个PHP+apache的问题 (转载)stl的map可以嵌套几层?
相关话题的讨论汇总
话题: pgsql话题: crash话题: mysterious话题: create话题: sprintf