Code Monkey home page Code Monkey logo

Comments (10)

dinhvh avatar dinhvh commented on August 17, 2024

It's not clear what this issue is about. Could you clarify?

from mailcore2.

CodaFi avatar CodaFi commented on August 17, 2024

Set a breakpoint in fillWithInfo() and you can see that all of the objectForKey() calls are failing because MCSTR() does "" "str" "" instead of "str"

from mailcore2.

dinhvh avatar dinhvh commented on August 17, 2024

When you're talking about code, it's more clear if you reference which file to look into. fillWithInfo() name is used at several locations.

Regarding the issue itself:

I don't think that's the reason of your issue. Keep investigating about your specific issue.
If MCSTR() was really broken, it would fail everywhere.

MCSTR() does "" str "", which concatenate an empty string with str with an empty string.
It makes sure that str is a constant.

from mailcore2.

dinhvh avatar dinhvh commented on August 17, 2024

Reopen if that's really the issue and give more details.

from mailcore2.

CodaFi avatar CodaFi commented on August 17, 2024

But it fails specifically for the providers dictionary because the JSON keys aren't made with MCSTR(), they're just parsed out into it. It works everywhere else because everywhere else uses MCSTR().

Here, these lines fail for every provider HashMap given to them:

https://github.com/MailCore/mailcore2/blob/master/src/core/provider/MCMailProvider.cc#L62
https://github.com/MailCore/mailcore2/blob/master/src/core/provider/MCMailProvider.cc#L66

And because they fail, every one of the folder lookup methods afterwards dereferences a NULL pointer and causes a fatal crash.

from mailcore2.

CodaFi avatar CodaFi commented on August 17, 2024

If I replace those MCSTR()'s with mailcore::String::stringWithUTF8Format() it works like a charm.

from mailcore2.

dinhvh avatar dinhvh commented on August 17, 2024

Therefore, that's an issue with String::uniquedStringWithUTF8Characters().
Do you have a minimal code that reproduces the issue?

Could you try to apply that patch?

diff --git a/src/core/basetypes/MCString.cc b/src/core/basetypes/MCString.cc
index 6710e59..2398958 100644
--- a/src/core/basetypes/MCString.cc
+++ b/src/core/basetypes/MCString.cc
@@ -1975,6 +1975,7 @@ String * String::substringWithRange(Range range)
}

static chash * uniquedStringHash = NULL;
+static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;

static void initUniquedStringHash()
{
@@ -1991,14 +1992,17 @@ String * String::uniquedStringWithUTF8Characters(const char * UTF8Characters)
pthread_once(&once, initUniquedStringHash);
key.data = (void *) UTF8Characters;
key.len = (unsigned int) strlen(UTF8Characters);

  • pthread_mutex_lock(&lock);
    r = chash_get(uniquedStringHash, &key, &value);
    if (r == 0) {
  •    pthread_mutex_unlock(&lock);
     return (String *) value.data;
    
    }
    else {
    value.data = new String(UTF8Characters);
    value.len = 0;
    chash_set(uniquedStringHash, &key, &value, NULL);
  •    pthread_mutex_unlock(&lock);
     return (String *) value.data;
    
    }
    }

from mailcore2.

dinhvh avatar dinhvh commented on August 17, 2024

Patch not broken by formatting is here:
https://gist.github.com/dinhviethoa/5692527
Let me know if it solves your issue.

from mailcore2.

CodaFi avatar CodaFi commented on August 17, 2024

Yep, that patch solves it. Sorry I couldn't answer you earlier, I was integrating the framework and had to fix a ton of warnings before I could test anything.

from mailcore2.

dinhvh avatar dinhvh commented on August 17, 2024

Fixed with b88d4be

from mailcore2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.