I am on 64-bit, %lu works just fine. My problem is that %llu on my 64-bit OS causes apr_vformatter to not identify %llu as a "%" string, so that in my example below it skips the %llu and sends the u_int64_t to the %s, causing a seg fault. Whereas printf does not have this behavior on a 64-bit OS.
Anyways, I've submitted a patch on an existing bug, who knows if it'll take. :) https://issues.apache.org/bugzilla/show_bug.cgi?id=48476 On Aug 17, 2010, at 4:28 PM, Philip Prindeville wrote: > Hey Chris, > > I'm assuming this is only happening on a 32-bit native machine, right? > > Because on an x86_64 machine '%lu' would be 64-bit and behave correctly, yes? > > -Philip > > > On 8/11/10 8:51 AM, Chris Knight wrote: >> I spent half-a-day yesterday trying to figure out why I was crashing in >> apr_psprintf on a strlen until I realized that my "%llu%s" format string was >> causing it to use my long long int as a char *. >> >> Needless to say, no harm in adding support for %ll[du] yes? >> >> Ah, 64-bit fun for everyone.... >> >> Example code: >> >> #include<apr.h> >> #include<apr_pools.h> >> #include<apr_strings.h> >> #include<stdio.h> >> >> int main(int argc, char **argv) { >> apr_pool_t *pool = NULL; >> char *s = "hello world"; u_int64_t v = 12345678; >> >> apr_pool_initialize(); apr_pool_create(&(pool), NULL); >> printf("%llu%s", v, s); // works >> char *f = apr_psprintf(pool, "%llu%s", v, s); // segfault on strlen >> printf("%s\n", f); >> } >