NSData dataWithBytesNoCopy 释放时触发guardMalloc

发布于 2024-11-16 08:48:22 字数 1800 浏览 1 评论 0原文

请参阅下面的更新

<s:element name="GetFile">
    <s:complexType>
    <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="User" type="s:string"/>
    <s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string />
    <s:element minOccurs="0" maxOccurs="1" name="ObjectId" type="s:string"/>
    </s:sequence>
    </s:complexType>
</s:element>
<s:element name="GetFileResponse">
    <s:complexType>
    <s:sequence>
    <!-- This is the return value -->
    <s:element minOccurs="0" maxOccurs="1" 
       name="GetFileResult" type="s:base64Binary"/>
    </s:sequence>
    </s:complexType>
</s:element>

使用 wsdl2objc 生成的代码,我在启用防护 malloc 时收到错误:

GuardMalloc[eBridge-1115]:守卫 malloc 区域失败:释放指针 我们没有分配那不是 被任何注册区域认领
GuardMalloc[eBridge-1115]:明确 陷入调试器!!!

这是我在全部使用 asm 之前看到的最后一个 obj-c 代码:

@implementation WebServices_GetFileResponse
- (void)dealloc
{
    [soapSigner release];
    //breaks on the line below
    if(GetFileResult != nil) [GetFileResult release];

    [super dealloc];
}

我相信它正在破坏生成的 Response 对象的 deserializeElementsFromNode 但尚未确定它。这不是一个“为我调试我的程序”的问题。我的问题很简单 - 有没有人遇到过 wsdl2objc 生成的 base64Binary 字节数组返回类型的问题?

更新


我认为问题在于

+ (id)dateWithBase64EncodedString;

NSData (MBBase64) -

char *data = malloc(...);
NSUInteger length = 0;

... // fill data[length++];

realloc(data, length);
return [NSData dataWithBytesNoCopy:bytes length:length]; //offending line?

我假设这不会使 Objective-C 运行时声明内存..所以当我释放 NSData 时它仍然在某种程度上用“malloc”分配。还有人比我更了解吗?

Please see update below

<s:element name="GetFile">
    <s:complexType>
    <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="User" type="s:string"/>
    <s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string />
    <s:element minOccurs="0" maxOccurs="1" name="ObjectId" type="s:string"/>
    </s:sequence>
    </s:complexType>
</s:element>
<s:element name="GetFileResponse">
    <s:complexType>
    <s:sequence>
    <!-- This is the return value -->
    <s:element minOccurs="0" maxOccurs="1" 
       name="GetFileResult" type="s:base64Binary"/>
    </s:sequence>
    </s:complexType>
</s:element>

With the generated code from wsdl2objc I get an error with guard malloc enabled:

GuardMalloc[eBridge-1115]: guard
malloc zone failure: freeing a pointer
we didn't allocate that was not
claimed by any registered zone
GuardMalloc[eBridge-1115]: Explicitly
trapping into debugger!!!

This is the last obj-c code i can see before it goes all asm on me:

@implementation WebServices_GetFileResponse
- (void)dealloc
{
    [soapSigner release];
    //breaks on the line below
    if(GetFileResult != nil) [GetFileResult release];

    [super dealloc];
}

I believe it is breaking in the generated Response object's deserializeElementsFromNode but have not pinpointed it yet. This is not a "Debug my program for me" question. My question is simply - Has anyone ran into this problem with a base64Binary byte array return type generated by wsdl2objc?

Update


The problem I believe lies in

+ (id)dateWithBase64EncodedString;

in NSData (MBBase64) -

char *data = malloc(...);
NSUInteger length = 0;

... // fill data[length++];

realloc(data, length);
return [NSData dataWithBytesNoCopy:bytes length:length]; //offending line?

Im making an assumption that this does not make the objective-c runtime claim the memory.. so when I am releasing the NSData it is somehow still allocated with 'malloc'. Does anyone know better than I do?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

往事风中埋 2024-11-23 08:48:22

在 + (id)dateWithBase64EncodedString 中,我将最后一行更改为:

return [NSData dataWithBytesNoCopy:bytes length:length **freeWhenDone:NO**];

它似乎有效。这只是我的技巧,但如果您是 wsdl2objc 的作者,希望它会有所帮助。

In + (id)dateWithBase64EncodedString I changed the last line to:

return [NSData dataWithBytesNoCopy:bytes length:length **freeWhenDone:NO**];

and it seemed to work. This is just my hack, but if you are the author of wsdl2objc sees this hopefully it will help.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文