We study the motion of a bubble driven by buoyancy and thermocapillarity in a tube with a non-uniformly-heated walls, containing a so-called "self-rewetting fluid"; the surface tension of the latter exhibits a parabolic dependence on temperature with a well-defined minimum. In the Stokes flow limit, we derive the conditions under which a spherical bubble can come to rest in a self-rewetting fluid whose temperature varies linearly in the vertical direction, and demonstrate that this is possible for both positive and negative temperature gradients. This is in contrast to the case of simple fluids whose surface tension decreases linearly with temperature for which bubble motion is arrested for negative temperature gradients only. In the case of self-rewetting fluids, we propose an analytical expression for the position of bubble arrestment as a function of other dimensionless numbers. We also perform direct numerical simulation of axisymmetric bubble motion in a fluid whose temperature increases linearly with vertical distance from the bottom of the tube; this is done for a range of Bond and Gallileo numbers, and for various parameters that govern the functional dependence of surface tension on temperature. We demonstrate that bubble motion can be reversed and then arrested in self-rewetting fluids only, and not in linear ones, for sufficiently small Bond numbers. We also demonstrate that considerable bubble elongation is possible under significant wall confinement, and for strongly self-rewetting fluids and large Bond numbers. The mechanisms underlying the phenomena observed are elucidated by considering how the surface tension dependence on temperature affects the thermocapillary stresses in the flow.