[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Strange Segfault with V 0.9.3 an MinGW Cross Compile
[Thread Prev] | [Thread Next]
- Subject: Re: Strange Segfault with V 0.9.3 an MinGW Cross Compile
- From: g4-lisz@xxxxxxxxxxxx
- Reply-to: libssh@xxxxxxxxxx
- Date: Wed, 15 Jan 2020 13:05:20 +0100
- To: libssh@xxxxxxxxxx
Hi, On 15.01.20 10:02, Skalák, Zdeněk wrote: > Hello, > > On Wed, Jan 15, 2020 at 9:48 AM <g4-lisz@xxxxxxxxxxxx > <mailto:g4-lisz@xxxxxxxxxxxx>> wrote: > > On 15.01.20 08:27, Andreas Schneider wrote: > > > On Wednesday, 15 January 2020 01:22:13 CET g4-lisz@xxxxxxxxxxxx > <mailto:g4-lisz@xxxxxxxxxxxx> wrote: > >> I cross compiled V 0.9.3 with MinGW on Ubuntu. The compilation > worked > >> flawlessly. > >> > >> But when I run my code linked to the resulting libssh.dll, it > crashes > >> immediately when I set verbosity to > 2. > >> > >> I could track this down to vsnprintf() which is called through > line 865 > >> in channels.c: > >> > >> SSH_LOG(SSH_LOG_PACKET, > >> "placing %zu bytes into channel buffer (%s)", > >> len, > >> s_stderr ? "stderr" : "stdout"); > > Try s_stderr -> is_stderr > > Hi Andreas, > > Haha that would be a silly issue, when the compiler would not complain > about this... > > Sorry, I somehow lost the 'i' when I pasted the code into the mail. > > > > I can imagine two things which could went wrong: > a) libstdc (or whomever implements the vsnprintf()) doesn't know the > `%zu` format, so this one is skipped and the `len` argument is used > for the (%s) format > b) 32/64 bit mismatch - the format (count of bytes) of the `len` on > the stack doesn't correspond to the format (count of bytes) of the > `%zu` specifier, so for the second (%s) format, some `grabage from the > stack` is used > > Both these two scenarios can lead to mysterious crashes .... Thanks a lot for your thoughts! Indeed it was a). I realized that when after my "partch" (removing %s and the second argument), `zu` was printed instead of the length... I sent a real patch (Use inttypes macros for size_t format string). Best regards, Till
Strange Segfault with V 0.9.3 an MinGW Cross Compile | g4-lisz@xxxxxxxxxxxx |
Re: Strange Segfault with V 0.9.3 an MinGW Cross Compile | Andreas Schneider <asn@xxxxxxxxxxxxxx> |
Re: Strange Segfault with V 0.9.3 an MinGW Cross Compile | g4-lisz@xxxxxxxxxxxx |
Re: Strange Segfault with V 0.9.3 an MinGW Cross Compile | Skalák, Zdeněk <zskalak@xxxxxxxxxxxx> |