pobrn / mktorrent

A simple command line utility to create BitTorrent metainfo files
Other
474 stars 72 forks source link

Generation of broken torrents with CFLAGS that differ from defaults #22

Closed holgersson32644 closed 6 years ago

holgersson32644 commented 6 years ago

Hi,

on Gentoo we have a bug where mktorrent-1.1 creates corrupt torrents when built with other CFLAGS than the default ones, e.g. "-march=native" (at least on Intel i-CPUs so far reported).

The compiler versions tested are gcc-6.4.0 and 7.3.0.

Any ideas what's wrong here?

cmclark65 commented 6 years ago

Have a look at https://github.com/cmclark65/mktorrent. I fixed at least one problem related to word size and also cleared a lot of compiler warnings and problems when forked mktorrent, and possibly that will fix the problems compiling for different architectures. I'm not sure how difficult it would be to merge my fork with the current main fork, since there have been a number of commits to the main since then.

holgersson32644 commented 6 years ago

@cmclark65 thanks, it looks as your fork fixes it. Your main commit is really huge - could you split it up a bit? Currently it can't be merged into ruddes tree, and smaller pieces will help to update your improvements.

cmclark65 commented 6 years ago

| From: holgersson notifications@github.com

| @cmclark65 thanks, it looks as your fork fixes it. Your main | commit is really huge - could you split it up a bit? Currently | it can't be merged into ruddes tree, and smaller pieces will | help to update your improvements.

I'd love to help you, but:

I cleared all the compiler warnings and added the features I wanted 4 years ago.

I haven't done any programming that I recall since that time.

I don't really understand git or other concurrent/branching source control systems and their use very well.

For sure, I believe my code is good and my fixes for all the compiler warnings to be pedantically "correct", but I am not a professional coder and don't have the time right now to learn/relearn how to use git to break up my commit. Nor to go through the main rudde branch to see what has changed since I did this.

I'm sorry I didn't break my changes into three commits at the time (the bug fixes; the auto piece size feature; the arbitrary non-standard dictionary entry feature). I wasn't intending to do the bug fixes but unfortunately one of the problems was that the variable used to calculate the total data size of the files in a torrent was over-flowing (which didn't actually cause a problem most of the time) on some or all architectures, but I needed it to be correct in order to calculate the piece size automatically, and once I fixed that I found other type declarations that were bad/wrong that needed to be right sized also (mostly counters) ...

If you look at the diffs from my commit, the things you want/need are all:

the diff for hash.c

the diff hash_pthreads.c

ignore the changes to init.c except the changes to the includes.

ignore changes to main.c except changes to the includes

in mktorrent.h, just change the type of the "size" variable and ignore the rest of my changes

I can't remember if my changes to prefix.c are necessary to fixing the variable type/size issues or not but think they are.

I think anyone who programs in c and understands git better than I could port just that stuff over to the current rudde fork, and then set your CFLAGS to add "-Wextra -pedantic" and properly clear all warnings that remain on both 32 (with and without the USE_LARGE_FILES defined) and 64 bit systems. And then mktorrent should probably survive the architecture you are having issues with using also. If so, commit that and do the pull request.

-- Charles Clark | cmc@stegosaur.us

holgersson32644 commented 6 years ago

I'd love to help you, but:

-> no but, your description actually helped me a lot ;-)